Reason: no suitable image found [closed]
Asked Answered
N

31

136
dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /var/mobile/Containers/Bundle/Application/3FC2DC5C-A908-42C4-8508-1320E01E0D5B/Stylist.app/Stylist
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/3FC2DC5C-A908-42C4-8508-1320E01E0D5B/testapp.app/Frameworks/libswiftCore.dylib: mmap() errno=1 validating first page of '/private/var/mobile/Containers/Bundle/Application/3FC2DC5C-A908-42C4-8508-1320E01E0D5B/testapp.app/Frameworks/libswiftCore.dylib'
(lldb) 

I am getting this error when building on my iPhone. I am able to build on the simulator. I have redone all my provision files however I still can't build on my iPhone. My Xcode is like this

enter image description here

Is this a framework problem or a signing issue? This did not happen in Xcode 6. Thank you.

Narcotize answered 23/9, 2015 at 3:7 Comment(3)
Possible duplicate of dyld: Library not loaded: @rpath/libswiftCore.dylibMonosepalous
I solved this issue ( after finding loads of dead-ends on SO) by changing the permissions on the World wide developer cert - see my answer here: https://mcmap.net/q/16086/-dyld-library-not-loaded-rpath-libswiftcore-dylib ( hopefully this helps!)Monosepalous
Update for iOS 13.3.1: if you have this unlucky iOS and try to install app with nested frameworks, just know it's a bug - update to 13.4.1 or later, it's solved yetKippar
Y
392

I have this problem before for accidentally revoked my certificate. Then all my swift projects have this problem. There are two ways to solve this:

Click on Product → Clean (or CMD + Shift + K)

Or by manually cleaning the Xcode setting files:

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode
Youngster answered 23/9, 2015 at 3:17 Comment(9)
use them in terminalYoungster
This worked for me as well, after I had the same problem and tried many things.Crux
I think Alt + Clean will do it as wellEngagement
I have the same problem, but it only show when it is uploaded on server. It works well when I run it from xcode. can u help my problem ?Keniakenilworth
This solved the problem! After hours of reading Stack, reissuing certificates, restarting, deleting, reinstalling.. no results. And "Product -> Clean" did it in second.Lippi
For what it's worth, I hit a similar error in XCode 9.0.1. I tried uninstalling and reinstalling all my certs, but when I reinstalled, they seemed to remember the trust setting I had previously. What ended up working for me (it seems) was turning off the 'Always Trust' setting of the "Apple Worldwide Developer Relations Certification Authority" cert followed by a reboot. What a cryptic issue!Abwatt
why did this error came in the first place??Maghutte
Didn't help anything? Swift 4 - Swift 5. Try to use another device with lower firmware iOS 13 and below or simulator. In my case - newest software couldn't work with previous version of Xcode.Brunhilde
Are you using a non-developer Apple ID to install the app to your phone? It looks like iOS 13.3.1 has broken apps installed with free Apple IDs, but only if they contain embedded frameworks. If it's possible to link all your dependencies as static libraries rather than frameworks (for example, if you're using Cocoapods you can remove use_frameworks! from your Podfile), that should fix the issue for now.Buttons
R
31

I searched long on this issue. There are several reasons causes this issue.

If you are facing when you and Swift code/library in an Objectice C project you should try Solution 1-2-3

If you are facing this issue with a new a Swift project Solution 4 will fit you best.

Solution 1:

Restart Xcode, then computer and iPhone

Solution 2:

Go to project build settings and set Embedded Content Contains Swift Code flag to YES

Solution 3:

Go to project build settings and add @executable_path/Frameworks to Runpath Search Paths option

Solution 4:

If none of above works, this should. Apple seems to be ninja patched certificates as mentioned in AirSign's post

At InHouse certificates

Subject: UID=269J2W3P2L, CN=iPhone Distribution: Company Name, O=Company Name, C=FR

they added a new field named OU

