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

后端 未结 30 2477
鱼传尺愫
鱼传尺愫 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 10:55

    Recently ran into this issue with importing CoreNFC on older iphones (e.g. iPhone 6) and Xcode (11.3.1). I was able to get it to work by

    1. In your Projects, select the target.
    2. Goto General tab on top.
    3. Under the 'Frameworks, Libraries and Embedded Content' section, add the framework (for me it was CoreNFC). Repeat for other targets.
    4. Click on Build Phases on top and expand 'Link Binary with Libraries'.
    5. Make the troublesome framework optional (from required).

    This allowed me to compile for older/newer iPhones without making any code changes. I hope this helps other.

    0 讨论(0)
  • 2020-11-22 10:55

    In my case app crash only on real device and it occurred for standard library's. I tryied a lot of steps meintioned before, after 1h i just delete app from real device and install it again.

    0 讨论(0)
  • 2020-11-22 10:56

    In Xcode 11

    I was facing the same issue

    Changing "Do Not Embed" in General Tab > "Frameworks, Libraries, and Embedded Content" was still resulting the same error.

    What did solved for me was adding the Framework in Build Phases Tab > Embed Frameworks section

    --Updated---

    I observed that in projects built in previous versions of Xcode Embed Frameworks Section is not available when running in Xcode 11, Find the below steps to achieve the solution:

    1: First need to add the New Copy Files Phase under Build Phases tab.

    2: Second change the name of the added phase to Embed Frameworks

    3: Change the destination to Frameworks.

    4: Add the framework for which the error occurred.

    0 讨论(0)
  • 2020-11-22 10:57

    Xcode 11

    1. Navigate to settings of your target and select General.
    2. Look for "Frameworks, Libraries, and Embedded Content"
    3. Keep "Do Not Embed" and make sure that all your targets (if you have more than one) have only set it's own framework and not others targets.
    0 讨论(0)
  • 2020-11-22 10:59

    Resolved for me by unselecting "Copy only when installed" on Build Phases->Embed Frameworks

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题