dyld: Library not loaded: #rpath/libswift_stdlib_core.dylib when running on iPhone - ios

Update 2: This is an old question involving the developer beta of iOS 8 and Xcode. The problem was that the Swift standard library wasn't included in the iPhone 4s iOS 8 beta. The issue has been resolved in the release.
Update: I've been getting fed up with the errors and crashes that come along with beta software, so I decided to reset my phone to iOS 7.1.1 and now the error is gone... I have no idea what is going on, but I'm going to assume its a bug since iOS 8 is still in beta. I will file a bug report with Apple and hope it gets resolved with the next seed.
As many other people before me, I am receiving the following error message when running a swift-based app on my iPhone (4S running iOS 8.0 beta 1):
dyld: Library not loaded: #rpath/libswift_stdlib_core.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/
CDC7263B-9F18-4369-87CC-F36DB5163B99/TESTPROJECT.app/TESTPROJECT
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/
CDC7263B-9F18-4369-87CC-F36DB5163B99/TESTPROJECT.app/Frameworks/
libswift_stdlib_core.dylib: mmap() error 1 at address=0x00206000,
size=0x00128000 segment=__TEXT in Segment::map() mapping
/private/var/mobile/Containers/Bundle/Application/
CDC7263B-9F18-4369-87CC-F36DB5163B99/TESTPROJECT.app/Frameworks/
libswift_stdlib_core.dylib
When running on the iOS simulator (iPhone 4S), I get the following (many times):
SetAppThreadPriority: setpriority failed with error 45
- This is a new single view application project generated from the built-in templates with Xcode 6 beta, with none of my own code. (Also happens with an empty application)
- I have already tried the solution found here (restarting Xcode)
I can't seem to find any other way of moving/accessing the required swift library.

For me, quitting and relaunching Xcode made this go away.

I ran into the same problem and I think it maybe because the app has to be configured to dynamically load certain frameworks. In any case changing the "Runpath Search Paths" build setting to "#executable_path/Frameworks" seemed to fix the problem.
I'm guessing that Xcode sets this automatically for new projects but older projects may need to be fixed manually. In my older project it was blank.

I hit this problem in simulator. I tried some settings listed here http://ikevin.tw/?p=174.
In summary, Defines Module -> Yes, Embedded Content Contains Swift Code -> Yes, Product Module Name -> [My product name].
These changes managed to get me to launch and run.
The trick is that afterwards, I reverted the changes to see which of them actually made a difference. After reverting all of them, the app still launched. So it's completely unclear what actually caused the app to end up launching.

I'm guessing your iPhone 4S is lower than iOS 6. We also did regression tests on iPhone 4S's on iOS 6 and 7 but they were all fine. Devices on iOS 5 and 5.1 had the same error as you have though.

I had this issue using an Ad Hoc (or enterprise) mobileprovision with a production certificate. Switching to a development certificate and mobileprovision solved the issue.

99% of the time when you get an error like this when upgrading the beta, it's the cache in ~/Library/Caches/com.apple.dt.Xcode* directories. Delete these and rebuild.

I had the same issue on an exploratory project. When I tried to build on a device I got the error. All I had to do was set the 'Provisioning Profile' in 'Code Signing' and everything worked.

Related

Xcode Error on Simulator: MGIsDeviceOneOfType is not supported on this platform