Subject: UID=269J2W3P2L, CN=iPhone Distribution: Company Name, OU=269J2W3P2L, O=Company Name, C=FR

so you should just recreate certificate and provision

Roshan answered 23/9, 2015 at 3:13 Comment(7)
Thank you I have done Solution 1~3 and doesn't work.I have recreated a certificate and provision and it does not work as wellNarcotize
I was facing the same error message as asked originally by Satsuki . Solution 4 did the trick for me. I had problems with Realm Framework but only if I tried to create an archive of my application and then install it through iTunes (otherwise the direct deployment to the device was fluent).Mercator
4 did it for me as well! Here is a link to the AirSign post: airsignapp.com/…Lamb
How do I edit the InHouse certificate?Eel
1 and 2 did not work for me. Window -> project, delete derived data fixed it. Inferior, buggy xcode >.<Paige
The most useful answer. Thanks.Hulton
I'm running on simulator. There isn't any certifcates or provision profiles being used but still this error.Kayak
D
27
Xcode->Product->Clean + Xcode Restart

After attempting many of the other mentioned solutions, to my eternal embarrassment, doing an Xcode->Product->Clean and restarting Xcode, did the trick.

Dissonant answered 27/1, 2016 at 2:4 Comment(2)
I too did many of the previously mentioned steps like getting the WWRD, Checking the Runpath, etc....Nothing worked until I did this "Clean". So a BIG Thank You!Housen
I had to restart Xcode, after several cleans failed. This would seem too obvious of a solution considering how difficult Apple seems to make everything elseSailmaker
G
19

For me this issue was appearing due to the WWRD cert -- Mine was up to date but for some reason it was set to 'always trust' instead of 'use system default', which apparently makes a difference.

Geothermal answered 24/3, 2016 at 23:33 Comment(7)
+1 for the cert problem. I tried absolutely EVERYTHING, but then noticed my developer certificate was set to "Always Trust" in the keychain. Changing to "Use System Default" as you say worked perfectly. Thank you!Truda
Tried everything and this did it. Seriously Why can't apple fix this as part of Xcode....Monosepalous
extremely IMPORTANT: after changing the certificate access to "use system defaults" deep CLEAN the project (cmd+Alt+shift+K)Sennit
Saved my day bro! thanksLaurence
I think this is the ULTIMATE solution to this problem. I also tried almost all the solutions available over the internet but non of them work for me except this. Great solution...Sheikh
My developer cert in keychain was set to 'Always Trust' for some reason. It was building and creating IPA and it was crashing on launch. Changing to 'Use System Deafults' changed the game for me. Now, its working fine.Haircloth
Thank you so much its helped me a lot.Marcellusmarcelo
C
17

If you accidentally reset your keychain, this can occur due to missing Apple certificates in the keychain. I followed the answer on this to solve my problem.

I had the same issue and was able to fix by re-downloading the WWDR (Apple Worldwide Developer Relations Certification Authority). Download from here: http://developer.apple.com/certificationauthority/AppleWWDRCA.cer

Carlyn answered 22/10, 2015 at 3:14 Comment(4)
fixed it for me after transferring Xcode and my user profile from one Mac to another.Mammillate
Works for my case, thanks!Stuffing
THANK YOU SIR, YOU ARE A LIFESAVERParsley
Thank you, took me so long to find this.Sweatshop
E
15

Removing the DerivedData did the trick for me.

Did it through Xcode -> Preferences -> Locations -> clicked the arrow behind the DerivedData path and removed the whole DerivedData folder in the Finder.

Erhart answered 20/10, 2015 at 12:21 Comment(3)
thanks, worked for me, cordova + xcode 7.2Principle
Window > Projects > My Project > Derived Data > Delete did the job for me.Orangeade
Worked for me on Xcode 10.1. All worked as well but in one happy day Xcode began to show those errors. Thanks.Huneycutt
T
5

