Reputation: 4755
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
$(inherited) @executable_path/Frameworks
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
Upvotes: 470
Views: 274394
Reputation: 814
In my case, I was trying to resolve an issue that is happening in iOS 14. So I downloaded iOS 14.0 for my simulator in Xcode settings. In that case, I encountered the same problem as the author mentioned.
No matter how many times I applied the suggested answers, it didn't work for me.
Then I simply downloaded iOS 14.1 version and deployed my code with it. Problem solved!
The good news is that our app was behaving the same with iOS 14.1 so that we could reproduce the issue and fix the bug.
Upvotes: 0
Reputation: 2636
In addition to previous answers (setting Runpath Search Paths) my solution was in increasing iOS Deployment Target from 11.0 to 12.4.
Upvotes: 0
Reputation: 152
For me, I forget add two lines of code below to target 'Runner' do
in Podfile
target 'Runner' do
use_frameworks!
use_modular_headers!
end
Add these codes solved, wish to help you!
Upvotes: -1
Reputation: 536
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!
Upvotes: 8
Reputation: 498
I tried to read through all the answers. (Maybe missed some) But here is my solution. Might be helpful to someone. I just created a swift file (void.swift) in my project. When I added this file, it asked me to create a bridge. I said yes. That's all! It started working. Background: My project is written in obj c. And I added FBSDK pods to my project. After that, I started getting this error.
Upvotes: 1
Reputation: 3541
Nothing worked for me, then i did these steps below:
I removed the flipper usage from podfile. It looked like this for me:
use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
I added a swift file in my project to create a bridging header.
Upvotes: 0
Reputation: 553
For me none of above solutions worked.
I managed to get rid of the issue by creating an empty swift file inside my project. After that do a clean build and everything just worked!
Hope this helps others.
Tested on iOS 15 & React Native 0.66
Upvotes: 1
Reputation: 17872
Me also got the exact same error in Xcode 13, iOS 12 mobile.
Here my project deployment info is 12.0, but my framework deployment info in iOS 15.0.
I have changed my Framework deployment info into 12.0.
Conclusion:
Which means framework and project supported versions issue. We need to fix the framework minimum support version after creating the framework.
Upvotes: 0
Reputation: 914
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.
Upvotes: 72
Reputation: 11
I am having same issue
There are lot's of answers there but might be my answer will help some one.
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let mom = NSManagedObjectModel.mergedModel(from: [Bundle(for: Self.self)])!
let container = NSPersistentContainer(name: "Test", managedObjectModel: mom)
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
Upvotes: 0
Reputation: 159
For Xcode 12.x, what worked for me is go to General > Frameworks, Libraries, and Embedded Content. Then, choose Embed & Sign all Agora frameworks. (it was defaulted to Do Not Embed.
Upvotes: 1
Reputation: 809
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"
Upvotes: 4
Reputation: 12512
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.
Upvotes: 6
Reputation: 2797
In my case, This is a bug of the early version iOS13.
https://forums.developer.apple.com/thread/128435
kambala
Mar 25, 2020 12:41 AM
FYI this is fixed in 13.4 release
Upvotes: 0
Reputation: 1088
Got the same issues after two years. I think this post explains the reason I got (But may be not the reason in this question). Use subscribed developer account or static libraries could help. Like remove use_frameworks!
in your Podfile
.
Upvotes: 0
Reputation: 36257
I ran into this issue while I was trying to run unit-tests on a private pod.
I did everything everyone suggested. Nothing worked.
All I had to do was to run my unit-tests on a different simulator.
I didn't try resetting the contents and settings of my simulator, maybe that would have worked as well ¯_(ツ)_/¯
Upvotes: 1
Reputation: 3051
I tested all of the above solutions but nothing solved the problem. I was using Xcode 10.2 and macOS 10.14.3. first i installed swift 5 runtime support for command line tools but nothing changed second i updated OS to 10.14.4 and nothing changed third i updated Xcode to 11.2.1 and the problem solved (do not user Xcode 11.2. it has archiving issue and deprecated)
Upvotes: 0
Reputation: 3617
If you're getting an error like this:
The bundle "YourFrameworkTests" couldn't be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. (dlopen_preflight(/some/path/.../YourFrameworkTests.xctest/YourFrameworkTests): Library not loaded: @rpath/SomeOther.framework/SomeOther Referenced from: /some/path/...)
and use CocoaPods in your framework, then try to edit the Podfile
and remove inherit! :search_paths
from the Test
target, and run pod install
again.
For more details, see https://github.com/CocoaPods/CocoaPods/issues/8868.
Upvotes: 1
Reputation: 788
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
Upvotes: 23
Reputation: 61
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!
Upvotes: 2
Reputation: 1433
The most easy and easy to ignored way : clean and rebuild.
This solved the issue after tried the answers above and did not worked.
Upvotes: 9
Reputation: 5347
For the device, you also need to add the dynamic framework to the Embedded binaries
section in the General
tab of the project.
Upvotes: 70
Reputation: 4953
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"
Upvotes: 69
Reputation: 6182
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
Upvotes: 581
Reputation: 1033
I'm using Xcode 8.3.3 and Xcode 9.2. The solution for me was to switch my default Xcode from 8 to 9 using Xcode Select:
$ xcode-select --print-path
$ sudo xcode-select -switch /Applications/Xcode-9.2.app
Edit: Actually what seemed to help here was that Xcode 9.2 used the derived data from Xcode 8.3.3. Not a solution but at least it allows me to move forward with my work.
Upvotes: 1
Reputation: 130
For me solution is here below Disable the "Embed Asset Packs in Product Bundle" and this issue will be gone
Upvotes: -1
Reputation: 1010
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.
Upvotes: 8
Reputation: 3431
I am on Xcode 8.3.2. For me the issue was the AppleWWDRCA certificate was in both system and login keychain. Removed both and then added to just login keychain, now it runs fine again. 2 days lost 😭
Upvotes: 1
Reputation: 416
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.
Upvotes: 2
Reputation: 6882
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
Upvotes: 3