Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dyld: Library not loaded: @rpath/libswiftCore.dylib problem with new Xcode (10.2)

Tags:

xcode

macos

swift

None of the referenced answers works. Something new has happened with Xcode 10.2

This happens whether or not I use Swift 4.2 or 5.

It happens immediately with a brand new, unedited command-line tool.

All you need to do, is create a MacOS command-line tool, and hit "run."

You immediately get this error.

Nothing I have done so far has fixed it.

like image 545
Chris Marshall Avatar asked Mar 26 '19 12:03

Chris Marshall


3 Answers

From the Swift 5 Release Notes for Xcode 10.2:

Swift 5 Runtime Support for Command Line Tools Package

Starting with Xcode 10.2, Swift command line tools require the Swift libraries in macOS. They’re included by default starting with macOS Mojave 10.14.4. In macOS Mojave 10.14.3 and earlier, there’s an optional package to provide these runtime support libraries for Swift command line tools that you can download from More Downloads for Apple Developers. If you installed the beta version of this package, replace it with the release version. This package is only needed for Swift command line tools, not for apps with graphical user interfaces.

Note that:

  • This is only necessary if you are still on macOS 10.14.3. As soon as macOS is upgraded to 10.14.4, the Swift runtime libraries are provided by the operating system, and command line tools created with Xcode 5 run without the need to install the “Swift 5 Runtime package.”
  • On macOS 10.14.3 with Xcode 10.2 you must download and install the latest “Swift 5 Runtime package.” An earlier package which you might have installed with an Xcode 10.2 beta release does not work.
  • Early versions of the Xcode 10.2 beta release notes recommended to add a user-defined setting SWIFT_FORCE_STATIC_LINK_STDLIB=YES as a workaround, that is no longer necessary.
like image 177
Martin R Avatar answered Oct 20 '22 00:10

Martin R


I updated my macOS as was suggested, but it did not help without the following change in the Package.swift:

- // swift-tools-version:4.2
+ // swift-tools-version:5.0
like image 2
Tim Avatar answered Oct 20 '22 00:10

Tim


This issue happened because I update XCode to 10.2 without updating the MacOS to the latest and the sdk that I used also not updated. Apparently these steps had solved my issues :

  1. Update your MacOS the latestList item
  2. for my case even updating all the required updates not solving the crash issue. In that case don't forget to check if your affected SDK/framework already rebuild from the latest XCode (10.2), since The problem went away after I rebuild the SDK with the latest XCode (10.2).
  3. For my case, we used jenkins to release the app, if the cloud still using old xcode and os, the .ipa will still crash. Need macos and xcode on jenkins cloud to be also updated.
  4. Because updating the cloud will affect everything (near the release date) so either I roll back the os and xcode, or I use the old sdk/framework (before rebuild state). But using the second option will make it crash on simulator but atleast no crash issue if release the app.
like image 3
xeravim Avatar answered Oct 20 '22 00:10

xeravim