Realm Swift OS X Cocoapods application crashes

My steps were:

1) In Xcode, I create a new OS X Swift application for the command line and add their example code for the “Dog class” 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:

Swift-stdlib-tool does not work: EMBEDDED_CONTENT_CONTAINS_SWIFT is enabled, but the product type "Command Line Tool" is not a shell type.

And this crash:

dyld: library not loaded: @ rpath / libswiftAppKit.dylib Link to: Reason: image not found

So far, a Google search indicates that the warning and the failure are related. Do you have some ideas?

I am using OS X El Capitan, Xcode 7.2.1, Cocoapods 0.39.0

+7
source share
1 answer

TiM's comment prompted me to find out that at the time of this writing, it's almost impossible to add frameworks to Swift command-line applications. This blog post describes one way. From step 1, he says:

  • Create an Objective-C command-line tool and change the search paths. Not fast. You can create a Swift environment for the code that you specified in the command line tool, but the tool itself should not compile any Swift code. This will lead to confusion with the linker and make it see duplicate declarations of the Swift library declarations (one of the .dylib sent, the other built-in to the command line tool).

This presentation shows a different approach, starting with creating a Cocoa application and then forcing it into the application from the command line in step 31.

It was at that moment that I thought: “mmmaybe my command line tool could use some great graphics” and instead made the Cocoa OSX Swift Realm Cocoapod application.

+8
source

All Articles