iOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 Beta

后端 未结 30 2855
鱼传尺愫
鱼传尺愫 2020-11-22 10:08

This crash has been a blocking issue I used the following steps to reproduce the issue:

  • Create a Cocoa Touch Framework project
  • Add a swift file and a
30条回答
  •  执念已碎
    2020-11-22 11:01

    Surprisingly, not all of the necessary pieces are documented here, at least for Xcode 8.

    My case was a custom-built framework as part of the same workspace. It turns out it was being built incorrectly. Based on jeremyhu's last response to this thread:

    https://forums.developer.apple.com/thread/4687

    I had to set Dynamic Library Install Name Base (DYLIB_INSTALL_NAME_BASE) under Build Settings of the Framework Project and then rebuild it. It was incorrectly set to $(LOCAL_LIBRARY_DIR) and I had to change it to @rpath.

    So in the link processing stage in the App Project, it was instructing the host App to dynamically load the framework at runtime from /Library/Frameworks/fw.Framework/fw (as in, the root of the runtime filesystem) rather than path-to-App/Frameworks/fw.Framework/fw

    Regarding all the other settings: it does have to be in 3 places in Build Phases, but these are all set at once when you just add it to the Embedded Binaries setting of the General tab of the hosting App.

    I did not have to set up an extra Copy Files phase, which seems intuitively redundant with respect to the embedding stage anyway. By checking the tail end of the build transcript we can assure that that's not necessary.

    PBXCp /Users/xyz/Library/Developer/Xcode/DerivedData/MyApp-cbcnqafhywqkjufwsvbzckecmjjs/Build/Products/Debug-iphoneos/MyFramework.framework
    

    [Many verbose lines removed, but it's clear from the simplified transcript in the Xcode UI.]

    I still have no idea why Xcode set the DYLIB_INSTALL_NAME_BASE value incorrectly on me.

提交回复
热议问题