dyld: Library not loaded: #rpath/libswiftCore.dylib / Image not found - ios

I am running my app from xcode to my iOS device and I get this and black screen on iOS device.
Console text:
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/10DB2FE8-EF09-4857-B4AC-0DB2E4419D6F/App-Name.app/App-Name
Reason: image not found
(lldb)

Try adding the following line to Runpath Search Paths of your target.
#executable_path/Frameworks
your_target -> Build Settings -> Linking -> Runpath Search Paths

I had this same issue. I ended up adding the framework in the following locations:
General > Embedded Binaries
General > Linked Frameworks and Libraries
Build Phases > Link Binaries with Libraries
The embedded binaries seemed to be the key for me.

For me helps adding #executable_path/Frameworks to the project Runpath Search Paths, not target.
your_project -> Build Settings -> Linking -> Runpath Search Paths

None of the other solutions helped me, but everything was fixed by deleting Xcode's Derived Data directory.

Oh yes. I've faced with that problem spending hours on solution.
You may try to set "Always Embed Swift Standard Libraries" to "Yes" under your Build Settings > Build Options
(don't forget to shift+cmd+K your project after)

I had to switch 'Embedded Content Contains Swift Code' to 'Yes' to get my Obj-C app to work after updating the Obj-C embedded framework with a Swift object.

In the Framework Target (not the app target), go to Build Settings > Build Options > Always Embed Standard Swift Libraries to YES.
This solved the issue for me!

I had this error in a command line project (Xcode 10.2 and macOS 10.14.3)
The solution was to update to macOS 10.14.4
Swift command line projects won’t run on macOS 10.14.3 and earlier unless you install the Swift 5 Runtime Support for Command Line Tools package. Without that package, Swift command line projects crash on launch with “dyld: Library not loaded” errors. (46824656)
From Swift 5 Release Notes for Xcode 10.2

In my case, This issue is coming in Objective-c project in which I am using a Swift framework (AirWatch SDK).
Solutions:
I have resolved this issue with Xcode 9.3 and 11.0.1 iOS as mentioned bellow steps :
Drag and drop your swift framework in your project and move in default Framework folder of your project.
Then add them as Embedded binaries as shown in screenshot.
Change your framework status from Required to Optional as shown in screenshot. (Build Phases > Link Binary with Library)
Set Always Embed Swift Standard Libraries to Yes in your build settings.
Set Subpath and select destination as Framework for your added framework in Build Phases> Embed frameworks
as shown in screenshot.
Hope it will help someone.

I have faced the same issue, setting the right code sign identity solved the problem(Build settings->Code Signing Identity).
As per Apple technical questions "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"

I fixed by deleting all from Xcode Derived Data directory:
~/Library/Developer/Xcode/DerivedData
Good luck all!

This error message can also occur when using a framework build in a different Swift version then the one currently being used, e.g. if you upgrade Xcode.

I had the same error message, that is how I solved it :
The issue came from the certificates generated automatically by Xcode. I had to revoke these certificates dans generate them back from developer.apple.com
The solution is then :
- Go to developer.apple.com / certificates --> Revoke certificates
OR go in Xcode > preferences > accounts > View details > select Sigining identities > clic setting whell > revoke
- Got to developper.apple.com and follow instructions to generate new certificates
- In Xcode in my project : go to Code Signing Identity and sign both Debug lines with the generated certificate
- Both release lines are set to "iOS Developer"
- Then project > clean
- Build and run on device

#Saikiran's answered worked.
My certificates were generated before iOS 8 was released. I revoked all my certificates and regenerated all provisioning profiles and it solved my problems immediately.
I don't have enough reputation to vote up #Saikiran's answer, but that definitely helped solving the problem.

For me has worked set the option
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
to YES in Project -> Build Settings -> Build Options
(Namirial framework through Cocoapods)

None of the above solutions worked for me. I changed the iPhone Developer Certificate trust settings in Keychain. It should be Always Trust. Change it to Use System Defaults. Double click the certificate in Keychain to open the option screen
Discovered that from this blog

I had the same error message, this is how I solved it :
This is happening because i changed bundle identifier, so i just put old bundle id and it started to work again

I already had the Runpath Search Paths set correctly, but it still didn't work. #Justin Domnitz's answer put me on the right track: Setting "Always Embed Swift Standard Libraries" to Yes in my target's build settings did the trick for me.

Seems this issue was caused by the inclusion of Swift file into objective-c custom framework. Also unsure if related but my app target was built in objective-c as well. Also building to simulator in debug. Haven't verified for release or archive build yet.
Additionally Runpath Search Settings for the project target were set to "#executable_path/Frameworks", within the target settings for the framework they were set to: "#executable_path/Frameworks" and "#loader_path/Frameworks".
After having tried rebuilding custom framework and reattaching to app target, clearing derived data folder and a couple other suggestions, what ultimately worked for me was changing the build setting within Project target for the custom framework project (not app target): "Always Embed Swift Standard Libraries" to "YES". It appeared not to matter what the setting for the app target was set to. I verified this by resetting the simulator and rebuilding. This is similar to Daniele Ceglia's answer but I wasn't able to add a comment and wanted to provide more clarity.

For me Cleaning the project solve the issue!

I got such issue, too
All other ways could not help me,
so I have done it on stupid way
created new project and pod install from scratch
and after confirmed it is working correctly, I copied all class files and storyboard files, at last done!
I think it is the last way for it, maybe could help you

I had a similar problem in an Objective-C project where I started to include Swift files.
In my case, I created two targets in the main project, and I added a Swift empty file, that creates a bridging header file and some configurations, but I only marked it as a member of one target. The first target works properly, but the second not, and I noticed that the differences in build settings were this setting:
Runpath Search Paths -> $(inherited) and #executable_path/Frameworks
And I also needed to reference Objective-C Bridging Header to the file that was created before:
Objective-C Bridging Header -> pathTo/Target-Bridging-Header.h
After adding this two settings, the second target started to work properly.

Try cleaning the build folder, I was having the same problem and I solved it this way:
Product -> Clean Build Folder

For Me restart simulator solved this problem.

I tried a bunch of the cases above and it didn't seem to solve my issue. I use git and cocoapods for a project, and the error went away as soon as I made a new commit.

I had this problem before in iPod touch iOS 9.3. And I used all the methods mentioned in this post, but none of them worked.
I checked my project setting. And in the other link flag, I found I added -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null.
This flag prevents dyld insert in the jailbroken phone. When I delete this flag, the app can be launched again. I am not sure why it worked. Because in iPhone se iOS 10 I don't have to delete this line. But it did work in iPod touch iOS 9.3. So check it if you have the same situation like me.

Please check the *.framework If there is a _CodeSignature signature framework directory.
If there is no _CodeSignature folder,
Navigate to the Build Phases ,click + to add New Copy File Phase to create Copy Files.
after that, reference *.framework and choose Code Sign On Copy

Related

Unable to run my app on iOS 13. For a framework problem

I'm trying to test my project on my iPhone with iOS 13, using Xcode 12 beta 6.
The app crash on start and this is the message in the log:
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/GPUTools.framework/libglInterpose.dylib:/usr/lib/libMTLCapture.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
(lldb)
Someone can help me?
Thank you
This occurs because Xcode fails to sign the frameworks that are provided by SwiftPM with your app’s signing identity. It’s a known issue (SR-13343) in Xcode 12.
You can do these steps on third framework file to try fix :
select:Siging & Capabilites.
find : FrameWorks, Libraries, and Embedded Content.
change : the. "embed" of the third frameworks from "Do not Embed" to "Embed & Sign".
Go to Project Settings -> Target -> General -> Frameworks, Libraries, and Embedded Content -> Check that your custom framework has "Embed & Sign" option
add AppTrackingTransparency.framework to your project
In my case, I made a SPM framework and embedded then occurred this error.
I unchecked "Copy only when installing" in Build Phase of Embed Frameworks then works fine
you can also check this
Stripe iOS SDK via Swift Package Manager is installing, but crashing because "Library not loaded"
Don't Copy the Framework directly to your project. Adding 'Embed Pods Frameworks' manually works for me. Try It.
If you are asking permission for tracking via AppTrackingTransparency, you must addNSUserTrackingUsageDescription key to the info plist.

Xcode - Bundle format unrecognized, invalid, or unsuitable

Ok so I have just about managed to get to this point on my own but am now having some issues code signing the app specifically with the AdMob framework. I am getting this error:
Command /usr/bin/codesign failed with exit code 1 the details it are giving are as follows: Applications/MyApp.app/Frameworks/GoogleMobileAds.framework: bundle format unrecognized, invalid, or unsuitable
I have read the other posts on the site and tried many different ways of fixing this. If I untick 'Code Sign On Copy' the archive builds successfully but then fails on validation with a match error. This is how I have my frameworks set up currently:
Any help would be much appreciated!
I saw this same issue with a different framework.
The solution for me was removing the framework from the 'Embedded Binaries' section and only adding it to the 'Linked Frameworks and Libraries' section in the target 'General' tab.
I have just seen the same issue but with a different framework that was the social framework and then I did below:
go to build phase -> embed frameworks -> press copy only when installing check box
then it worked with me with no error
I had a similar problem but with a different framework. The solution for me was to make sure that the framework was present in these three places:
General tab:
Embedded Binaries
Linked Frameworks and Libraries
Build Phases tab:
Embed Frameworks
I ran into this issue when using a different framework.
Clear the DerivedData solve this issue.
https://docs.sentiance.com/sdk/troubleshooting/ios/bundle-format-unrecognized-invalid-or-unsuitable
Go to Xcode menu bar and select File > Project Settings (or Workspace Settings).
Under Per-User Workspace Settings, find the shortcut to DerivedData folder and open it via Finder.
Remove the entire content of the folder and empty the Trash.
Restart Xcode.
In Xcode 11.*
Target -> General -> Linked Frameworks and Libraries
change related framework with option "Do Not Embed"
Else Check on the :
Target -> Build Phase -> Link Binary With Libraries
Check status with Required/Optional - try it with required first.

Xcode 7 GM created generic archive instead of iOS app archive

I recently started using Xcode 7 GM.
When I archive my project, I get a generic Xcode archive instead of an iOS archive.
I'ved tried pretty much all the following:
xcode is creating generic xcode archive instead of iOS App Archive
Cannot generate iOS App archive in xcode
I compared the contents of a previous successful archive and a different folder structure for some components:
Swift libraries are inside a sub folder
The app extension is outside of the .app package
The info.plist is missing keys
Has anyone else encountering this problem? If so, did you solve and how?
Edit
We are using Cocoapods 0.38.2
I add the same problem : an old Xcode project, Xcode 7 (not the GM, the App Store version) and Cocoapods.
I have been tinkering a lot, tried Cocoapds 0.39 b3 and b4 without success, changed params in Build Settings, but finally - for me - the problem was shown by mrezk in https://github.com/CocoaPods/CocoaPods/issues/4021 :
Missing ApplicationProperties in Info.plist
As I'm not used to tinker with Info.plist and these keys, I've found in the Apple Dev forums a very useful answer : https://forums.developer.apple.com/thread/17063
In summary, for info.plist newbies like me ;) :
Archive your project
Organizer will show a Generic Xcode Archive
Right Click, Show in finder
Right Click, Show Package Contents
Open the Info.plist file in a XML editor
As mochs indicates, add these lines in the section :
<key>ApplicationProperties</key>
<dict>
<key>ApplicationPath</key>
<string>Applications/<<APP_NAME>>.app</string>
<key>CFBundleIdentifier</key>
<string><<BUNDLE_IDENTIFIER>></string>
<key>CFBundleShortVersionString</key>
<string><<YOUR_MARKETING_NUMBER>></string>
<key>CFBundleVersion</key>
<string><<YOUR_BUILD_NUMBER>></string>
<key>SigningIdentity</key>
<string>iPhone Distribution: <<CERTIFICATE_NAME>> (<<CERTIFICATE_ID>>)</string>
</dict>
and replace the tags with your own values.
Save, close Xcode, double click the archive : it should open in the Organizer as a iOS Type Archive.
Thanks to mrezk and mochs for the solution.
OP here.
The members of my team all tried Cocoapods' beta and it fixed the problem for us. Therefore I'm going to accept my own answer.
Although it might fix the problem, I believe Christian Navelot's answer to not be scalable and certainly not manageable within a team.
Also, all of us tried using the cp beta without removing the Copy Pod Resources build phase. This means that I won't be accepting Todd Anderson's answer either.
We are not using static libraries either, we are using frameworks (aka use frameworks! inside the Podfile).
Thanks to all for contributing to this question. Looks like we all got put into the same boat by Xcode 7!
Cheers!
In my case clearing the "Installation Directory" build setting in all static libraries fixed the issue. It was set to "/usr/local/lib" before.
When using "Save Built Product" as export method the Products folder got these sub directories. That's what pointed me in this direction.
I'm using cocoapods 0.38.2.
The other answers mentioned here were temporary fixes, but each required manual effort, either after every archive or after every pod install.
The new, better solution, is to update cocoapods to the latest version and remove your 'Copy Pod Resources' build phase from each app extension.
See https://github.com/CocoaPods/CocoaPods/issues/4021 for more information.
I had a similar issue with XCode7.1.1 and an app project with WatchKit Extension.
I fixed the issue by the following step
Open Build Settings of my app target and set NO to "Skip Install".
Open Build Settings of my WatchKit Extension target and set YES to "Skip
Install"
Open Build Settings of my WatchKit App target and set YES to "Skip
Install"
Then I could make iOS archive.

