Crash on device using ad-hoc distribution - ios

Suddenly my ad-hoc distributions through Testflight and iTunes-sync no longer work. The application distributed using the ad-hoc build config never start fully on device. It crashes immediately with a segmentation fault 11.
The weird thing with this problem is that a debug build, on all the devices mentioned below, work flawlessly. This is causing me to believe that there is something messed up in my project.pbxproj. But when I look in the git-log I see nothing out of order, the only thing changed in there are the Architectures (ARCHS) and Valid Architectures (VALID_ARCHS).
Am I correct to assume that messing up the architectures should not cause an actual error on startup but during the build process?
Some Background:
Also worth mentioning is that I had both Xcode 4.4.1 and 4.5 GM installed, when I upgraded the GM to the one from App Store it removed my backup of Xcode 4.4.1 as well. After that hiccup I removed all version of Xcode, rebooted and installed version 4.4.1 again (this is so I can build for armv6).
Any helpful tips in how to proceed with this debugging is extremely valuable to me.
Thanks for your time.
<3
Console print and crash log from device:
- https://gist.github.com/3781018
I can add more logs if needed.
Current Environment:
- Xcode Version 4.4.1 (4F1003)
- Mac OS Version 10.8.2
Project Setup (pbxproj):
- https://gist.github.com/3780985
Devices tested:
- iPhone 3GS iOS 6
- iPhone 3G iOS 4.2.1
- iPad 2nd Gen iOS 5.1.1
- iPhone 4S iOS 5.1.1
- iPhone 4 iOS 6.0
- iPhone 4S iOS 6.0
Update
To proceed with the debugging this is what I tried:
1. Skip Testflight and use the old-school way of releasing an ad-hoc with iTunes. FAIL
2. Reinstalling the provisioning profiles FAIL
2. Create a new user on my machine an reinstall Xcode. FAIL
3. Build from another machine. FAIL
4. Set optimization level to: -O0 FAIL
Even though I was certain that none of the code had been changed, I saw no other reasonable explanation for this. So I started reverting the project in git, staring with the day I successfully made an ad-hoc release. To my horror I noticed that the same segmentation fault was following me through the fabric of time!
Considering this fact there was only one action left to take; a very powerful way of debugging I dubbed spray-and-pray. =) In other words I started to comment out sections of the code and see if that made any difference and to my complete surprise it actually did. After a few hours of disabling and enabling parts of my application I found the culprit: a static NSArray was never retained. What's really blowing my mind here is that the actual initialization of the array has been looking the same since 2010. So why on earth did this suddenly result in a memory error now? And why did the static analyzer not warn we about this?
I am too exhausted at the moment to answer those questions right now, I will try to update the question with more details and hopefully an answer as well tomorrow.
Once again, a big thank you for anyone who helped out so far! <3

