Can I use CocoaPods when creating a Cocoa Touch Framework?

Viewed 15693

I'm creating a new Cocoa Touch Framework (MyFramework.framework), which will have a dependency on Alamofire. This framework will be written in Swift. As a test I started a new Cocoa Touch Framework project:

File > New > Project > Framework & Library > Cocoa Touch Framework

Then, in the terminal I performed:

pod init

under this projects directory. In the newly created Podfile I added the following:

source 'https://github.com/CocoaPods/Specs.git'
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!

pod 'Alamofire', '~> 3.0'

Once again, in the Terminal I performed:

pod install

and started coding away.

Everything seemed well and good till I used the MyFramework.framework Product in a Single View Project. When I attempt to run the project I get the following issue:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
Referenced from: /Users/me/Library/Developer/CoreSimulator/Devices/87DA70B6-49BF-441E-BD81-F4A80B0792CF/data/Containers/Bundle/Application/2E414EA8-7E54-4D71-9295-566D4FAAADE2/test.app/Frameworks/MyFramework.framework/MyFramework
Reason: image not found

I thought that Cocoa Touch Framework projects were inherently Dynamic, and therefore would include all dependencies.

Can anyone tell me why this is happening and how I may be able to fix it? Is this an issue with CocoaPods or am I missing something?

I'm a noob to Stack Overflow so please let me know if you need more information from me.

Thanks!

2 Answers

Try adding the dependency on Alamofire in the framework's podspec as below

Pod::Spec.new do |s|

# Other setup 

# Dependencies
s.dependency "Alamofire"
# Other dependencies if any
Related