XCFit 4 released : Swift 3.1, Carthage and Pre-defined BDD Steps Support

Home / Automation / XCFit 4 released : Swift 3.1, Carthage and Pre-defined BDD Steps Support

XCFit is full stack iOS BDD framework in Xcode. XCFit setup Xcode templates with skeleton code and directory structures which helps us to get started with BDD and XCFit Swift Framework provides lots of predefined BDD Style steps to automated BDD with less code. You can read details of XCFit on Github. XCFit 4.0 is jus released with lots of features, the brief release notes are available on GitHub here.  Let”s see what’s new in the XCFit 4 in details  in this post.

XCFit 4.0

XCFit 4.0 is a major release with lot of improvements on Swift Frameworks. The XCFit 4 .0 has following major changes.

  • Support for Swift 3.1 and Xcode 8.3
  • Added Carthage Support for the XCFit Framework with Integrated Cucumberish library.
  • Added lots of Predefined steps for the XCFit and Cucumberish, so that we can use them directly into our project.
  • Xcode templates are improved by separating and XCFit and Fitnesse templates in different command.
  • Improved README and Web page documentation of XCFit with Video Demo on Youtube.
  • Let’s see new changes in brief.

Swift 3.1 Support

Apple has just release Swift-3.1-dev snapshot with some useful changes in the XCTest framework. You can read about newly added classes in the XCUITests on my DZone blog. Basically, XCUITest now support asynchronous testing and able to to control Siri with new classes. Apple has added XCWaiter class for better waiter waiting which has beed utilised by XCFit.

XCFit 4.0 is fully built on Swift 3.1, you can see the Swift version on Cocoapods. The idea is to fully support XCFit Swift framework from XCFt 3.1 onwards. You might need to wait until Swift 3.1 public release to use new features of XCFit 4.0 if you don’t have Swift 3.1 installed yet.

Carthage Support

XCFit Swift framework can now be built using Carthage, previously it was used with Cocoapods only but XCFit 4.0 added support to Carthage as well. XCFit has dependency on Cucumberish frameworks so that we can get both of these framework by pulling XCFit. Just add following to Cartfile  in your project root

Now, we can download and build the frameworks using following command

Now we can set both XCFit and Cucumberish target manually.

Setting XCFit Swift Framework

The above command will create ‘Carthage’ directory with built framework. We need to manually drag and drop this to our XCUIPoMTest’ target build settings. On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk. On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: bin/sh), add the following contents to the script area below the shell:

and add the paths to the frameworks you want to use under “Input Files”, e.g.:

It should like this:

Setting Cucumberish Framework

We can setup Cucumberish as well. Now we need to manually drag and drop frameworks in the build phases  of the Cucumberish target.

  • From the build phases of the cucumberish target select Link Binary with Libraries  and drag Cucumberish.framework from Carthage/Build/iOS  directory. We need to add new ‘Copy Files’ phase and select destination as ‘Frameworks’ and Add Cucumberish Frameworks from directory. Select ‘Create Group’ and ‘Copy if needed’ when prompted. The entire Carthage Setup looks like this


Pre-Defined BDD Steps

XCFit4.0  has pre-defined steps for both XCFit Swift framework as well as Cucumberish framework.

It’s recommended to use your own steps as predefined steps might not read well for your project needs. Pre-defined steps gives you guidance on how to implement your own step, however you can use pre-defined steps wherever they make sense to avoid duplication. The pre-defined steps will be available directly into Xcode once you import XCFit  and extend the test class to XCFit framework.

There are some pre-defined Cucumberish Steps available to use directly without any need to implement in the step definition. You can see list of steps here. You already have those steps in the ‘CommonStepDefinitions.swift’ file. You can modify the steps as per your project need or add your own.

Extending BDD Step from XCFit Framework

XCFit has a step givenILaunchedApplication()  and you are not happy about the wordings. You can easily write and Extension and your steps like this :

Now you can use your own givenMyiOSApplicationHasBeenLaunched()  step anywhere inside the Test target.

Extending/Changing Cucumberish BDD Steps

XCFit template for setting Cucumberish has the Swift code for the all pre-defined Cucumberish BDD Steps inside the ‘CommonStepDefinitions.swift’ file. You just need to add your own steps accordingly or change the exiasting one.

Updated README and Video Demo

XCFit 4.0 has improved documentation on Github README and it’s web page . You can see step by step guide on using XCFit frameworks. There is also video demo o Youtube, you can watch here

