Search code examples
stripe-paymentsdylibswift-package-managerbuild-settings

Stripe iOS SDK via Swift Package Manager is installing, but crashing because "Library not loaded"


I am using Xcode 12, iOS 14, everything builds correctly, but when I am installed on the device and about to run, I get a message saying "dylib: Library not loaded:"

dyld: Library not loaded: @rpath/Stripe.framework/Stripe
  Referenced from: /private/var/containers/Bundle/Application/31B00354-2E1E-4385-8317-5518588873F7/MyApp.app/MyApp
  Reason: image not found
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib

I've tried copying the framework via a build phase, but I'm unable to copy the Stripe framework this way. In my targets Frameworks, Libraries and Embedded content, Stripe is set to Embed & Sign.

I've deleted derived data, cleaned, killed Xcode, restart computer, tried different iPhone, with different iOS etc. no luck.

Thank you for the help.


Solution

  • I needed to add @executable_path/Frameworks to my RunPath Search Paths in the Build Settings.

    @executable_path - resolves to the absolute path of the executable, eg. /private/var/mobile/Containers/Bundle/Application/0F2C2461-A68B-4ABA-A604-B88E6E9D1BB1/App.app/

    From https://blog.krzyzanowskim.com/

    Knows a lot more about this stuff than I do ^

    The article (if it still links): https://blog.krzyzanowskim.com/2018/12/05/rpath-what/