问题
Just finished updating codebase to Swift 4. It is working fine in the simulator. When I build to a device I get an instant crash with no error message:
It works fine in the simulator.
There are some threads on it:
App crashes only with (lldb)?
iOS app crashes with no error, just (lldb)
dyld`__abort_with_payload: With no error message
From what I learned the problem might be linked binaries but I've dug into my linked binaries and I believe everything is linked correctly.
Any thoughts on where to begin debugging this or what the problem might be?
Update1: I had an internal framework for one of my xcodeproj's so I tried removing it and installing it as a pod but the error still persists.
Update2 Adding full stack trace:
Update3 Error trace from forcing crash by launching app not from Xcode but the phone itself and then tracing error log:
Termination Description: DYLD, Library not loaded: @rpath/PromiseKit.framework/PromiseKit | Referenced from: /var/containers/Bundle/Application/C50A937F-2A6F-4E5C-89C7-2D
Update4 After removing the promisekit framework the shell version of the app does compile on the device which leads me to conclude this (like the others who have had this mysterious issue) is a framework link error. However trying all the solutions in the common threads like:
iOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 Beta
Has not worked. Embedding and linking or anything else has not worked.
So it is a framework linking error of some kind but linking and embedding does not seem to fix the issue.
回答1:
One of the things that can trip up development with the simulator is its access to Macintosh resources. The project may have accidentally been linked to a Macintosh version of a framework or library. It exists on the simulator, but does not exist on an iPhone device.
I have had issues in the past with Xcode choosing the wrong version of a framework when the targets for iOS and Mac had the same names. If you have such frameworks, try changing one or both target names and product names temporarily. Then see if Xcode is choosing the one you intended.
回答2:
The long and the short of it was when I embedded the framework into the main app, it caused some other obscure bug. When I removed a runscript from the build phases, it allowed the embedding to actually work and it fixed the issue.
So by deleting the run script phase seen below in the build phases:
I was able to embed the framework and the app began to compile on devices.
So if you have this type of error in the future the solution is still to embed it, but in my case, there was another problem preventing that embedding from working.
回答3:
After I solved another problem: https://stackoverflow.com/a/48538124/1012775 I modified some settings that kind of messed up my build settings. Because of that I got the same problem as the questioner here.
I solved it by doing a 'git reset --hard' and got back to my clean state. Since than I don't have this issue anymore, thank God. It might work for you too.
来源:https://stackoverflow.com/questions/46922292/ios-app-crash-on-launch-with-only-lldb-the-app-works-in-simulator