ios 模拟器上的 Xcode 错误:此平台不支持 MGIsDeviceOneOfType
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50701321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode Error on Simulator: MGIsDeviceOneOfType is not supported on this platform
提问by Woodman
I have a very simple application with a single view, containing several UILabels. Upon running in Simulator, the Xcode console returns the error:
我有一个非常简单的应用程序,只有一个视图,其中包含多个 UILabel。在模拟器中运行时,Xcode 控制台返回错误:
libMobileGestalt MobileGestalt.c:875: MGIsDeviceOneOfType is not supported on this platform.
libMobileGestalt MobileGestalt.c:875:此平台不支持 MGIsDeviceOneOfType。
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).
模拟器本身只显示一个白屏。我还尝试在具有相同白屏的开发人员设备上运行它。我搜索了文档,但找不到任何对MGIsDeviceOneOfType
. 该应用程序是在 macOS 10.14 上的 Xcode 10 beta 中用 Swift 编写的。我试图在 iPhone 7-X Simulators 以及开发 iPhone 7 上运行它,所有这些都运行目标软件 (12.0)。
回答by Edison
MobileGestalt
移动格式塔
The libMobileGestalt.dylibprovides 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 Managerand has been deprecated as of 10.8. MobileGestaltis entirely undocumented by Apple as it is a private library.
该libMobileGestalt.dylib为所有iOS的属性的中央存储库。它可以类似于 OS X 的格式塔,它是CoreServices
. OS X 的格式塔已记录在案,例如格式塔管理器,并已从 10.8 开始弃用。MobileGestalt完全没有被 Apple 记录,因为它是一个私人图书馆。
MobileGestalt allows for the testing of system properties that may or may not be compatible on different simulators.
MobileGestalt 允许测试在不同模拟器上可能兼容或不兼容的系统属性。
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
.
iOS 中相当多的系统进程和应用程序依赖于 MobileGestalt,它位于 /usr/lib/libMobileGestalt.dylib。它更像是一个基本库,但其公开的 API 遵循 Apple 框架约定并使用MG
API 前缀,例如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.
如果您在 iOS 文件系统上寻找 MobileGestalt,您将找不到它 - 与所有私有框架和库一样,它已预先链接到 /System/Library/Caches/... 等。如果你喜欢黑客和渗透测试,那么你可以使用工具来提取它。
MobileGestalt provides plenty of information - around 200 or so queries - on various aspects of the system. Here are a few.
MobileGestalt 提供了大量关于系统各个方面的信息——大约 200 个左右的查询。这里有一些。
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.
有数百例如AirplaneMode
,MobileEquipmentIdentifier
等等。
MobileGestalt maintains a table of OSType selector codes.
for example c:890in the message: libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.In this case MGIsDeviceOneOfType
is a method of the MobileGestalt library.
MobileGestalt 维护一个 OSType 选择器代码表。例如消息中的c:890:libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType 在此平台上不受支持。在这种情况下MGIsDeviceOneOfType
是MobileGestalt 库的一个方法。
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.
有一个单独的选择器可以直接查询模拟器的功能,而不是检查模拟器版本。这些消息很可能表明模拟器版本与 Xcode 版本和/或模拟器上不受支持的 API 之间不兼容。
回答by Alessandro Ornano
I've successfully dropped it with the disabling of the project garbage.
我已经通过禁用项目垃圾成功删除了它。
Go to <Name of your Project>->Scheme->Edit SchemeThen go to Run(menu to the left side) and add the following environment variable:
转到 < Name of your Project> ->Scheme-> Edit Scheme然后转到Run(左侧的菜单)并添加以下环境变量:
Name:OS_ACTIVITY_MODE, Value: disable
名称:OS_ACTIVITY_MODE,值:禁用
回答by tjmister
I just installed Xcode 10 Beta and had the same problem. Ran Xcode 9.4.1 and the problem went away.
我刚刚安装了 Xcode 10 Beta 并遇到了同样的问题。运行 Xcode 9.4.1,问题就消失了。
回答by ankmara
in my case: check your app delegate for method - didFinishLaunching. I had private and get the error. After remove "private" everything works fine
就我而言:检查您的应用程序委托的方法 - didFinishLaunching。我有私人并得到错误。删除“私人”后一切正常
回答by 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.
案例:我运行模拟器 iPhone 8 并且在调试器中收到此消息。
Solution:I changed to a newer simulator no error message in the debugger.
解决方案:我改用较新的模拟器,调试器中没有错误消息。
回答by de.
Ran into this when opening some project from GitHub on Xcode 10.0.
在 Xcode 10.0 上从 GitHub 打开某个项目时遇到了这个问题。
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.
这不是一个真正的解决方案,但当时对我来说已经足够了。
回答by Bharathram C
回答by 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.
我看到这个问题。使用 Xcode 10.1。创建了一个全新的项目 - 除了显示白屏之外什么都不做。发现它出现在旧设备的模拟器上。例如,iPad Pro(12.9 英寸)和 iPad Pro(12.9 英寸)(第 2 代)出现问题,而 iPad Pro(12.9 英寸)(第 3 代)则问题消失。iPhone XR 模拟器不显示。
Basically seems annoying.
基本上看起来很烦人。
回答by 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
如果您有应用程序提供的字体,则需要添加到 Info.plist 并检查文件是否选择了 Target Membership
回答by 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.
模拟器重新启动后,按预期再次启动我的应用程序。