Search code examples
iosxcodereact-nativeopenssl

DYLD error: Library not loaded: @rpath/OpenSSL.framework/OpenSSL


I have a react-native app that consumes OpenSSL-Universal as dependency.

OpenSSL is being called from CPP Code which is bridged via an react-native swift library. In the Simulator the whole code runs fine. But when I build the App for production, Archive it in X-Code and install it on a real i-Phone, I get following error:

DYLD error: Library not loaded: @rpath/OpenSSL.framework/OpenSSL

I have added the OpenSSL.framework to Targets -> Build Phases -> Link Binary with Libraries and to

General -> Frameworks, Libraries, and Embedded Content

What am I missing here? Its really confusing to me that it runs fine on the Simulator, but not on a real device


Solution

  • It is due to not OpenSSL library integrated properly

    Solution 1:

    • Project settings

    • Select Target

    • Select the General tab

    • Under Frameworks, Libraries and Embedded Content, click on the plus button.

    • Find the OpenSSL.xcframework from the list and hit Add.

    • select Embed and sign from OpenSSL.xcframework

    • run xcode build again

    Solution 2:

    1. add this line into Podfile
    pod 'OpenSSL-Universal', :modular_headers => true, :configurations => ['Release']
    
    1. just run pod install in the ios root directory
    2. run the build

    Solution 3:

    For whatever reason in Project settings > Select Target > Build Settings > Framework Search Paths this:

    Screenshot 2023-04-07 at 9 45 48 PM

    but the Release ones were missing a bunch of those so I added these 2:

    "${PODS_ROOT}/OpenSSL-Universal/Frameworks"
    "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal"
    

    Then both debug and release builds worked for me. 👍🏼