It occurred on my side when building an app in the command line via xcodebuild and xcrun PackageApplication, signing the app with an enterprise profile. On our CI build servers, the certificate was set to "Always Trust" in the keychain (select certificate -> Get Info -> Trust -> "Use System Default" can be changed to "Always Trust"). I had to set it back to "Use System Default" in order to make this work. Initially we set this to "Always Trust" to work-around the keychain dialogs that appear after software updates and certificate updates.

Transformation answered 28/3, 2016 at 6:20 Comment(0)
B
5

At the risk of sowing more confusion, I had this issue when updating to XC8.

None of these suggestions, nor from any other thread, solved it. What DID work, was removing EVERYTHING from the "Link Binary with Libraries" build phase, the "Target Dependencies" build phase, and the "Linked Frameworks and Libraries" General setting.

FYI, I'm using Carthage and had added $(PROJECT_DIR)/Carthage/Build/tvOS to the FRAMEWORK_SEARCH_PATHS build setting, so that my frameworks could be found.

FYI 2, this projects and the frameworks, are 100% swift and the frameworks are building DEFINES_MODULE = YES.

Bissextile answered 10/8, 2016 at 22:6 Comment(1)
DEFINES_MODULE = YES worked for me. My project contained both objective-C and Swift.Haddington
S
4
  1. Remove the app from device
  2. Clean the project (CMD + SHift + K)
  3. Build/Run on device
Subtle answered 20/7, 2016 at 5:54 Comment(0)
F
3

Cited from Technical Q&A QA1886:

Swift app crashes when trying to reference Swift library libswiftCore.dylib.

Q: What can I do about the libswiftCore.dylib loading error in my device's console that happens when I try to run my Swift language app?

A: To correct this problem, you will need to sign your app using code signing certificates with the Subject Organizational Unit (OU) set to your Team ID. All Enterprise and standard iOS developer certificates that are created after iOS 8 was released have the new Team ID field in the proper place to allow Swift language apps to run.

Usually this error appears in the device's console log with a message similar to one of the following: [....] [deny-mmap] mapped file has no team identifier and is not a platform binary: /private/var/mobile/Containers/Bundle/Application/5D8FB2F7-1083-4564-94B2-0CB7DC75C9D1/YourAppNameHere.app/Frameworks/libswiftCore.dylib

Dyld Error Message:
  Library not loaded: @rpath/libswiftCore.dylib

Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000120021088
Triggered by Thread: 0

Referenced from: /private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/TestApp
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x1001D8000, size=0x00194000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/Frameworks/libswiftCore.dylib
Dyld Version: 353.5

The new certificates are needed when building an archive and packaging your app. Even if you have one of the new certificates, just resigning an existing swift app archive won’t work. If it was built with a pre-iOS 8 certificate, you will need to build another archive.

Important: Please use caution if you need to revoke and setup up a new Enterprise Distribution certificate. If you are an in-house Enterprise developer you will need to be careful that you do not revoke a distribution certificate that was used to sign an app any one of your Enterprise employees is still using as any apps that were signed with that enterprise distribution certificate will stop working immediately. The above only applies to Enterprise Distribution certificates. Development certs are safe to revoke for enterprise/standard iOS developers.

As the AirSign guys state the problem roots from the missing OU attribute in the subject field of the In-House certificate.

Subject: UID=269J2W3P2L, CN=iPhone Distribution: Company Name, OU=269J2W3P2L, O=Company Name, C=FR

I have an enterprise development certificate, creating a new one solved the issue.

Funest answered 17/12, 2015 at 9:38 Comment(1)
can anyone explain this in english?Monosepalous
P
3

You may still get this issue after tried @Jieyi Hu Answer. may it's seems fixed but if it's comes again (possibly on xCode 9).

However, this workaround seems to work (applies to Cocoapods 1.5.x):

  1. clean your project
  2. close Xcode and delete DerivedData
  3. open Podfile in your project , and add this:

    post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings.delete('CODE_SIGNING_ALLOWED') config.build_settings.delete('CODE_SIGNING_REQUIRED') end end

  4. pod update

