ChatGPT解决这个技术问题 Extra ChatGPT

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).

You should've mentioned that you are using XCode 10 Beta. btw having the same issue
Are you trying to use AWS MobileHub?
Ran into this error in the debug console when running an instructor's key MVC design app. I am running Xcode 10 (not beta). Didn't get the error when running on actual device.
Having this issue after Xcode 10 update (not beta)
The problem appears to be related to the platform running in the simulator. I created an empty project, compiled, and ran on iPhone X, XR, XS, and XS-Max and there was no problem. Run it on anything prior to this, starting with 8 Plus, and the error occurs. Mac OS X: 10.13.6, Xcode: 10.0

E
Edison

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.


This seems like a logical reason for the problem. What did you end up doing to fix the issue?
As the very last sentence suggests. Make sure sim versions & Xcode versions are compatible or just use a real device.
You wrote 200 or so queries, but apparently there are 673 known obfuscated keys. [edit: oh well, your name is "tymac" and the blog is from "timac" ... probably not a coincidence]
A
Alessandro Ornano

I've successfully dropped it with the disabling of the project garbage.

Go to ->Scheme->Edit Scheme Then go to Run (menu to the left side) and add the following environment variable:

Name:OS_ACTIVITY_MODE, Value: disable

https://i.stack.imgur.com/QFuWn.png


It's working mate. Any explanation why is it working?
This isn't an answer, but it's related and important: stackoverflow.com/questions/52410471/…
I regret to mention that trying this approach, my simulator is not opening and no output at console.
This kind of commad drop certain debug messages, it's very useful and it's had nothing to do with the correct working of simulator and console: probably you have another issue that is not related with this argument.
I encountered the error as: libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform. For this when I tried the above approach, this didn't work. But when I just quit the simulator and clean my code, then it was working fine.
a
ankmara

in my case: check your app delegate for method - didFinishLaunching. I had private and get the error. After remove "private" everything works fine


Mine was not private.
m
mokagio

I just installed Xcode 10 Beta and had the same problem. Ran Xcode 9.4.1 and the problem went away.


This is not a viable answer IMO, especially now that xcode 10 is in the wild and still has this issue. The problem didn't "go away" on xcode 9.4.1 - it never existed to begin with. It's one thing to say "unfortunately this is an xcode 10 issue and we might have to be patient." It's another to ignore it altogether.
J
JhonnyTawk

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.


d
de.

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, opening an old project in Xcode 10.1, just hit 'Continue program execution' multiple times took me to actual issue at hand with solution here stackoverflow.com/a/12398777/4221299
B
Bharathram C

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.

https://i.stack.imgur.com/ZZcwI.png


Mine's set to 12.2 and the message is printed with the iPhone SE simulator but not with the iPhone XR one. So, at least for me, @anorskdev is right.
a
anorskdev

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.


This was the cause for me as well. I am not sure why this is an issue. My iPad is able to run iOS 12 so the sibling simulator should not be considered an unsupported device.
Same thing here (screen only got an InputField and a button). Xcode 10 with an iOS 12 project: Using the iPhone SE simulator logs this message but it doesn't show up with the iPhone XR.
N
Nuno Ferro

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


S
Strudel

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.


N
Nike Kov

The regular way when strange errors happens helped:

1) Clean project; 2) Shut down simulator; 3) Reinstall pods.

Xcode 10.


That worked for me as well. Thanks a lot. Users of iOS over 'nativescript' platform, you can do (1) Clean the project by deleting 'platforms/ios' folder, (2) Shutdown and reset the simulator by "Erase all content and settings", and (3) Rebuilt the project by runnings 'tns prepare ios --release' and then 'tns build ios --bundle'. Then, you can run the app in the simulator by opening the .xcworkspace file, choose a simulator and run the project from there. It worked perfectly for me.
P
PKCLsoft

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.


It's now called Device -> Erase All Content and Settings...
H
Harry McGovern

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.


Isn't that going to eat up a lot of memory?
R
RaulGM

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.


How did you fixed it? I was also having the same problem. But this only happens when running it on production in ionic and after that I got stuck in the splash screen loader
G
Gulfam Khan

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.


B
Bartosz Kunat

I got this error by calling .sync on the main queue which caused a deadlock (DispatchQueue.main.sync {}). I meant to call .async.


R
R. Mohan

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 :)


S
Sandip Moradiya

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.