My steps were:
1) In Xcode, I create a new command-line OS X Swift app and add their example "class Dog" code, plus "import RealmSwift" at the top.
2) I add a Podfile with two lines, "use_frameworks!" and "pod 'RealmSwift'" and then run pod install.
3) I open the workspace, compile, and run. I get this warning:
Not running swift-stdlib-tool: EMBEDDED_CONTENT_CONTAINS_SWIFT is enabled, but the product type 'Command-line Tool' is not a wrapper type.
And this crash:
dyld: Library not loaded: @rpath/libswiftAppKit.dylib Referenced from: /Users/ys1382/Library/Developer/Xcode/DerivedData/testRealmApp-gxysfwfiirxwddbklmbolznecnld/Build/Products/Debug/RealmSwift.framework/Versions/A/RealmSwift Reason: image not found
So far googling indicates the warning and crash are related. Any suggestions?
I'm using OS X El Capitan, Xcode 7.2.1, Cocoapods 0.39.0
TiM's comment led me to find out that, as of this writing, it's almost impossible to add frameworks to Swift command-line apps. This blog post describes one way. Starting with step 1, it says:
- Create an Objective-C command line tool and change the Search Paths. Not Swift. You can create a Swift framework for the code you’d put in your command line tool, but the tool itself must not compile any Swift code. Doing so will confuse the linker and make it see duplicate declarations of the Swift library (one in the shipped .dylib, another embedded in the command line tool).
This presentation shows a different approach, starting with creating a Cocoa app, and then coercing it into a command-line app, in 31 steps.
It was at that point I thought, "mmmaybe my command line tool could use some nifty graphics after all" and made a Cocoa OSX Swift Realm Cocoapod app instead, which worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With