Hope you like XCFit 4.0

  • Viktoria

    hey, I’m running the “carthage update –platform iOS” command and getting this kind of error.
    The following build commands failed:
    CompileC /Users/MyName/Library/Developer/Xcode/DerivedData/CucumberishExample-elueayvmvoarxsdhcjkvdafuaknh/Build/Intermediates/CucumberishExample.build/Release-iphoneos/Cucumberish.build/Objects-normal/armv7/Cucumberish.o /Users/MyName/Documents/XCFit4Demo/Carthage/Checkouts/Cucumberish/Cucumberish/Cucumberish.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler

    Could you please help me with it?

    • Hi Viktoria, Thanks for reporting it.

      Can I know which version of Xcode and Swift you are using ? XCFit is built on Swift 3.1-dev. It’s worth checking if it works with Cocoapods. ?

      Please try deleting the derived data and let me know how it goes. If that’s Cucumberish causing issue then I will remove Cucumberish as dependency for XCFit.

      • Viktoria

        I’m using Swift version 3.0.2 and Xcode version 8.2.1.
        What is more, I have already tried deleting derived data, but it didn’t help.

        • Hi @Viktoria, I have updated the framework to support Swift 3.0.2 and Xcode 8.2.1. You can update Cartfile with

          github “Shashikant86/XCFit” “3.0.0”

          And run ‘$ carthage update –platform iOS’ This should work now. Delete you old Carthage/ directory, cart file.resolved and Derived Data. I think this should help. I have updated README file accordingly. Let me know how it goes 🙂 Thanks for pointing this out !

          • Viktoria

            Hi, thanks for the help!
            I have deleted all the things that you’ve mentioned including Derived data, also have updated Cartfile. But during the ‘$ carthage update –platform iOS’ command I’ve got new error:
            “The following build commands failed:
            Ld /Users/MyName/Library/Developer/Xcode/DerivedData/XCFit-eyztddpopzgxzadcbhfhozcwgoey/Build/Intermediates/XCFit.build/Release-iphoneos/XCFit.build/Objects-normal/arm64/XCFit normal arm64
            (1 failure)”

          • That’s annoying.. It works for me with same Xcode and Swift version. Can you please try pulling branch in cartfile?
            github “Shashikant86/XCFit” “Swift3.0.2” and again delete everything derived data, clear simulator content, Carthage/ directory and cart file.resolved..
            I will try to setup TravisCI job with demo project and see what happens 🙂

            I used to get that error as well, it’s related to selecting right architecture and bitcode but I have fixed it ..

          • Viktoria

            yes, finally it works for me with “github “Shashikant86/XCFit” “Swift3.0.2”
            thanks a million for your help!)

          • Glad that it finally worked :).. Just wondering why not worked on “3.0.0” tag. It seems to be working fine on TravisCI Xcode8.2 image. https://travis-ci.org/Shashikant86/XCFitSwift3Demo/builds/201815413. Worth checking Carthage version. I am on latest Carthage

          • Anyway thank you for reporting it. Let me know if you came across any issues regarding XCFit..

          • Viktoria

            Hi again! Faced with one more issue:)
            I was trying to configure XCFit using Cocoapods. during “pod install” command I’ve got the error ” [!] Unable to satisfy the following requirements:
            XCFit (from https://github.com/Shashikant86/XCFit.git, tag 3.0.0) required by Podfile
            Specs satisfying the XCFit (from https://github.com/Shashikant86/XCFit.git, tag 3.0.0) dependency were found, but they required a higher minimum deployment target.”

            Then I’ve changed “platform :ios, ‘8.0’” to the 9.0 version in the Podfile. Then it works fine.
            But the thing is that minimum deploy target version should be 8.0 for our project. Is there are any options to fix this issue?
            (Now I’m talking about Cocoapods configuration (it’s more preferable for us))

          • I am not sure it’s possible as Apple as policy to support latest iiOS version and -1 (9, 10) id you supporting iOS 8 you can only use Xcode 7.x
            How ever you can still use XCFit iOS 9 + …

          • Viktoria

            thanks a lot for the answer!

      • Viktoria

        btw, when I’m trying to launch your example project on my Mac, I’m getting this error for “import XCFit” code line: “module compiled with swift 3.1 cannot be imported in swift 3.0.2”
        Does this mean that XCFit will not be work on Swift version less than 3.1?

        • Yes. Thats true..XCFit has some new classes like XCWaiter for XCTest. It might now compile on previous swift versions. My goal is to use make it available with Swift 3.1 features.. and support version above that .. Please let me know what you trying to use ‘XCFit’ Or ‘Cucumberish’ I will try to make it backward compatible for lower Swift versions.

          • Viktoria

            I’m trying to use XCFit.
            thank you for the assistance!

          • Hi Viktoria, I have updated the framework to support Swift 3.0.2 and Xcode 8.2.1. You can update Cartfile with
            github “Shashikant86/XCFit” “3.0.0”
            And run ‘$ carthage update –platform iOS’ This should work now. Delete you old Carthage/ directory, cart file.resolved and Derived Data. I think this should help. I have updated README file accordingly. Let me know how it goes 🙂 Thanks for pointing this out !