首页 > 解决方案 > iOS模拟器崩溃

问题描述

一旦我单击 Flutter ios 模拟器右上角的位置按钮,该应用程序就会自动关闭。

设备:iOS 模拟器(iPhone 11 Pro)。

这是终端上显示的内容。

Lost connection to device.
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff23e6aefe __exceptionPreprocess + 350
        1   libobjc.A.dylib                     0x00007fff515339b2 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff23e6ad3c +[NSException raise:format:] + 188
        3   location                            0x000000010384f88a -[LocationPlugin requestPermission] + 426
        4   location                            0x000000010384ef18 -[LocationPlugin handleMethodCall:result:] + 2072
        5   Flutter                             0x0000000101332b1f __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104
        6   Flutter                             0x00000001012c1762 _ZNK7flutter21PlatformMessageRouter21HandlePlatformMess<…&gt;

这是图像

标签: iosflutter

解决方案


崩溃说[LocationPlugin requestPermission],发生这种情况是因为您没有将位置权限添加到 info.plist。

要解决这个问题,您需要将位置权限添加到您的 info.plist

<key>NSLocationWhenInUseUsageDescription</key>
<string>When in use permissions</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>always permissions</string>
<key>NSLocationAlwaysAndWhenInUsageDescription</key>
<string>Always and in usage permissions</string>

推荐阅读