xcodexctestquick-nimble

How to reliably install and setup Quick test framework on Xcode 8?


Background:
While working on this answer I noticed that it's not so trivial to properly set up Quick test framework on Xcode properly. In my case, it took 3-4 failed attempts to finally have a working version. And still, I'm not sure where my previous attempts were wrong. Or more importantly why the questioner in that thread could have duplicate run each time. Then it also took him several attempts to finally have a working one.

Question:
I am asking if any of you have a reliable way to set up Quick Framework on Xcode using Cocoa pods (or Carthage or Git Submodule), up to running a properly working Quick test case, that you're willing to share.

How I did it before:
Here is how I created my working Quick framework on Xcode:
1. I follow the step in XCTest article in RayWenderlich site to set up XCTest environment.
2. Then I add the Cocoa Pods as per installing Quick
3. Then follow instruction in Setting up your Xcode
4. Then I hacked and improvise all the rest of the way, googling for each issue I encounter after that, try this and that until it works.
(Among those steps include add Quick framework to link binary in build phase of my target)

I'm not proud to share my steps above, but I don't have a better way for now. I hope to find a better way by asking this question. It might be too much to ask.

My Podfile :

target 'PlayQuick' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for PlayQuick

target 'PlayQuickTests' do
    inherit! :search_paths
    # Pods for testing
    pod 'Quick'
    pod 'Nimble' 
end

end

Solution

  • Git submodule way is the most lean and simple way to achieve that.

    Follow the these steps to start from zero:

    1.a. Create Xcode project with Include Unit Tests checked.

    1.b. Alternatively, you could create unit test target on existing project.


    2. Close the Xcode project in (1)

    3. Create new Xcode workspace. File -> New -> Workspace.

    4. Open Terminal / Bash Shell / Cmd.exe

    5. Create a new sub directory for GitHubProjectClones.


    6. cd to sub directory in (5):


    7. Follow step one in Git Submodule section


    8. Follow step two in Git Submodule section.


    9. Follow step three in Git Submodule section to link Quick.framework and Nimble.framework during your test target's Link Binary with Library build phase.

    10. You should be able to follow along the examples in Quick Documentation