It looks like the cause of the problem is the concurrency issue:
Crashed Thread: 1
In such a case it may be hard to find and resolve the root of the problem (http://en.wikipedia.org/wiki/Unusual_software_bug#Heisenbug).
May be you are doing something with one object from multiple threads without proper synchronization;
or may be you dealloc'ed object in one thread (ex. thread 0) and trying to access it from another (thread 1).

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.

Very weird issues with xcode 7 and cloudkit

I have an app using CloudKit. After upgrading to iOS 9 it continued to work as it did previously with no issues. However, a couple days ago, I upgraded from Xcode 6 to 7. Xcode 7 broke some things visually...alignments, collectionview cell edge insets were changed, etc...definitely annoying, but it's probably some autolayout issues I needed to fix anyway. The real issue is beyond anything I've ever seen before. All of the sudden, my CK data will not get returned unless I'm connected to wifi AND a power source. At first I thought it had to be connected to the laptop and running from Xcode to the device. I tested it by disconnecting from the laptop and plugging into the wall and CK data was returned and CV cells got rendered. And whether or not it's connected to a power source, if I'm on cellular connection I just get the spinner (data loading) and it just sits there. And if it's running from Xcode, I don't see any logging happening either. But if i switch to wifi even while the app is running, then I see the logging of the CK results returned followed by the custom cell views being trigged and finally the cells get rendered on the device.
Just to be clear, I didn't make any coding changes around this happening...just upgraded to Xcode 7 (not the GM version). I did notice the below difference in info.plist when comparing in source control.
xcode 7:
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
xcode 6:
CFBundleIdentifier
com.drivethruu.${PRODUCT_NAME:xxxxxxxxx}
I replaced the actual product name with the "xxxx..." just for this post in case it's something I shouldn't be showing publicly. I did use the xcode 6 value just to see if that was the issue and got the exact same behavior. Didn't make it worse, but didn't make it any better. Also, I've changed the deployment target to everything between iOS 7.1 - 9.0 and no differences.
Anyone experiencing anything like this? Any idea on how to solve this?
UPDATE: Downloaded Xcode 6.4, discarded changes in the storyboard and info.plist files and recompiled and all issues resolved, so it's definitely some issue with Xcode 7. Still running iOS 9...will need to find out why the issue is happening on with Xcode 7 since I'll need to have the app iOS 9 certified before submitting. May need to open a ticket with Apple.
Thank you!
Apple has changed the behavior of the qualityOfService setting and the way data is fetched. In my opinion this is a CloudKit bug. For more information see:
iOS 9 CloudKit: query does not return anything while connected to cellular network
Please also make a bug report of this at http://bugreport.apple.com

Xcode 6.0.1 - iOS Simulator Black Screen

I've seen lots of questions about this - however none of them are solving my issue.
The Setup is as follows
OSX Mavericks 10.9.5
Xcode 6.0.1
iOS Simulator 8.0 (550.1)
I've tried now with 5 different Xcode projects, that are working with another machine with identical setups, except this one isn't working.
Every time I launch the simulator, whether or not it's with an App running, or standalone I get the same.
When I run from Xcode I get this message ->
An error was encountered while running (Domain = com.apple.CoreSimulator.SimError, Code = 146)
The things I've tried are:
Reset all Content and Settings (when I click and confirm this - nothing happens at all)
Removed all devices from the simulators, and re-created them
Made sure everything is up to date
Cleaned all projects, SEVERAL times
Restarted machine inbetween doing everything under the sun
Deleted Derived Data
This has been happening for 3 days now.
Suggestions please!
This probably isn't the "official" answer, but my solution to solve this was literally bin xcode, empty trash, then reinstall from the App store.
This post on the Apple Developer Forums has a bunch of highly relevant information. It doesn't appear to directly address your issue, but try this:
Turn up debug logging for the Simulator:
defaults write com.apple.iphonesimulator DebugLogging -bool YES
defaults write com.apple.CoreSimulator DebugLogging -bool YES
Quit and relaunch the iOS Simulator.
Check ~/Library/Logs/CoreSimulator/*.log for more information.

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

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.

Log message referring to Gatekeeper appears occasionally when running simulator

I am developing an app for iPhone. Sometimes I get this log :
Named service 'com.apple.PersistentURLTranslator.Gatekeeper' not found. assetsd is down or misconfigured. Things will not work the way you expect them to.
Tue Oct 4 11:59:21 my-Mac-Pro.local[2958] : Named service 'com.apple.assetsd.changehub' not found. assetsd is down or misconfigured. Things will not work the way you expect them to.
It is happening when I present a modal UIImagePickerController, but not every time.
Has anybody got any ideas?
I agree with the other respondents that this is a bug.
In the mean time, a work-around is to quit the iOS Simulator and restart it. I've had to do this as I alternate testing between different devices.
Can you try the beta of Xcode 4.5 to see if this behavior exists ... If it does, I suggest filing Radars : https://bugreport.apple.com
The new os mountain lion has a feature called Gatekeeper that the service is trying to run through. What i have heard is that there are lots of bugs with Xcode and the new OS. My guess is that it is a bug and will probably be resolved once apple comes out with an update and many bug fixes.
Agree this is a bug. Relaunching simulator didn't work for me, but after I manually ran the app in question in simulator (as opposed to launching via 'Run' in Xcode) I was fine, and was subsequently able to use Run as normal.

Resources