Reputation: 3351
I'll preface this by saying that the solution is probably very simple but I've tried for hours to figure this out and I feel like it's close, but something is still wrong.
I'm creating a Cocoapod that has some other pods as dependencies and I'm trying to setup the projects / targets to work but running into the problem where the Cocoapod dependencies that I'm trying to load in PusherSwift.swift
(import Alamofire
etc) are failing.
Here is a link to the repo: https://github.com/hamchapman/pusher-swift-test
Can anyone see why the pod frameworks aren't being loaded so that they can be used in the PusherSwift.swift
file?
Specifically I'm trying to run the (default) tests but it keeps on failing saying:
No such module Alamofire
Note, I'm using the following:
Upvotes: 4
Views: 1797
Reputation: 1719
Do something like this:
target 'Echo' do
pod 'Alamofire'
pod 'AFNetworking'
pod 'Google/Analytics'
pod 'Google/AppInvite'
pod 'Appirater'
pod 'FDTake'
pod 'MBProgressHUD'
pod 'TDBadgedCell'
pod 'FDWaveformView'
pod 'SwiftyJSON'
target 'EchoTests' do
inherit! :search_paths
end
end
This makes it so that the test target has all the pods that the main target has, but you're still able to define some testdependencies like mocking or stubbing pods
Upvotes: 2
Reputation: 39313
This is a stupid answer but it works.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'Echo' do
pod 'Alamofire'
pod 'AFNetworking'
pod 'Google/Analytics'
pod 'Google/AppInvite'
pod 'Appirater'
pod 'FDTake'
pod 'MBProgressHUD'
pod 'TDBadgedCell'
pod 'FDWaveformView'
pod 'SwiftyJSON'
end
target 'EchoTests' do
pod 'Alamofire'
pod 'AFNetworking'
pod 'Google/Analytics'
pod 'Google/AppInvite'
pod 'Appirater'
pod 'FDTake'
pod 'MBProgressHUD'
pod 'TDBadgedCell'
pod 'FDWaveformView'
pod 'SwiftyJSON'
end
I'm sure there's a better way to do this, but I can't find it!
Upvotes: 1
Reputation: 613
By default Cocoapods only links to the first target in your project. The second target, which is usually your unit tests, is not linked. http://guides.cocoapods.org/syntax/podfile.html#link_with
Use the link_with
config in your Podfile to explicitly link pods to your unit tests target. eg
link_with 'MyApp', 'MyAppTests'
Upvotes: 1
Reputation: 3351
Okay well I have made it work now by adding the Pods project inside the PusherSwift project. I'm not entirely sure why that made it work but it basically just seemed to make the frameworks available to the PusherSwift targets.
Upvotes: 1