Swift App Opens on Simulator But Not on Device - ios

I've been working on my iOS app for a while, and it builds and runs fine on the simulator, but when I try to run it on my device, a few things happen:
The app launch screen appears
The app crashes and my Xcode output is as follows:
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from:/private/var/mobile/Containers/Bundle/Application/18932CDB-57DA-4A87-B154-45B9F3CD01D0/Up & Down - Minimalistic, Beautiful Counter.app/Up & Down - Minimalistic, Beautiful Counter
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/18932CDB-57DA-4A87-B154-45B9F3CD01D0/Up & Down - Minimalistic, Beautiful Counter.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x100110000, size=0x0015C000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/18932CDB-57DA-4A87-B154-45B9F3CD01D0/Up & Down - Minimalistic, Beautiful Counter.app/Frameworks/libswiftCore.dylib
(lldb)
The following message also appears, with a few other similar errors:
dyld`dyld_fatal_error: Thread 1: EXC_BREAKPOINT (code=1,subcode=0x1200f5088)
-> 0x1200f5088 <+0>: brk #0x3
So I don't waste your time, I would like to warn you that I have tried to clean and build, revoke and renew certificates, delete all breakpoints, and restart both Xcode and my iPhone.
Any ideas on how to make my app run on my device? Thanks!!!

My project has Cocapods and I'm using multiple schemes. Running pod update fixed something wrong that happened during a merge and now it runs fine.

Related

_XCTFailInCurrentTest should only be called while a test is running

I am now doing for UITesting with Xcode and I got this error.
* Assertion failure in void _XCTFailInCurrentTest(NSString *,
...)(),
/Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-10112/XCTestFramework/Classes/XCTestCase.m:63
2016-05-13 22:31:54.961 XCTRunner[15428:168507] * Terminating app
due to uncaught exception 'NSInternalInconsistencyException', reason:
'_XCTFailInCurrentTest should only be called while a test is running.
Failure description: Failed to receive completion for
I have seen other similar post here.
Cannot run Xcode (7.3) UI tests in Jenkins
I am using Jenkins but for now, I am directly running from Xcode and I can't even run from Xcode. How shall I do?
Background
I faced this issue in Xcode 7.3 (7D175) and iOS Simulator 9.3.
The symptoms were as follows
the Test Runner launches normally and exits.
Following this, the app under test never launches.
(if the app under test was not installed, Xcode will also never install the app prior to starting the test).
(a side symptom is that recording also does not work for me - I took inspiration from this SO post.)
After 30 seconds the test times out with:
XCTRunner[36260:489138] Continuing to run tests in the background with task ID 1
2016-05-18 16:17:25.720 XCTRunner[36260:489138] *** Assertion failure in void _XCTFailInCurrentTest(NSString *, ...)(), /Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-10112/XCTestFramework/Classes/XCTestCase.m:63
2016-05-18 16:17:25.723 XCTRunner[36260:489138] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_XCTFailInCurrentTest should only be called while a test is running.
Failure description: Failed to receive completion for <XCDeviceEvent:0x7fddc241f970 page 12 usage 64 duration 0.01s within 30.0s'
The fix that worked for me was:
reset the simulator.
check whether the deployment target is set to iOS 9.x in the build settings for the UI Test Target. (in my case it was set to iOS 8)
after changing the target, clean and rebuild.
After following these steps, Xcode was able to install the app prior to the test, recording worked, and the error went away.
By some reason simulator got corrupted. In my case it was not possible to launch any test once get at the same point. In my case what it worked was reset simulator (Menu Simulator|Reset Contents and Settings...) or switch to any other simulator.
We tried the tips from the other responses, which did not work for us.
A complete reinstall of Xcode 7.3 fixed our issue.
remove Xcode
restart
reinstall Xcode
success

xCode 7 - dyld`dyld_fatal_error:

When I was attempting to run my game (the code was generated by unity), I can get all the way to run the game in the simulator (for iPhone 5S - as thats the phone I have) but when I go to try and run it on my real iPhone, It will install, and then it will try to run, but I get a blank screen, and on my computer theres the error:
dyld`dyld_fatal_error:
-> 0x1200a5088 <+0>: brk #0x3
and beside the second line is:
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1200a5088)
The app will only open if xcode is trying to run it, but it will freeze, and if you just try click into the app on the actual phone it will quit out straight away.....
Anyone any ideas?
I just had this problem and resolved it by doing a hard clean (Cmd + Shift + Opt + K) and then re-building.
Try to go into Build settings -> Configuration -> Scripting Backend -> Mono2x (not IL2CPP)
Same problem occurred in Xcode 8. Found out that I am using a device of iOS 9. Same app run but no problem found in another iOS 10 device.
It seems that this occur when debugging only. The release app has no problem after installing via iTune.

iOS/Xcode all projects loading a custom embedded framework started crashing today

I'm working on an iOS project with a moderately complex build system that creates a framework/universal binary.
While making some changes to that framework & it's test app, running it suddenly started crashing in dyld before hitting main(). It appears to be an issue with Xcode, as reverting the build and even downloading a known good version now produce the same result! Dyld is failing to load the custom framework:
Process: TestApp [530]
OS Version: iOS 9.2.1 (13D15)
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000000e7ffdefe
Triggered by Thread: 0
Dyld Error Message:
Dyld Message: Library not loaded: #rpath/Test.framework/Spin
Referenced from: /var/mobile/Containers/Bundle/Application/8A7C50D3-F3A1-4DB6-8929-52607F8605A2/TestApp.app/TestApp
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/8A7C50D3-F3A1-4DB6-8929-52607F8605A2/TestApp.app/Frameworks/Test.framework/Test
mmap() errno=1 validating first page of
'/private/var/mobile/Containers/Bundle/Application/8A7C50D3-F3A1-4DB6-8929-52607F8605A2/TestApp.app/Frameworks/Test.framework/Test'
Error Formulating Crash Report:
Failed while requesting activity/breadcrumb diagnostics
This problem appears to have numerous possible root causes. I've tried the various solutions posted for question 32730312 (here: Reason: no suitable image found.) including:
deleting the projects Build and DerivedData folder
deleting various Xcode cache folders
restarting xcode, the computer & even the devices
regenerating the provisioning profile
discarding the project and building from a fresh pull or even previous releases of the SDK
None of those remedied the problem.
The project runs fine on the simulator, but not on a device. I'm unsure what else to try short of reinstalling Xcode and/or creating a separate user account as there's apparently something else blown apart in Xcode that I've missed!
Update: problem solved, root cause unknown.
I tried creating a new user account, checked out code from there, and got the same error. So, it wasn't a "hidden cache" of Xcode badness either...
Left with literally nothing else to try, I uninstalled & reinstalled Xcode, and everything started working again.
I post my results here hoping the last six hours of pain can help at least a single troubled soul... Ack!

Reason: no suitable image found : Frameworks/libswiftCore.dylib; start crashing in Xcode 7

I have an existing iOS project written in Swift successfully running on iOS 8.4.1. I have compiled the project on Xcode 7 with some changes as per in Swift 2.0. It's running on Simulator. But when I start using device, Application start crashing at launch time
/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x1002C0000, size=0x00214000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/89E98704-14A2-4341-B0A9-61F9DD639100/....../Frameworks/libswiftCore.dylib.
I have tried all the suggestion from StackOverflow and other resources except Altering Apple Certificates.
Can anyone let me know what would be the issue and how can I overcome to this problem.
Thanks

iOS app crashes immediately when debugging AppleWatch app on Simulator (not on device)

I've got an AppleWatch app that is working fine in Simulator and Device, but when I call openParentApplication, it appears that the parent app is crashing immediately because I see this in the console output:
The UIApplicationDelegate in the iPhone App never called reply()...
When I try to manually launch the parent iOS app in the Simulator it crashes there too immediately. I don't have time to attach the debugger (which is already attached to the AppleWatch app) to see what is crashing it. Note that the parent app runs fine when the AppleWatch is running and I'm using a real iPhone. I can also run the app fine on the Simulator when not debugging the AppleWatch app.
I've tried resetting the Simulator, but problem persists.
I'm just not sure how to debug this. Any help is appreciated.
Start an explicit background task in handleWatchKitRequest. Otherwise, your app gets killed before it reaches reply().
Refer to this post for a code example on how to create a background task.
In turns out that after commenting out all code in the parent app's didFinishLaunching and stripping almost all code out of the watch extension, the problem was indeed at a lower level.
The Simulator has a
Debug | Open System Log...
menu option that showed the crash logs, which contained:
Dyld Error Message: Library not loaded:
#rpath/MyCore.framework/MyCore Referenced from:
/Users/me/Library/Developer/CoreSimulator/Devices/A2061705-DDDF-477C-9AAA-E50GG43A6350/data/Containers/Bundle/Application/DEB7FB25-8233-4B9F-8DAB-9FF8AE42BF33/MyApp.app/MyApp
Reason: no suitable image found. Did find:
/Users/me/Library/Developer/CoreSimulator/Devices/A2061705-DDDF-477C-9AAA-E50FF43A6350/data/Containers/Bundle/Application/DEB7FB25-8553-4B9F-8DAB-9FF8AE95BF33/MyApp.app/Frameworks/MyCore.framework/MyCore:
mach-o, but wrong architecture
My Swift app has a few dependent Swift projects that are used by the app and extension. Getting the Swift frameworks to link has been a major pain. I've included the dependent frameworks (compiled in the same workspace) as embedded binaries. This works when running on the device, or on the Simulator, but not when running in this hybrid watch app + parent app Simulator context.
I changed the embedded binary references to point to the frameworks under ...DerivedData...Debug-iphonesimulator, as opposed to ...DerivedData...Debug-iphoneos, and the problem went away.
Still hoping the Swift framework story will improve.
Are you seeing an actual crash? That message has appeared for me plenty of times without the host app crashing.
99% of the time, that error appears because developers aren't opening a background task to complete their work in handleWatchKitRequest. Without the background task, the OS kills your app in the background before it has a chance to reply.

Resources