dyld: Library not loaded: #rpath/libswiftCore.dylib

I am trying to run a Swift app on my iPhone 4s. It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. I have iOS 8 and the official release of Xcode 6.
I have tried
Restarting Xcode, iPhone, computer
Cleaning & rebuilding
Revoking and creating new certificate/provision profile
Runpath Search Paths is $(inherited) #executable_path/Frameworks
Embedded Content Contains Swift Code is 'Yes'
Code Signing Identity is developer
Below is the error in entirety
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at
address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib
For me none of the previous solutions worked. We discovered that there is an "Always Embed Swift Standard Libraries" flag in the Build Settings that needs to be set to YES. It was NO by default!
Build Settings > Always Embed Swift Standard Libraries
After setting this, clean the project before building again.
For keen readers some explanation
The most important part is:
set the Embedded Content Contains Swift Code (EMBEDDED_CONTENT_CONTAINS_SWIFT) build setting to YES in your app as shown in Figure 2. This build setting, which specifies whether a target's product has embedded content with Swift code, tells Xcode to embed Swift standard libraries in your app when set to YES.
The flag was formerly called Embedded Content Contains Swift Code
Surprisingly enough, all i did was "Clean" my project (shift+cmd+K) and it worked. Did seem to be related to the certificate though.
I started getting this error when I removed:
#executable_path/Frameworks
from Runpath Search Paths in my build settings. Replacing it fixed everything up again (thank goodness for source control!)
I don't know how it got there, but it appears to be needed for a binary to find its embedded Swift runtime.
For the device, you also need to add the dynamic framework to the Embedded binaries section in the General tab of the project.
In Xcode 8 the option for Embedded Content Contains Swift Code option is no longer available.
It has been renamed to "Always Embed Swift Standard Libraries = YES"
Xcode 13 here (13.1 with react-native).
Created a clean react-native project and saw /usr/lib/swift as an entry in Runpath Search Paths.
After adding that, my project finally ran without crashing!
Nothing helped from what was suggested before.
I think it's a bug when certificates are generated directly from Xcode. To resolve (at least in Xcode 6.1 / 6A1052d):
go to the Apple Developer website where certificates are managed: https://developer.apple.com/account/ios/certificate/certificateList.action
select your certificate(s) (which should show "Managed by Xcode" under "Status") and "Revoke" it
follow instructions here to manually generate a new certificate: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW32
go to Xcode > Preferences > Accounts > [your Apple ID] > double-click your team name > hit refresh button to update certificates and provisioning profiles
I was having this issue with running my Swift tests (but not my app). It turns out that the test needed to have more than #executable_path/Frameworks in it's Runpath Search Paths build setting for the test target. Setting the Runpath Search Paths to the following worked a charm for me:
$(inherited)
#executable_path/Frameworks
#loader_path/Frameworks
OK, sharing here another cause of this error. It took me a few hours to sort this out.
In my case the trust policy of my certificate in Keychain Access was Always Trust, changing it back to defaults solved the problem.
In order to open the certificate settings window double click the certificate in the Keychain Access list of certificates.
This issue occurs again in Xcode 10.2. You must download and install the following package from Apple. It provides Swift 5 Runtime Support for Command Line Tools.
https://support.apple.com/kb/DL1998?locale=en_US
You have to set the Runpath Search Paths to #executable_path/Frameworks as showed in the following screenshot of Build Settings:
If you have any embedded frameworks made in Swift, than you can set to YES the Build Options Embedded Content Contains Swift Code.
I think Apple has already summarized it under Swift app crashes when trying to reference Swift library libswiftCore.dylib
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.
Let's project P is importing custom library L, then you must add L into
P -> Build Phases -> Embed Frameworks -> +. That works for me.
This error message can also be caused when upgrading Xcode (and subsequently to a new version of Swift) and your project uses a framework built/compiled with an older/previous version of Swift.
In this case rebuilding the framework and re-adding it will fix the problem.
The most easy and easy to ignored way : clean and rebuild.
This solved the issue after tried the answers above and did not worked.
I was having the same problem after moving to a new mac, and after hours, trying all the suggested answers in the questions, none of this worked for me.
The solution for me was installing this missing certificate.
http://developer.apple.com/certificationauthority/AppleWWDRCA.cer
Found the answer here.
https://stackoverflow.com/a/14495100/976628
Change Copy Pods Resources for the target from:
"${SRCROOT}/Pods/Target Support Files/Pods-Wishlist/Pods-Wishlist-resources.sh"
to:
"${SRCROOT}/Pods/Target Support Files/Pods-Wishlist/Pods-Wishlist-frameworks.sh"
I solved by deleting the derived data and this time it worked correctly. Tried with Xcode 7.3.1GM
After having tried out everything, I finally found out, that the build seems not always include every detail again and again. Maybe for speeding up the process...
In order to ensure WHOLE packaging before running on a device, make a Clean first: Shift-Cmd-K.
Then build with: Cmd-B.
After that run it on your device.
Easy.
Kind regards to all you nice guys in that place!
We had a unity project that creates an xcode project that includes libraries that use swift.
We tried each and every reasonable suggestion on this thread.
Nothing worked. Code runs fine on new devices, and crashes on iOS<=12
It seems that swift is so smart, that even if you set it to "ALWAYS_EMBED_SWIFT_LIBRAIES"="YES" it does not include the swift libraries.
What actually solved the problem for us is to include a dummy swift file in the project.
The file must contain calls to dispatch, foundation libraries.
Apparently this hints mighty-xcode to force include the libraries, but this time for real.
Here is the dummy file we added that made it work:
import Dispatch
import Foundation
class ForceSwiftInclusion {
init() {
// Force dispatch library.
DispatchQueue.main.async {
print("something")
}
// Force foundation library.
let uuid = UUID().uuidString
print("\(uuid)")
}
}
For unity, also add project.AddBuildProperty(target, "SWIFT_VERSION", "Swift 5"); to your post processing for creating the xcode project.
In my case, it was just the name of my target :
I renamed it like this : MyApp.something and the same issue appeared.
But I saw in the build Settings window, my product module name has been changed like this MyApp-something.
So, I removed the dot in my target name (MyAppSomething) and the issue was gone.
For me, having tried everything with no success, what worked was to remove #executable_path/Frameworks from the Packaging section (don't know how it came to be in there in the first place)
What worked for me in Xcode 11 was going to General -> Frameworks, Libraries, and Embedded Content and changing the "Embed" option for the framework in question to "Embed & Sign"
None of the solutions worked for me. Restarting the phone fixed it. Strange but it worked.
none of these solutions seemed to work but when I changed the permission of the world Wide Developer cert to Use System defaults then it worked. I have included the steps and screenshots in the link below
I would encourage you to log the ticket in apple bug report as mentioned here as Apple really should solve this massive error:
https://stackoverflow.com/a/41401354/559760
I had the same issue for Xcode 13+ when I create a release build. Had to waste my time on troubleshooting this issue. Finally I was able to fix the issue with following step.
I added a new entry for Release in Runpath Search Paths in Build Settings -> Linking.
/usr/lib/swift
After adding that, I could run my app without crashing!
Xcode 7.2, iOS 9.2 on one device, 9.0 on other. Both had the error. No idea what changed that caused it, but the solutions above for the WWDR were correct for me. Install that cert and problem solved.
https://forums.developer.apple.com/message/43547
https://forums.developer.apple.com/message/84846
There are lot's of answers there but might be my answer will help some one.
I am having same issue, My app works fine on Simulator but on Device got crashed as I Lunches app and gives error as above. I have tried all answers and solutions . In My Case , My Project I am having multiple targets .I have created duplicate target B from target A. Target B works fine while target A got crashed. I am using different Image assets for each target. After searching and doing google I have found something which might help to someone.
App stop crashing when I change name of Launch images assets for both apps . e.g Target A Launch Image asset name LaunchImage A . Target B Lunch Image asset name LaunchImage B and assigned properly in General Tab of each target . My Apps works fine.
For me building a MacOS command line Swift app that depended on 3rd party Swift libs (e.g. SQLite) none of the above solutions seemed to work. What did work was directly adding the following path to my Runpath Search Paths in the Build Settings:
/Applications/Xcode.app/Contents//Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/
Doing that did give a warning at runtime saying that Xcode had found 2 versions of libswiftCore - which makes sense. Except that not including that line resulted in Xcode not finding any versions of libswiftCore.
Anyway, that'll do for me even if it doesn't seem right - my app is just a utility that I'm not intending to distribute and at least it runs now!
I have multiple version of Xcode installed at the same time. The framework was built with a newer version of Xcode. The app that I tried to compile was with an older version of Xcode. When I cleaned and compiled both the framework and the app with the same version of Xcode then things worked.