Sources:

https://github.com/evgenyneu/Cosmos/issues/105

https://github.com/Skyscanner/SkyFloatingLabelTextField/issues/201#issuecomment-381915911

Thank you @Cédric

Palpate answered 17/5, 2018 at 7:59 Comment(0)
T
2

I too had this issue, however nothing I tried above and in several other posts worked.. except for this.

For me, I changed the bundle identifier since we have a different bundle ID for distribution versus development.

My hardware is allowed on this provision and my team account is valid but it was throwing the above error on some other framework.

Turns out that I needed to completely remove the old version of the app completely from my phone. And not just deleting it the standard way.

Solution :

  1. Make sure the target phone is connected
  2. from within xcode menu click [Window>Devices]
  3. select the target device on the left side menu.
  4. On the right will be a list of applications within your device. Find the application that your trying to test and remove it.

Evidently on installing the same app under the same team under a different bundle ID, if your not starting completely from scratch, there are some references to frameworks that get muddied.

Hope this helps someone.

Tyrelltyrian answered 11/12, 2015 at 22:34 Comment(1)
My bundle ID hasn't changed. And any of the above suggestions didn't fix things (-> Clean; manual delete; restart everything; and manually removing the app from the iPhone every time; and more). Just following Christopher's suggestions fixed thinks instantly without cleaning anything again. [iPhone 5; iOS 9.3.5; Xcode 7.3]Overplus
P
2

I just cleaned the project and Clean Build Folder by alt Product menu

Periodicity answered 20/5, 2016 at 14:58 Comment(1)
Shortcut for cleaning build folder: alt+cmd+shift+kOttavia
W
2

Below steps worked out successfully.

1) In the dynamic library install name had to be "@loader_path"

2) In main project the Runpath Search Path has to be "@loader_path" and "@loader_path/Frameworks"

3) From keychain used view-->show expired certificates and removed everything.

4) Deleted the Distribution certificate and reinstalled.

5) Downloaded developer.apple.com/certificationauthority/AppleWWDRCA.cer and installed.

Wildeyed answered 30/5, 2016 at 16:49 Comment(0)
D
2

I recently faced this problem. I tried all possible solutions but nothing worked. At the end I just quit the Xcode , removed the certificates in keychain and installed everything fresh and restarted mac. Fortunately it worked like charm :)

Drowse answered 25/8, 2016 at 6:32 Comment(0)
B
2

I had the same issue and was able to fix by re-downloading the WWDR (Apple Worldwide Developer Relations Certification Authority). Download from here:

and set to Always Trust in the keychain. Changing to Use System Default

it work for me,I hope this help you

Biggerstaff answered 1/9, 2016 at 3:27 Comment(0)
E
1

you probably don't have the correct arch in that lib, you can do a

file /private/var/mobile/Containers/Bundle/Application/3FC2DC5C-A908-42C4-8508-1320E01E0D5B/testapp.app/Frameworks/libswiftCore.dylib

