Xcode Unit Testing with Cocoapods

Xcode Unit Testing with Cocoapods

The solution for me was to update cocoapods to version 1.1.0.rc.2.

sudo gem install cocoapods --pre

Why can't Xcode find my App for Unit Tests?

You must use @testable import to import your app's module for unit testing. You have to supply the name of your application target, Pods_MyApplication_Example, not the name of the project. In your example it will look like the following:

@testable import Pods_MyApplication_Example

And remove the import statement that imports the app target.

Unable to use Cocoapod in Unit Tests

As far as I know that warning is not something you did. I think I saw some other people having the same issue and as far as I can tell it's a problem in the latest SDK from Apple. I say you can safely ignore it for now. Here are some people having the same issues:

  • Class PLBuildVersion is implemented in both frameworks
  • Class PLBuildVersion is implemented in both/Applications

Check this answer to get more info.

How to use unit test cases (added to a development pod as test_spec) in the main app target?

Once you have the target you need to edit your scheme to make it run the tests!

Edit scheme

Then set it to be tested (by adding it to the +)

Include tests in the test list

Also it is added automatically to the build

Add test to build

And its done! :D

COCOAPOD file not found for Xcode unit tests only

Add the pods separately for Target and TargetTests

Make the following changes in POD file

target ‘Target’ do
platform :ios, ‘8.0’
use_frameworks!
pod 'PLCrashReporter'
end

target 'TargetTests' do
platform :ios, ‘8.0’
use_frameworks!
pod 'PLCrashReporter'
end

Go to the Build Settings of TargetTests
and set the value for “Other Linker Flags” as $(inherited)

Do a POD install then do Clean Build Folder and run



Related Topics



Leave a reply



Submit