When running a clean, empty, Swift-based "hello world" command-line project in XCode 8.3 beta 2 (8W120l) or AppCode 2016.3.2 and having a minimal Podfile with (seemingly) any Pod, the project builds, but run leads to errors such as (for example)
dyld: Library not loaded: @rpath/Alamofire.framework/Versions/A/Alamofire
Referenced from: /Users/julian/Library/Developer/Xcode/DerivedData/wtf-cyoeewosqluzxmcwypdhyqrdoqlq/Build/Products/Debug/wtf
Reason: image not found
The project makes no direct or indirect reference to code in the Pod (i.e., no import and no invocations.) Running the executable from within either IDE or at the command line leads to the same error.
The program to print "hello world"
Program ended with error 9
CocoaPods : 1.2.0
Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
RubyGems : 2.0.14.1
Host : Mac OS X 10.12.4 (16E144f)
Xcode : 8.2.1 (8C1002)
Git : git version 2.11.1
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 0e21f945f392282fa53bdc92bcecc7f9bbeca830
Executable Path: /usr/local/bin/pod
cocoapods-deintegrate : 1.0.1
cocoapods-playgrounds : 1.2.2
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk :
The target you are integrating with is a command line tool. Does it allow to "embed" frameworks? If not you will have to manually embed it somehow. I created an OSX app and successfully ran it with the same pod integrated.
@bleeckerj check this out too http://stackoverflow.com/questions/630911/using-frameworks-in-a-command-line-tool
@dnkoutso By "emded" do you mean Link Binary With Libraries in Build Phases? I can try this again. If you have a bare Command-Line project that you were successfully able to include a framework via Cocoapods, I'd be interested to see it. Otherwise, I'd also like to confirm what you mean by "embed". Thanks!
I did not get a command line project to include a framework. My advice is to try it manually first without cocoapods, see what it entails and if its easy enough then perhaps we can automate with cocoapods.
With embed I mean that basically the app or bundle includes the framework within it upon which it can be found at runtime. Looks like this does not happen with command line apps? Again, I have little experience with building command line tool from Xcode in general.
AFAIK there's no good way to package a dynamic framework with a CLI tool, which is why static linking is preferred in this scenario.
Thanks @benasher44 @dnkoutso — my misunderstanding, which was clarified by the link on Stack Overflow. I get what the situation is now, re: dynamic vs. static linking for CLI. I just assumed it would work, but once you pointed me under the hood, I realized it wouldn't just bolt on as a dyld.
@bleeckerj no problem! I think we could provide a nice error message here to let people know that use_frameworks!/Swift won't work with CLI projects. Going to tag this as an easy enhancement.
@bleeckerj also, it appears your sample project link no longer works. If you could post an updated link, that'd be helpful!
@benasher44 Huh. That's weird. I just tried it now and it's there. It's at: https://db.tt/QLAD8bWLgS Can you check again? It's a .tgz to download.
@benasher44 Please add that error message. Just spend 4h trying to figure out what cause it :/
Most helpful comment
@benasher44 Please add that error message. Just spend 4h trying to figure out what cause it :/