问题
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
回答1:
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.
- Open test Navigator.
- Click the + button in the lower-left corner, then select New Unit Test Target… from the menu:
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.
- for example: $HOME/Developer/GitHubProjectClones
6. cd to sub directory in (5):
- mkdir Vendor
- git init
7. Follow step one
in Git Submodule section
- git submodule add git@github.com:Quick/Quick.git Vendor/Quick
- git submodule add git@github.com:Quick/Nimble.git Vendor/Nimble
- git submodule update --init --recursive
8. Follow step two
in Git Submodule section
.
- Back to Xcode with Workspace open:
- Make sure Project Navigator is selected
- File -> Add files to:
- select the Quick folder created in step 7.
- File -> Add files to:
- select the Nimble folder created in step 7.
- File -> Add files to:
- select your Xcode project in step 1.
- File -> Add files to:
- Make sure Project Navigator is selected
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
回答2:
Integrating Quick & Nimble via cocoapods works for me out of the box with no problems (macOS Sierra, Xcode8.3.2, iOS 10.3 SDK, Swift 3.1, cocoapods 1.2.1).
Be sure to have the latest stable cocoapods version installed (gem update cocoapods
) and to call pod install
and not just pod update
. You can also try to reintegrate your pods from scratch by calling pod deintegrate && pod install
.
Maybe there is an odd build setting or something similar in your project. You could validate this with a virgin test project.
If nothing seems to work, you should upload your project (e.g. to GitHub) so the community will be able to pinpoint the problem.
来源:https://stackoverflow.com/questions/44244912/how-to-reliably-install-and-setup-quick-test-framework-on-xcode-8