Swift app crashes when run on device - dyld: Library not loaded: @rpath/libswiftCore.dylib
Asked Answered
P

3

6

I am a newbie to the ios/xcode world and attempting to test out a simple Swift app on my iphone 5 running iOS v8.0.2. The app builds successfully in xcode (Version 6.1 (6A1052d)) but when it attempts to run it on the iphone, it crashes with the following error:

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/mobile/Containers/Bundle/Application/FBBDB6F3-6B2C-428F-AA9C-E88FE439D5B6/prox.app/prox
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/FBBDB6F3-6B2C-428F-AA9C-E88FE439D5B6/prox.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x001FA000, size=0x001A0000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/FBBDB6F3-6B2C-428F-AA9C-E88FE439D5B6/prox.app/Frameworks/libswiftCore.dylib
    /private/var/mobile/Containers/Bundle/Application/FBBDB6F3-6B2C-428F-AA9C-E88FE439D5B6/prox.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x004DA000, size=0x001A0000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/FBBDB6F3-6B2C-428F-AA9C-E88FE439D5B6/prox.app/Frameworks/libswiftCore.dylib
(lldb) 

I have tried out most of the suggestions that have helped others who have run into this error but have had no luck getting around it. The same app works fine when built using the build environment of another team member. I have compared the build settings and found them to be identical.

Prearrange answered 3/12, 2014 at 21:32 Comment(23)
Please file a bug with Apple or even take out a support incident. A lot of people are having the same problem recently. Something has gone wrong with Swift.Burnout
Exactly what kind of device is your "other team member" able to run on?Burnout
The other team member is using an iPhone running iOS 8.1.1. I think it is something to do with the build environment because the app built on this other team members xcode (same version as mine) works fine on my device.Prearrange
I said "exactly". There's no such thing as "an iPhone". What kind of iPhone? This could be important. We know you have an iPhone 5. Now we want to know what he has. Please find out.Burnout
It has nothing to do with "the build environment". I was building Swift apps and running them on my device just fine for months - and then I wasn't. I changed nothing. It's Swift that changed. Now we need to figure out how.Burnout
I am having same problem as of about ten days ago. Have been on vacation since and haven't got back to it. Thought it was just me...Gavrielle
@Matt - the other person who is able to build and deploy to all our devices is using an iphone 5s. When I build the same app on my Mac and attempt to deploy it to my device, it fails.Prearrange
Exactly what I suspected. So I'm betting that this is a 32-bit vs. 64-bit device problem. Something has gone wrong with Swift so that you can't develop on a 32-bit device. Thanks for confirming that!Burnout
Oh, and that may give us a workaround; you might be able to develop on your device by suppressing the 64-bit architecture in your build settings. In other words, if the only architecture is the 32-bit architecture, it might solve the problem. It's not a real solution, just a workaround; obviously you wouldn't want to suppress 64-bitness in real life.Burnout
@MikeTaverne What's your device type?Burnout
@Burnout - iPhone 6 Plus. But my coworker can run the same app on my phone. And I cannot run the app on iPhone 6. My device used to work up until two weeks ago. At that time I had some issues with my developer certificate and provisioning profile, after which the problem appears to have started. The app starts on my device now - I see the startup screen - then is crashes with the error described above. I suspect a problem with my cert still. It seems like a personal problem :)Gavrielle
But the app runs fine on iPod 5th gen with iOS 7.0.6. Argh.Gavrielle
@Matt - here is what Apple Dev support has to say about this problem "Our engineers have reviewed your request and have determined that you are experiencing an issue for which there is no known workaround at this time." :-(Prearrange
@MikeTaverne So much for the bitness theory. - Here's the thing. The ability to develop on the device is exactly what you're paying $99/year for. If you just wanted to develop on the simulator, that's free. So if you can't develop on the device and you're paying to be able to do so, Apple are in breach of contract. They must solve this and we need to make that very clear to them.Burnout
@Burnout What is the best way to raise the issue with Apple? I have not done this before. Do you have any sense for how widespread this issue is? Thanks.Gavrielle
@MikeTaverne It's plastered all over Apple's dev forums, that's for sure. And do a search right here for the key parts of the error message. Look at the "Related" links to the right of this comment, for one! I guess the way to start is to raise it as a dev support incident and don't be satisfied with the answer "no known workaround". They must provide a solution.Burnout
Opened a support ticket, will see what happens.Gavrielle
"Our engineers have reviewed your request and have determined that you are experiencing an issue for which there is no known workaround at this time."Gavrielle
@MikeTaverne Right, that's what they told the OP as well. But they can't leave it at that. This is not just "an issue" - it is a complete breach of contract. You have paid for a dev membership. A dev membership where you can't develop on a device is no membership at all, since if all you wanted is to develop on the simulator, you could do that for free. They have to give you satisfaction here.Burnout
@MikeTaverne Okay, I've had good luck with David Berger's solution. I had to delete and install so many things along the way that it's hard to know where to pin the solution, but it is true that after deleting all certificates (including cleaning them out from my keychain) and all profiles for apps not actually in the app store (which the Member Center wouldn't let me delete), and starting from scratch, we're back in business.Burnout
@Burnout - Yep, this worked for me too. I re-created my developer cert and it works now. Wish Apple could have told me this. :( Thanks for your help. MikeGavrielle
@MikeTaverne You were a big help too. And so was David Berger. I hope we've also helped the OP!Burnout
possible duplicate of dyld: Library not loaded: @rpath/libswiftCore.dylibZincate
S
5

Try creating a new distribution cert and a new provisioning profile. It is possibly related to this. I ran into this issue.

https://www.airsignapp.com/ios-apps-using-swift-crash-when-signed-with-inhouse-certificate/

Basically Apple added a new field to the cert and did not tell us in any clear way.

Skinflint answered 7/12, 2014 at 2:7 Comment(5)
If this were a certificate problem then (1) why doesn't Apple tell people that if that's the solution? and (2) how do you explain the fact that we can all run on a device just fine if the app is Objective-C only? This is not a certificate problem, it's a Swift framework problem.Burnout
You making a small point over a semantic issus. Apple changed their certificates without telling anyone. Apple designed their certificates and designed the Swift framework in a way so that they are coupled. The Swfit launching procedure on an iOS device looks for information that was embedded in the cert. If it is not there it crashes. To me this is a problem with both.Skinflint
That's a good argument... I'm up and running again, and starting from a completely fresh cert and provisioning profile was one of the things I did along the way, so I'm upticking your answer even if I can't be sure that post hoc was propter hoc. :)Burnout
@DavidBerger - upvote for this! In my case, re-creating my developer cert fixed the issue. When I ran my app in Xcode after downloading the new cert, it prompted me that my provisioning profile did not include my new cert, and offered to "Fix Issue". I clicked that and it generated a new provisioning profile and I was good to go. MikeGavrielle
I did this step several times and it has not solved my issue.Demirelief
D
1

You probably need to use a new certificate for signing your application. Excerpt from the Apple technical FAQs.

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.

Domoniquedomph answered 11/5, 2015 at 10:28 Comment(0)
S
0

I had the same problem after updating XCode, with an "old" Swift Project...

I solved it by creating a new project with the new XCode and just copy / paste my old classes to it... If you copy / paste every class/storyboard to the new project it will run

Skiver answered 3/12, 2014 at 21:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.