Unable to run app in Simulator: An error was encountered while running (Domain = LaunchServicesError, Code = 0)

After successfully compiling the project in Xcode 6, I am unable to run it in the simulator with the above mentioned message. I did all the possible research, tried everything and still no advances.
I am not working with swift, neither I use widgets or extensions, so please do not suggest solutions caused by these as can be seen in similar questions.
If someone found a possible cause (or solution!!) other than these, please help. Thanks
"Reset Content and Settings" from iOS Simutalor menu options and launching simulator after Quitting solved my issue.
Cleaning the build folder resolved the issue for me.
(While holding down the Alt-key: Product > Clean build folder)
I tried every other solution listed here. Well, I ported my project from Swift 1.2 to Swift 2.0. The application was stuck even after a lot debugging and launch services error 0 was reported.
solution: It happens because of framework compilation.
App target -> Build Phases -> Embed Frameworks.
So mark copy only when installing on. Clean the project and run it!
This has now been resolved. The problem was caused by ShareKit library added by CocoaPods for compatibility reasons. After removing the library and all related code, the app successfully launched in simulator. I recommend checking the system log for more details on the issue as to me it pointed me in the right direction (stating the name of conflicting library).
In case anyone has this problem in combination with cocoa pods, these steps helped me to solve this error (after few hours):
run pod cache clean
from SRC_ROOT run rm -rf Pods (optionally rm Podfile.lock)
Click on the Simulator app, click Simulator -> Reset Content and Settings...
Go into Xcode, In the Menu bar click Product -> Clean (or click Shift + Command + K).This will to clean your Xcode project.
Create a new Terminal Shell (From menu bar click Shell -> New Window)
run rm -rf ~/Library/Developer/Xcode/DerivedData/
...then try to Build & Run your project.
Note:
SRC_ROOT can be found by entering the Navigator, clicking on the project, clicking on the project again from the project and targets list, going into Build Settings, scrolling all the way to the bottom to the User-Defined Section, and the SRC_ROOT will be labeled as PODS_ROOT. Take that and copy it verbatum into the Terminal and proceed with step 2 from the list above.
Hope it helps.
I get rid from the issue by the given steps for simulator
1. Way
Reset Content and Settings of Simulator.
Clean your project by Cmd+Shift+K.
Clear your Derived Data.
The last one which is more important change your Bundle Identifier by "com.yourcompanyname.projectname" like "com.facebook.Facebook"
2. Way
You can do only be the given line, it works for me
The last one which is more important change your Bundle Identifier by "com.yourcompanyname.projectname" like "com.facebook.Facebook"
Thanks and enjoy programming.
Might be related to this issue: "This app contains an app extension with an illegal bundle identifier" issue
I had to format the bundle identifiers for my app and extension as follows:
com.company.AppName
com.company.AppName.Extension
First "Reset Content and Settings"
If you didn't fill the build number and fill it and Run.
It's solved for me.
If you change the name of the supplied class InterfaceController set by default when you start a new project. This class is referenced in the Info.plist under the key RemoteInterfacePrincipalClass. In my case, I got the error mentioned by the OP until I fixed the name of the class in there (see screenshot).
If you are here after having issues doing an integration with WatchOS 2.0, go to - ~/Library/Logs/CoreSimulator/[Device UDID]/system.log and if says something like WatchKit 2 app has frameworks; that's not allowed. then follow the link below.
http://zyafa.me/blog/watchos-2-and-embedded-frameworks
Thanks for pointing this out #Miki and kudos to you. I had the same issue as you yesterday (and I added ShareKit 3.0.0 from CocoaPods to the app a few days ago). I suspected ShareKit giving me this problem, but now I can be confident of exactly which library is causing this. Here is what I found in my log (if it can benefit others):
Error Domain=LaunchServicesError Code=0 "The operation couldn’t be
completed. (LaunchServicesError error 0.)" UserInfo=0x7fa836097aa0
{Error=PackageInspectionFailed, ErrorDescription=Failed to load
Info.plist from bundle at path
/Users/{UserName}/Library/Developer/CoreSimulator/Devices/99FEB34E-6F00-4EFA-861A-A6985AFE96D8/data/Library/Caches/com.apple.mobile.installd.staging/temp.X7eead/extracted/{AppName}.app/Frameworks/LiveSDK.framework}
I'm adMob user and I solved enabling "Copy only when installing" in App target -> Build Phases -> Embed Frameworks.
Have the same problem after localizing my app. Especially Info.plist. Seems I had empty CFBundleShortVersionString in InfoPlist.strings, after fixing that the simulator started to work properly.
I got this issue by adding a folder reference named "Resources".
If I give it another name, then it runs !
There are a number of things that can cause this error. The best general answer is to search the console log for CoreSimulator, as the simulator logs the underlying problem when it displays this message.
If you have installed any libraries using CocoaPods while XCode was open, all you have to do is, Close XCode and remove the library from Pod file, run the command pod install it will uninstall that library. then install library again. Please make sure that XCode is always closed while installing and uninstalling libraries.
I hade exactly the same problem and it was ShareKit.
On the simulator I had "Error Domain=LaunchServicesError Code=0".
On the iPhone6 device I had "App installation failed Could not inspect the application package."
When I removed ShareKit it worked.
I had this problem when I added an Apple Watch target to my app, and accidentally removed the InterfaceController.m file. Adding back the file in the target fixed the problem.
There are different things that can cause this. Looking in the console may well give you a clue.
In my case - the issue was an extension built before I changed the name of the product. Xcode didn't clear the old one out, then got stressed at two extensions with the same bundle id.
(Deleting the build folder fixed my particular issue).
In my case the issue came from an icon set added with some images missing. Once I replaced the icon set with another one, and uninstalled the app in the simulator; I was able to run it again.
I removed all my pod files and replaced them all, seems the problem for me was the bolts framework was old, and causing this error. I did a clean & reset content and now it's all good.
Do not add the google maps framework to the embedded lib section this solved my build break.
I had this error in developing app for Apple Watch after adding in Info.plist: "App Transport Security Settings" and "Allow Arbitry Loads" = YES. (In WatchKit App, in WatchKit Extension is good!!)
Deleting this two rows, it keeps working.
For me, the problem occurs because I added my framework (GoogleMobileAds.framework in my case) to Embedded Binaries, not Linked Frameworks and Libraries.
For your information, AdMob instructs you to use Add Files to "Your Project" menu on Xcode, but I was too lazy to obey the instruction.
I had this problem when trying to run UI tests in a project containing AWS Cognito.
Here's how I resolved it.
Select the UI test target.
Click on the Build Phases section.
Click the plus to add a Copy Files phase
In the Copy Files phase, change the destination to Frameworks (see the last image)
Hit the plus below the Copy Files phase.
Select the framework for which you're receiving an error and hit the Add button (yours will probably not be the first item in your project hierarchy).
It should end up looking like this.
Repeat steps 5 and 6 for all frameworks giving you an error.
Run your tests.

Resources