dyld: Library not loaded: #rpath .. reason: image not found - ios

I am running into the above mentioned error on Xcode 10.2.1 and iOS 11 when adding my custom framework to an existing project.
I tried all the options mentioned in the previous questions asked related to this same error.
Always Embed Swift Binaries is set to yes, cleaned, removed derive data, reinstalled the certs.
Would anyone be able to help with this?

You need to also add your framework as Embedded Binary. Go to your target, select "General" tab and "Embedded Binaries" there.
Most of the times, you are using Apple (iOS) provided frameworks, that come as part of iOS and there is no need to do anything else, but define you're using them. That's the "Linked Framework and Libraries" part. When you use your own framework however, you need to embed it as part of your application and also add it to "Embed Binaries".

Related

How to debug "Invalid Bundle" error which happens only after submitting to app store

I have a lot of frameworks in my app. App works fine in adhoc/enterprise release. Only if I submit to the app store for testflight testing I get this error email from apple:
Dear developer,
We have discovered one or more issues with your recent delivery for "My app's name here". To process your delivery, the following
issues must be corrected:
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
Once these issues have been corrected, you can then redeliver the corrected binary.
Regards,
The App Store team
there is no specific information here. How can I debug it?
Got an answer from Apple Developer Technical Support which says it is a bug on Apple's side. this is the suggested workaround below which did not work for me:
To diagnose this issue, you should export the IPA you are sending to
the App Store from Xcode. Since IPAs are zip files, you can
decompress it by right clicking and saying Open With > Archive
Utility. You should find your main executable inside the unzipped
folder structure and run otool at the command line to see the library
list: otool -L
The list of paths you get should match what you find inside of your
IPA. All of your libraries should start with #rpath. A simple
comparison of everything in this list with the unzipped IPA folders
should reveal what is missing.
Once you know what is missing, go to your Xcode build phases setup.
There should be a build phase for either Copy Files or Embed
Frameworks that includes the missing library — you should just add the
library to the list. If you don’t see either of these build phases,
you can recreate it by adding a new Copy Files build phase, setting
the Destination to Frameworks, and adding the library to the list,
ensuring that Code Sign On Copy is checked.
If you don’t find anything missing in your main binary, make sure to
do the same search on any other binaries you may have, like for a
watchOS app or an iOS app extension.
If you find that all of the frameworks are in this build phase, please
take a look at the Embedded Binaries section of your app target’s
General page, and let me know if you see multiple levels of ../ next
to the binary that you found is missing.
Please let me know if it works for you!
I have encountered the same issue when uploading an app with watch support to the app store.
I was able to solve it with the hint from the first answer, using otool -L to analyze the binary from the ipa or xcarchive.
However, the problem was not with my frameworks (at #rpath) but with a swift lib. I noticed that libswiftWatchKit.dylib was missing in the frameworks folder.
The solution that worked for me was as simple as to set EMBEDDED_CONTENT_CONTAINS_SWIFT=YES in the build settings of the watch app (or the watch app extension, but not both). After that, all necessary swift libraries were correctly copied to the watch app path in the archive and upload to app store was working correctly.
Apparently, the watch app works and upload passes if you provide the necessary swift libraries only in the main app's folder.
After adding the custom Swift framework to my project I got this email after uploading the app to iTunes connect.
I got this email from iTunes store,
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
The fix is simple for this issue,
Step 1: Make sure your Custom framework is added to Embedded Binaries in General tab of your target.
Step 2: Under build settings,
Set Always Embed Swift Standard Libraries = Yes for your main project target.
And Set Always Embed Swift Standard Libraries = No for your custom framework target.
This solved my problem and I was able to upload binary to iTunes connect.
Ref
Tried all the above solutions and did not work for me.
I was experiencing this issue in Xcode 10.1 recently and all my frameworks were referenced correctly (did otool -L and everything lined up).
Seems there were some changes in the apple validation process, may be a bug, may not be on Apple's end, but all my prior builds uploaded and validated fine -- and I did not add any new frameworks since.
Upon uploading the binary to iTunesConnect, I'd see the following error:
Invalid Bundle - One or more dynamic libraries that are referenced by
your app are not present in the dylib search path.
Invalid Bundle - The app uses Swift, but one of the binaries could not
link to it because it wasn't found. Check that the app bundles
correctly embed Swift standard libraries using the "Always Embed Swift
Standard Libraries" build setting, and that each binary which uses
Swift has correct search paths to the embedded Swift standard
libraries using the "Runpath Search Paths" build setting.
MY SOLUTION:
After days of debugging, what worked for me was to disable 'Include bitcode for iOS content' upon uploading the archive from Xcode organizer. Seems that this option modifies the binary which caused the validator to fail.
Or you can disable bitcode in your Build Settings
My Problem:
I had the same error with embedded frameworks.
The App project has Custom Framework project
Inside the Custom Framework project is another Custom Framework project
The app built to the simulator and to devices with no problem but failed the Apple test, returning "Invalid Bundle".
I inspected the package just like Taha had been told to by Tech Support and everything was present and correct!
My Solution:
I restructured the project so that the two custom frameworks sit side by side and one is no longer embedded within the other.
This looks to be an Apple validation problem since everything works fine on devices and the simulator but the work around was straight forward.
In my case, in the build settings, this was fixed when I added the following to the build settings for the library:
DYLIB_INSTALL_NAME_BASE = #rpath
The clue was a linker warning: 'YourLibrary has an install name beginning with “/”, but it is not from the specified SDK'
Had same issue. This happened to me because one of my Framework target was added to main target in "Link Binary With Libraries" but was not added to "Target Dependencies" and "Embedded Binaries"
I also received a similar mail from Apple:
Dear Developer,
We identified one or more issues with a recent delivery for your app,
"********. Please correct the following issues, then
upload again.
ITMS-90562: Invalid Bundle - One or more dynamic libraries that are
referenced by your app are not present in the dylib search path.
Best regards,
The App Store Team
I used my own framework for my watch app. I solved this issue by changing the framework option to "Embed Without Signing" in the Extension Target. The default option was "Do Not Embed".
I had the same problem, it was due to one framework not being present in the Frameworks subfolder in the app bundle.
I fixed it by adding a Copy Fields build phase, and adding the missing .framework file there.
This error message is also addressed in Apple Technical Note TN2435
Embedding Frameworks In An App: https://developer.apple.com/library/archive/technotes/tn2435/_index.html
You can find the error message under the heading "Missing Framework Bundle" with troubleshooting steps.
We had the same problem, and even after going through all the steps (see "Missing Framework Bundle"), the only thing that worked was disabling Bitcode.
So I struggled on this for two days. What it turned out to be was I had UITests checked in Archive for the Build for the Scheme I was archiving.
After unchecking it from Archive, re-archiving it, validating it (although validating it before always passed), and "Upload to AppStore" I did not get the e-mail from Apple informing me of Invalid Swift Support. Instead I got the e-mail that it'd been processed and is good to go!
In my case, I've had to add a framework from Notification App Extension to the main target (embed & sign in the main target, do not embed in the extension) - even though there was no mention about it in otool -L output.
Funny thing that Iterable official doc says that the framework should be embedded & signed in the extension - which would lead to another upload problem because of nested bundles.

Error manually adding framework required by another framework

I'm trying to implement this wonderful framework: https://github.com/Yalantis/Koloda
The framework requires Facebook Pop, I don't like using cocoa pod so I added Pop manually, like this:
And I linked Pop to Koloda, Koloda to main project.
I succeeded running on simulator, but When I ran on iPhone, after the app launches, the compiler says:
dyld: Library not loaded: #rpath/pop.framework/pop
Referenced from:
/private/var/containers/Bundle/Application/9FC4B4D6-35AE-4233-9873-13905A64F725/Memory
Alarm.app/Frameworks/Koloda.framework/Koloda
Reason: image not found
Xcode 7.3.1. Base SDK 9.3 . I was able to compile and run project by manually adding Kolada and Facebook pop. I am not sure if you tried adding Kolada as Embedded project. (Available since ios8). Here are steps I followed:
Right click on my project to add "Kolada".
Right click on Kolada to add Facebook Pop.
2.1. Make sure Facebook Pop is added in General -->Linked Framework and Libraries.
2.2 And in Build Phases --> Add Copy Files Phase. Make destination as Framework and Add pop.framework here.
Add Kolada as Embedded project . Select your project Target . General --> Embedded Binaries.
Following questions might be helpful to you:
Reason: no suitable image found.
dyld: Library not loaded. Reason : no suitable image found
I am attaching screenshots.
Adding Kolada to Project
Once you've added pop to Koloda, you then can add the iOS framework for pop to Koloda, it should appear at the top of the list. Does the Koloda project compile?
Big thanks to #kamal and #JingJingTao for trying so hard to help me with this problem, I solved eventually with Cocoa Pods.
There seems to be some code signing issue with Xcode 7, which is marked out in Xcode 8, unfortunately I wasn't able to use Xcode 8 to build due to the other libraries need upgrade, this problem seem to be very common:
dyld: Library not loaded: #rpath/libswift_stdlib_core.dylib
Eventually, as #JingJingTao suggested, I had to try Cocoa Pods, and it worked, guess for now, it's the only solution.
Last thoughts, Cocoa Pods has an open community, people discuss and fix almost every issue you can encounter, while with Xcode, when you are freaking out with a problem, no one will tap on your shoulder and say: "Hey this is a bug and we will fix it later. " because, they are not open source.

Google Drive GTL framework, dyld: Library not loaded: #loader_path/../Frameworks/GTL.framework/GTL

I have an app called Tripla which can sync data via Google Drive for iOS 8- devices. However, it got crash when synchronizing data on iOS 9 devices. Therefore, I tried to upgrade the Google frameworks by the latest library and follow the tutorial https://developers.google.com/drive/ios/quickstart.
This update, I got the error msg - dyld: Library not loaded: #loader_path/../Frameworks/GTL.framework/GTL ....... image not found when debugging on real devices.
After looking up many similar solutions such as:
Add "GTL.framework" to "Embedded Binary" in tab "General",
Add "GTL.framework" to "Linked Frameworks and Libraries" in tab "General",
Add "GTL.framework" to "Copy Files" in tab "Build Phrase",
Add dynamic path to "Runpath_Search_Path" in tab "Build Settings",
the issue was still not been solved.
Does anyone have the same issue and get solved?
ps. Debugging on simulator is working well when clicking "Run" on Xcode. It, however, gets crash again on OS X 10.11.2 when clicking Icon on main screen in the simulator 9.1.
Change dynamic library to static library
I solved this issue my own. It might be caught by wrong setting in the Google's dynamic linked framework. So that the app cannot run in real devices and find the dynamic library in runtime period. Please follow the tutorial Drive SDK for iOS and do more things.
Make sure your Architecture setting in GTLiOSCore in GTLCore sub-project is correctly for iOS, but OSX for GTLOSXCore instead.
Change "Mach-O Type" to "Static Library" from "Dynamic Library"
After finishing the steps above, your Drive app may be run in your real devices.
select TARGET -> General -> Embedded Binaries
click add button
select GTLCore->Products->GTL.framework iOS
click add button
Done
This work for me. Xcode 7.3 swift2.2

ios - moving frameworks broke the project

I recently added the Social.framework and Accounts.framework to my ios project. It was placed on top of the navigator area and I dragged those two into the frameworks folder. Then it showed in red color in the Build Phases "Link Binary with Libraries" ....and now the project crashes on startup.
What did I do so wrong? And what is the correct way to fix this?
I get this error:
dyld: Library not loaded: /System/Library/Frameworks/Social.framework/Social
Referenced from: /Users/owner12/Library/Application Support/iPhone Simulator/5.1/Applications/823A0485-7443-4206-B9F5-A84C03DBFB89/BusinessPlan.app/BusinessPlan
Reason: image not found
You didn't do anything wrong. Sometimes Xcode gets confused. I would suggest that you edit the project, scroll down to where it lists the frameworks, and select the Social and Accounts frameworks and click the Minus button.
After that, you might want to quit Xcode and clean out the build folder as described here:
How to Empty Caches and Clean All Targets Xcode 4
If that doesn't solve it, you might have to revert to an earlier commit.

Could not instantiate class named MKMapView

I may be doing something really stupid here as I've done it before and it worked and now...
Created a new iPad project, in the details view I added a MKMapView, added the MapKit.framework to the project, added the property / etc. to the header. Go to run the project and get a SIGABRT with
****Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate
class named MKMapView'**
I found http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial/ but, like I said, I've already added framework. What am I missing?
I ran into this too, but I was able to get past it by following the instructions of step 2 in your link (thanks, by the way):
Add the MapKit framework to the project. (Control + Click Frameworks
folder -> Add -> Existing Frameworks)
I just searched for MapKit.framework, added it to the project, and the error went away.
I haven't added any map code yet (although I do have a MapViewDelegate connected in IB), but it's working fine so far!
Click on your project to bring the project settings. Under Targets, click your project, select from the upper toolbar "Build Phases". Under "Link binary With Libraries" tab, you will see the list of frameworks included in your project. Click the "+" button and add MapKit library from the shown list to your project.
For Xcode 6.1:
Select your project
In general tab, look for Linked Frameworks and Libraries (last one)
Press + button
Search MapKit.framework
Finally add
Easy way!
Works above Xcode version 7.2
As far as I'm concerned selecting the MAPS from capabilities will automatically link your framework to your project all you have to do is check the Maps button in Capabilities -> Maps.
Heres the attached screenshot. Cheers!!
For xCode 4.2:
Click on your project name ->targets ->building Phase ->link binary with library
-> click on + sign ->select mapKit.framework ->click add
I noticed that I was getting this message (on top of the original one mentioned in this post) when I was building and running on the simulator:
ld: warning: ignoring file
/Users/peter/programming/iPhone/iNspector/MapKit.framework/MapKit,
file was built for unsupported file format which is not the
architecture being linked (i386)
Then I just connected my iPhone, build and ran on the device, and the map worked.
So it seems that the MapKit framework cannot be compiled on the 386 architecture, it needs the device.
In regards to #futureshocked's input, I also came across the
Id: warning: ignoring file /blah.../MapKit, file was built for unsupported file format which is not the architecture being linked (i386)
issue.
**Check to make sure you didn't copy the MapKit framework into your local project directory when you added it to your project. I accidentally did this and XCode was giving me the above error. So I removed it from my project directory (in Finder), recompiled, and everything was normal again.
If you don't have the Framework in your project, go ahead and re-link as stated in the answer above.
Found a good tutorial on getting started with MapKit:
http://www.youtube.com/watch?v=X-3jM24EIGM&feature=related
I also received this error when trying to deploy to my 5.1 phone (with XC 4.5), even after changing my deployment target to be 5.1. Looks like the maps update wouldn't fly since I still had Google Maps on my phone. After updating my phone's OS, the exception disappeared.
Please import the WebKit at your Build Phases.

Resources