El Tomato
El Tomato

Reputation: 6707

Xcode Issue: Library not loaded: @rpath/libswiftAppKit.dylib

I've finished working on a Cocoa (not iOS) application with Swift 3. I've tested it on a desktop computer. It works fine. I've tested it on another desktop computer. It works fine. I have even managed to send it over to iTunes Connect. But I have not submitted it because the same application fails to run on a MacBook Pro (2013). Anyway, I've tested it on a MacBook Pro with a retina display. That's when the entire problem started happening. Actually, this desktop application ran on the same MacBook Pro a few days ago. I think it was not sandboxed yet. Now, every time I send a binary copy that runs on different iMac models to MacBook Pro through AirDrop and try to run the application, I get an error that says EXC_CRASH (Code Signature Invalid). So I've deleted some files inside Developer /Xcode / DerviedData. Now, I cannot even debug the application. When I debug it, it hangs up with a fatal error message, which I have never seen before.

enter image description here

Now, if I double-click on an application that Xcode has generated, I get a crash report that says Library not loaded: @rpath/libswiftAppKit.dylib. I thought that I might have deleted some system files by accident. But if I debug existing macOS and iOS apps, I have no problem running them. Fortunately, the entire problem occurs on this particular Xcode project.

One topic that I've found here suggest that we set the Always Embed Swift Standard Libraries option to Yes. I've done that with no vail. I have also read a suggestion that says something about setting the When using this certification option on a developer certificate to Use System Defaults, which doesn't help. Another suggestion that I've tried is clearning cache (Command + Shift + Option + K).

If you have any suggestions, please let me know. Thanks.

More information

I have also seen a bizarre alert message repeatedly on MacBook Pro that says "%@" cannot be found. This error message poped up when I double-clicked on the application icon. It may refer to

String(format: NSLocalizedString("whatever", comment: ""), variable name)

Upvotes: 3

Views: 3524

Answers (1)

Joshua
Joshua

Reputation: 71

I have solved the problem! I had the same problem with you. But from the answer in https://www.reddit.com/r/swift/comments/4nac9s/using_swift_frameworks_with_command_line/, I have known that the key is the rpath.

So I try to add this path to the project in the following two settings:

${DT_TOOLCHAIN_DIR}/usr/lib/swift/macosx/
  1. Runpath Search Paths
  2. Library Search Paths

I don't know why need to add both the two settings, but it works!

Upvotes: 7

Related Questions