saagarjha / unxip

A fast Xcode unarchiver
GNU Lesser General Public License v3.0
867 stars 39 forks source link

MacOS 11.6.6: dyld: Library not loaded: /usr/lib/swift/libswift_Concurrency.dylib #20

Open NorseGaud opened 2 years ago

NorseGaud commented 2 years ago
+ unxip Xcode_13.2.1.xip
dyld: Library not loaded: /usr/lib/swift/libswift_Concurrency.dylib
  Referenced from: /usr/local/bin/unxip
  Reason: image not found
saagarjha commented 2 years ago

Using unxip on macOS Big Sur is a bit complicated because it requires the use of the Swift Concurrency backcompat libraries, which are typically meant to be shipped alongside an app. One way you can make this work is copy the code into an app target, which will set up the run paths correctly and you can just invoke it from the command line. I feel like you can also probably use something like LD_LIBRARY_PATH too but I haven't explored it much.

NorseGaud commented 2 years ago

Since I build an Anka macOS VM for each macOS version that's in the public Apple mirrors and >= Mojave, it would be extremely valuable to have unxip supported on those versions. Right now I'm doing unxip {XIPFILE} || xip --expand {XIPFILE} for full support.

saagarjha commented 2 years ago

That sounds like a reasonable workaround for now. I'm going to try to get some insight into how to distribute the backdeployment library on macOS 11, but until then that works I guess. Especially since I have no plans of supporting anything below that due to the use of Swift Concurrency.

philipsdean commented 1 year ago

I managed to make building the command line tool with the backdeployment library work on macOS 11.7 without building a full .app bundle. Plus how it can be done should enable making a .pkg release for Big Sur do-able. Here's what you can do...

  1. Pull the code into a command line tool Xcode project to start.

  2. In order to link the runpath you need to copy and edit the libswift_concurrency.tbd file that normally gets added to the project when you try to link the concurrency dylib in the 'Link Binary With Libraries' build phase. You can find the file here: Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/swift/libswift_Concurrency.tbd.

  3. Place a duplicate copy of it into the project as a framework. Edit line 18 (install-name line) in your copied libswift_concurrency.tbd to be: install-name: '<path>/libswift_Concurrency.dylib'. Where <path> will be the path you are going to place the libswift_Concurrency.dylib file to be found at.

  4. Next you want to get the dylib file that gets bundled in an App for back deployment here (swap out swift version for yours in the file path): Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libswift_Concurrency.dylib

  5. Place libswift_Concurrency.dylib at the path you said it would be. Then build!

It also looks like this can be used to support back to Catalina as well

saagarjha commented 1 year ago

Yeah, you don't actually need to make an app bundle, just provide the Swift Concurrency libraries somehow. An app just provides a convenient bundle to keep everything together.