and it should show you the arch's that are in that library... I am not sure how you are linking, but it probably isn't the right way (if libswiftcore is a factory library, if it is some add on library then it probably isn't compiled correctly)

Edlun answered 23/9, 2015 at 3:11 Comment(2)
Hello, Thank you for your answer, I have a question. In the answer you said and it should show you the arch's that are in that library. how do you show it.Narcotize
the command is called file... but I guess you need to find the local version on your mac, rather than the path on the phone...Edlun
C
1

In my case ,the keychain is showing the certificate as untrusted ,to solve this problem I have set the trust options of certificate as "Always trust". Setting the certificate to "Always trust" was the main cause of the crash. I was not able to install the application into device. Solved this by setting trust option to "System defaults" instead of "Always trust" .It worked for me.

Carlotacarlotta answered 2/9, 2016 at 7:15 Comment(0)
C
1

You see the same symptoms if you are working in Xamarin Studio and you are referencing a portable library for which you need to do the PCL bait and switch trick for. This occurs if the referencing project is out of date with respect to the referenced library. I found that I had updated my common library to a newer framework, updated my packages but hadn't updated my iOS packages to match. Updating the packages solved this error for me.

Clough answered 21/11, 2016 at 8:53 Comment(0)
V
0

You can regenerate your certificate and restart your iPhone.

This work for me, I hope this help you.

Vagus answered 13/6, 2016 at 11:41 Comment(1)
Please explain how you did that.Moron
P
0

I solve the problem by check my local keychains.Keep login.keychain has the right certificate

Puzzler answered 29/7, 2016 at 6:24 Comment(1)
Welcome to Stack Overflow! This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you earn sufficient reputation you will be able to comment on any post. If you have a related but different question, ask a new question referencing this one if it will help provide context.Camilacamile
L
0

You need to set certificate (just certificate & not provisioning profile) for each and every dynamic framework you are linking(directly or indirectly) in your projectenter image description here

Lissner answered 24/11, 2016 at 7:34 Comment(0)
A
0

In my case, after I delete all certification created by Xcode and downloaded. Let xcode 8.1 manage certification of app, It works well!!! Hope this can help someone.

Arlie answered 2/12, 2016 at 7:39 Comment(0)
C
0

I have encountered this issue ONLY on the simulator. It seems to be related to some invalid Entitlements in our application, but the issue doesn't appear when we run on a device.

Closeknit answered 15/12, 2016 at 16:44 Comment(0)
F
0

I solved using these tricks.

Step 1:

Go to project build settings and add @executable_path/Frameworks to Runpath Search Paths option

Step 2:

Go to target build settings and add @executable_path/Frameworks to Runpath Search Paths option and Framework Search Paths.

enter image description here

Step 3:

Re-downloading the WWDR (Apple Worldwide Developer Relations Certification Authority), set to Use System Default as option.

Step 4:

Delete All derived Data using Terminal

rm -rf ~/Library/Developer/Xcode/DerivedData/*

Step 5:

Delete All Certificates and reinstalled it to Keychain. I enabled the Use System Default option.

Step 6:

Restart Xcode.

Funest answered 19/9, 2017 at 11:31 Comment(0)
L
0

faced same issue

  1. my developer certificate was expired so created new developer certificate and download
  2. clean and restart xcode this works for me
Losing answered 17/10, 2017 at 9:19 Comment(0)
S
0

I ran into this issue with XCode 9. Nothing of the above worked out. This did the trick for me:

Project > Build Settings > Swift Compiler - Search Path: Setting "Import Paths" to $(PROJECT_DIR) (recursive)

Sync answered 27/10, 2017 at 8:5 Comment(0)
B
0

This resolved my error-

Re-downloading the WWDR (Apple Worldwide Developer Relations Certification Authority), set to Use System Default as option.

Both answered 1/11, 2017 at 17:27 Comment(0)
G
0

In my case, it was an issue with one of the pods I was using. I ended up removing that pod and placing the code from it into my project manually.

Gribble answered 29/11, 2017 at 6:24 Comment(0)
A
0

For what it's worth, I hit a similar error in XCode 9.0.1. I tried uninstalling and reinstalling all my certs, but when I reinstalled, they seemed to remember the trust setting I had previously. What ended up working for me (it seems) was turning off the 'Always Trust' setting of the "Apple Worldwide Developer Relations Certification Authority" cert followed by a reboot. What a cryptic issue!

Abwatt answered 6/7, 2018 at 19:40 Comment(0)
T
-1

enter image description here

I have a similar issue, which detail information as the first image.

My solution is that switch the certification always trust to use system defaults. just like: enter image description here

enter image description here

Turbary answered 24/1, 2018 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.