I have a very simple application with a single view, containing several UILabels. Upon running in Simulator, the Xcode console returns the error:
libMobileGestalt MobileGestalt.c:875: MGIsDeviceOneOfType is not supported on this platform.
The Simulator itself just shows a white screen. I've also tried running it on a developer device with the same white screen. I've searched documentation but can't find any reference to MGIsDeviceOneOfType.
The application is written in Swift in Xcode 10 beta on macOS 10.14. I am attempting to run it on the iPhone 7-X Simulators, as well as a development iPhone 7, all running the target software (12.0).
MobileGestalt
The libMobileGestalt.dylib provides a central repository for all of the iOS's properties. It can be analogous to OS X's Gestalt, which is part of CoreServices. OS X's Gestalt is documented for example Gestalt Manager and has been deprecated as of 10.8. MobileGestalt is entirely undocumented by Apple as it is a private library.
MobileGestalt allows for the testing of system properties that may or may not be compatible on different simulators.
Quite a few system processes and apps in iOS rely on MobileGestalt, which is located at /usr/lib/libMobileGestalt.dylib. It's more of a basic library, but its exposed APIs follow the Apple framework conventions and uses the MG API prefix for example MGIsDeviceOneOfType.
If you look for MobileGestalt on the iOS filesystem you won't find it - like all private frameworks and libraries, it has been prelinked into the /System/Library/Caches/...etc. If you like hacking and pen-testing then you can use tools to extract it.
MobileGestalt provides plenty of information - around 200 or so queries - on various aspects of the system. Here are a few.
libMobileGestalt.dylib
//Answers to MG queries
MGCopyAnswer(#"5MSZn7w3nnJp22VbpqaxLQ");
MGCopyAnswer(#"7mV26K/1a+wTtqiunvHMUQ");
MGCopyAnswer(#"BasebandAPTimeSync");
MGCopyAnswer(#"BasebandPostponementStatus");
MGCopyAnswer(#"BasebandPostponementStatusBlob");
MGCopyAnswer(#"BasebandSecurityInfoBlob");
MGCopyAnswer(#"BasebandStatus");
MGCopyAnswer(#"BuildVersion");
MGCopyAnswer(#"CoreRoutineCapability");
MGCopyAnswer(#"DeviceClass");
MGCopyAnswer(#"DeviceClassNumber");
MGCopyAnswer(#"DeviceName");
MGCopyAnswer(#"DeviceSupports1080p");
MGCopyAnswer(#"DeviceSupports720p");
MGCopyAnswer(#"DiskUsage");
MGCopyAnswer(#"GSDeviceName");
MGCopyAnswer(#"HWModelStr");
MGCopyAnswer(#"HasBaseband");
MGCopyAnswer(#"InternalBuild");
MGCopyAnswer(#"InverseDeviceID");
MGCopyAnswer(#"IsSimulator");
MGCopyAnswer(#"MLBSerialNumber");
MGCopyAnswer(#"MaxH264PlaybackLevel");
MGCopyAnswer(#"MinimumSupportediTunesVersion");
MGCopyAnswer(#"PasswordConfigured");
MGCopyAnswer(#"PasswordProtected");
MGCopyAnswer(#"ProductType");
MGCopyAnswer(#"ProductVersion");
MGCopyAnswer(#"RegionCode");
MGCopyAnswer(#"RegionalBehaviorNTSC");
MGCopyAnswer(#"RegionalBehaviorNoPasscodeLocationTiles");
MGCopyAnswer(#"ReleaseType");
MGCopyAnswer(#"SIMStatus");
There are hundreds more e.g. AirplaneMode, MobileEquipmentIdentifier, etc.
MobileGestalt maintains a table of OSType selector codes.
for example c:890 in the message: libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform. In this case MGIsDeviceOneOfType is a method/property of the MobileGestalt library.
Instead of checking the simulator version there is a separate selector for directly querying the capabilities of the simulator. The messages most likely indicate incompatibilities between simulator versions and Xcode versions and/or unsupported APIs on the simulator.
I've successfully dropped it with the disabling of the project garbage.
Go to <Name of your Project>->Scheme->Edit Scheme Then go to Run (menu to the left side) and add the following environment variable:
Name:OS_ACTIVITY_MODE, Value: disable
in my case: check your app delegate for method - didFinishLaunching. I had private and get the error. After remove "private" everything works fine
I just installed Xcode 10 Beta and had the same problem. Ran Xcode 9.4.1 and the problem went away.
This error will only occur when testing/debugging on simulators.
The newer the simulator the better.
Case: I run simulator iPhone 8 plus I got this message in the debugger.
Solution: I changed to a newer simulator no error message in the debugger.
Ran into this when opening some project from GitHub on Xcode 10.0.
The pragmatic solution was: just hit 'Continue program execution' multiple times and probably disable your exception breakpoint. Apparently the exception was recoverable.
It's not a real solution but it was good enough for me at that point.
In my case, the Target's Deployment Target was at iOS 8. When I pushed it up to iOS 10.3, it ran fine, both on the Simulator and the device.
Am seeing this problem. Using Xcode 10.1. Created a brand new project - doesn't do anything except show a white screen. Discovered it was showing up on simulator for older devices. For example, iPad Pro (12.9 inch) and iPad Pro (12.9 inch) (2nd generation) show the problem, but problem is gone for iPad Pro (12.9 inch) (3rd generation). Does not show up for iPhone XR simulator.
Basically seems annoying.
If you have fonts provided by the app, you need to add to Info.plist
And check if the file have the Target Membership selected
I had the same issue, but with MapKit, where a MapView did not show up, just the white screen and the same error, MGIsDeviceOneOfType is not supported on this platform.
Solved it by fixing "Ambiguous layout" warnings tied to the MapView object. Now it's working perfectly fine, and the errors went away.
The regular way when strange errors happens helped:
1) Clean project;
2) Shut down simulator;
3) Reinstall pods.
Xcode 10.
For me, with the simulator in question in focus, I selected Hardware->Erase all content and settings.
After the simulator restarted, launching my app worked again, as expected.
I went to XCode -> Preferences -> Components
Ticked all the simulators and the check box to install updates automatically, and then "check and Install now" and went away for a few hours while they all updated.
Now the problem is gone - so in fact, it's as mentioned. New XCode with Old - non-updated simulators.
What worked for me was to change within general > Deployment Info > Main Interface to CDVLaunchScreen and do the same within general > App Icons and Launch Images > Launch Screen File to CDVLaunchScreen as well.
I come from Ionic, so this might not be a problem for those who develop in Swift / Objective-C.
I have recently updated to Xcode 10.2 and when I tried to run a project created in earlier version, Same error occurred.
The problem was that simulator was running before updating Xcode.
Solution was very simple for me to quit Simulator and restart so that it can get the new changes. I don't think the model of the simulator (iPhone SE or iPhone X) matters. You just need to restart your simulator for it to take effect of new update.
I would recommend to quit both Xcode and simulator and restart your Mac.
I got this error by calling .sync on the main queue which caused a deadlock (DispatchQueue.main.sync {}). I meant to call .async.
I got this error, when trying to read a json file which is inside my project and it returned nil, due to that i got this error.
I got nil because of some spelling mistake in the font name, that json file was holding the font names, after copy pasting the font name i got data and the error fixed.
I tried allmost all of the solutions given above, nothing worked, So debug with patience, you will get to know which is causing this error and in some bad time xcode will play in our life :)
I was facing same problem but I've successfully dropped it with below things:
Shutdown simulator,
Shutdown Xcode,
Re-open Xcode and simulator
I hope it will help.

Internal API error

Since few days, every time I try to run my app on my iPhone, I get get this error message "There was an internal API error".
I'm getting this error just with one application only on my iPhone. In fact, there's no problem with the same app on simulator or on my iPad. No problem too with other apps on my iPhone...
I've tried many things mentioned in those threads:
"There was an internal API error." while running an app on any iPhone/iPod-touch device
Xcode 4.4 - There was an internal API error
like remove/re-run the app, reboot iPhone/mac, clear cache, check plist, check profiles, check build settings, restore iPhone.
I'm using xCode 7.1.1 and iOS 7.1.2
Can someone point me on what I forget to check please ?
As per my work and research I got a solution. Since I was preparing the build in manual way from product. In that case my appname.app was copying in folder from which I have to create a build, that app was not copied properly and I prepared the build and installed in my device, in that case I got this error.
I again clean the Xcode prepare the build properly and installed it, it works.
When I rename my project and delete the special character "ç", xCode success to run the app on my iPhone. It might be related to xCode 7, before there was no problem for compiling.
I also had this problem. The way I solved it was by removing the special characters from the Product Name (in Build Settings) - I had an 'æ'. Indeed, it looks related to Xcode 7, because it used to work on previous versions of Xcode.

How to fix a broken iOS Simulator (The operation couldn’t be completed. LaunchServicesError error 0.)

When I try to run my project with my favorite simulators (iPhone 5s/8.4 and iPhone 5s/9.1) I get this error, and in syslog I see:
kernel[0]: AMFI: Simulator(pid 6881) - [deny-mmap] mapped file has no team identifier and is not a platform binary: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 7.1.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/host/liblaunch_sim.dylib
This started happening after I had built and run an xcodeproject downloaded from github. My main project had been working fine and when I switched back to it, I started getting this error.
Other simulators, such as iPhone 6/9.1, work OK.
Previously, when switching back and forth between my own project and examples projects from the internet, I have seen xcode pop up a provisioning error alert, offering to fix the problem, and when I click "Fix" I am able to continue with no issue. I'm an xcode newbie and all this is quite mystifying.
I have tried to "Reset Content and Settings" of the offending simulator, Quit the Simulator, quit xcode, and rebooted. I've checked my Provisioning Profiles in Preferences > Accounts and they look fine as far as I can tell.
Using the SimDir app I found the device directory for the simulator and dragged it to the trash. After that, the simulator worked for a little while then broke again.
I found this apple article but frankly I couldn't understand it (and I'm not running Swift. This is a react-native app.)
Oh one more thing. It's weird that the syslog message mentions iOS 7.1.simruntime when I'm using the 8.4 or 9.1 simulator. The project's deployment target is 7.0 but ???.
By the way I also tried cleaning my build folder (CMD-K) and anything else relevant in this SO question and this one.
UPDATE: Like a virus, the working simulator is now getting infected. The iPhone 6/9.1 simulator worked well for a while, but now keeps getting this error (which can be 'fixed' temporarily by Reset Content and Settings). It looks like my Provisioning Profile is OK in xcode because I can run on my iPhone, and when I build an Archive of the project and validate it with Apple it validates succesfully. It's just the simulators.
A good night's sleep resolved this issue! The next day I had the error pop up a couple of times but was resolved by "Reset Content and Settings". After that day the problem has not reappeared. I have no idea why I was seeing this... The only thing I can think of is that I might have had my own project and the example project from the web open in Xcode at the same time. You wouldn't think that should cause a problem but...
If it has an Apple Watch App bundled in you should use the bundle IDs correctly, like:
com.user.app
com.user.app.watchkitapp
com.user.app.watchkitapp.watchkitextension

Xcode 6.01 Archive validation error: Invalid Segment Alignment

I have been working on an iOS project solely in Xcode. Deployment target is iOS 8.0. After updating to Xcode 6.x, building and testing on my iPhone 5s and iPhone 6 as well as the simulators works fine. However, when I create an archive and want to validate it, I get the following error:
Archive validation failed due to the issues listed below.
iTunes Store operation failed.
Invalid Segment Alignment. This app does not have proper segment alignment and should be rebuilt with the latest version of Xcode. Please contact Developer Technical Support if you need further assistance.
I have googled for the past couple of days and it seems that this problem mostly occurs in connection with other development tools, especially from Adobe. However, I have only used Xcode for development.
This is what I have tried so far:
Reinstalling Xcode 6.01
Turning Autolayout on and off
Set target from 8.0 to 7.1
Just submit the archive (no error message, but new version is not found in Testflight)
Unfortunately, none of this has worked. My questions:
What does the error message want to tell me?
Has anyone any idea how to solve this problem?
Thanks a lot!
I found the solution. XCode seems to have lost track of two of my files (XX.h and XX.c) This file name (with a .o extension) was in the summary of the 1st step of the validation.
I removed the references to both files, added them again and everything works fine. Hope that helps someone!
(Edit: sorry, cannot flag this answer as the right answer, will do so in two days when stackoverflow lets me)
More detailed instructions:
When pressing "Validate" in the Organizer, look at the "Summary" dialog that pops up
If there are any .o files listed in addition to your app, go back to Xcode and remove the corresponding .h AND .m files from your project (removing the reference is sufficient)
Re-add them by dragging and dropping them back into your project
Recompile and it should work (assuming you're not using Adobe Air components in your app)
(thanks a million for this post Fynh, your fix made it finally work for me!)
In my case I was submitting an app that include a framework I had built that was a universal framework - created using lipo (for use with both device and simulator).
After replacing the universal compiled framework with device compiled framework, validation was successful.
To fix this bug I had to go Targets / Build Phases / Expand Copy Bundle Resources and remove the empty.cpp file (my error was about a empty.o file)
Hope this helps someone

Xcode 6 GM won't compile for iOS device, but is fine in simulator - odd error message

I have a project that compiled just fine in XCode 6 beta, but now, in the GM, it won't compile for an iOS device, giving the error:
myController.m:393:9: No visible #interface for 'UIDevice' declares the selector 'initialize:'
at this line:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
It still compiles absolutely fine for the simulators; I've also tried these fixes:
Cleaned the whole project and re-built.
Deleted all Derived Data from ~/Library/Developer/XCode
Re-installed XCode
Checked XCode preferences and pointed Command Line Tools location to XCode 6 (XCode 5 is still installed on the machine and it was pointing there)
...but with no luck. Same error on compilation.
Help! We're on a tight timescale with iOS8 now approaching, and this is a real headache.
PS: We're also using Cocoapods in the workspace, for what it's worth.
OK, I solved this one after rather a lot of hair-pulling. The app in question is an iOS 8 app, with an embedded Today Extension.
It turned out that, when adding the Today Extension, XCode had added a build setting:
'Enable Modules (C and Objective-C': YES
Neither my project nor my containing app targets used this build setting, but setting it to YES caused issues to do with trying to link Frameworks automatically (and failing) and all sorts of related odd error messages that ultimately related to header files.
The problem was further compounded because there are source files that are members of both the containing app's target and also the Today Extension's target.
Hope this info helps somebody else.
Carl

Resources