简体   繁体   English

在iOs 10中请求位置时应用崩溃

[英]App Crashes when requesting Location in iOs 10

In my application I use to get the location data and send it back to the server. 在我的应用程序中,我用于获取位置数据并将其发送回服务器。 the app worked pretty good in previous versions and it crashes in iOs 10. i'm using Xcode 8. the following message shows in the log. 该应用程序在以前的版本中运行良好,并且在iOs 10中崩溃。我使用的是Xcode8。以下消息显示在日志中。

Couldn't find the "com.apple.private.externalaccessory.showallaccessories" entitlement
[MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/delta/Library/Developer/CoreSimulator/Devices/EE3BD084-BA73-44F6-AD95-BE49BBE838AC/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
[MC] Reading from private effective user settings. 

so How can I fix this. 所以我该如何解决。

In iOS 10, If you want to access to private data, a significant change is that you must declare ahead of time or your App will crash. 在iOS 10中,如果要访问私有数据,则有一个重大变化,那就是必须提前声明,否则您的应用将崩溃。

If you are using any of the framework listed below 如果您使用下面列出的任何框架

Contacts, Calendar, Reminders, Photos, Bluetooth Sharing, Microphone, Camera, Location, Health, HomeKit, Media Library, Motion, CallKit, Speech Recognition, SiriKit 联系人,日历,提醒,照片,蓝牙共享,麦克风,相机,位置,健康状况,HomeKit,媒体库,动作,CallKit,语音识别,SiriKit

You have to declare the description in Info.plist 您必须在Info.plist中声明描述

Here is the full list of Info.plist keys which you have to declare for iOS10. 这是您必须为iOS10声明的Info.plist键的完整列表。

    <!-- Photo Library -->
    <key>NSPhotoLibraryUsageDescription</key>
    <string>$(PRODUCT_NAME) photo use</string>

    <!-- Camera -->
    <key>NSCameraUsageDescription</key>
    <string>$(PRODUCT_NAME) camera use</string>

    <!-- Microphone -->
    <key>NSMicrophoneUsageDescription</key>
    <string>$(PRODUCT_NAME) microphone use</string>

    <!-- Location -->
    <key>NSLocationUsageDescription</key>
    <string>$(PRODUCT_NAME) location use</string>

    <!-- Location When In Use -->
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>$(PRODUCT_NAME) location use</string>

    <!-- Location Always -->
    <key>NSLocationAlwaysUsageDescription</key>
    <string>$(PRODUCT_NAME) always uses location </string>

    <!-- Calendars -->
    <key>NSCalendarsUsageDescription</key>
    <string>$(PRODUCT_NAME) calendar events</string>

    <!-- Reminders -->
    <key>NSRemindersUsageDescription</key>
    <string>$(PRODUCT_NAME) reminder use</string>

    <!-- Contacts -->
    <key>NSContactsUsageDescription</key>
    <string>$(PRODUCT_NAME) contact use</string>

    <!-- Motion -->
    <key>NSMotionUsageDescription</key>
    <string>$(PRODUCT_NAME) motion use</string>

    <!-- Health Update -->
    <key>NSHealthUpdateUsageDescription</key>
    <string>$(PRODUCT_NAME) heath update use</string>

    <!-- Health Share -->
    <key>NSHealthShareUsageDescription</key>
    <string>$(PRODUCT_NAME) heath share use</string>

    <!-- Bluetooth Peripheral -->
    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>$(PRODUCT_NAME) Bluetooth Peripheral use</string>

    <!-- Media Library -->
    <key>NSAppleMusicUsageDescription</key>
    <string>$(PRODUCT_NAME) media library use</string>

    <!-- Siri -->
    <key>NSSiriUsageDescription</key>
    <string>$(PRODUCT_NAME) siri use</string>

    <!-- HomeKit -->
    <key>NSHomeKitUsageDescription</key>
    <string>$(PRODUCT_NAME) home kit use</string>

    <!-- SpeechRecognition -->
    <key>NSSpeechRecognitionUsageDescription</key>
    <string>$(PRODUCT_NAME) speech use</string>

    <!-- VideoSubscriber -->
    <key>NSVideoSubscriberAccountUsageDescription</key>
    <string>$(PRODUCT_NAME) tvProvider use</string>

Also

Apps that are able to communicate with an external accessory must declare the protocols they support in their Info.plist file. 能够与外部附件通信的应用程序必须在其Info.plist文件中声明其支持的协议。

To declare the protocols your app supports, you must include the UISupportedExternalAccessoryProtocols key in your app's Info.plist file. 要声明您的应用程序支持的协议,您必须在应用程序的Info.plist文件中包含UISupportedExternalAccessoryProtocols键。 This key contains an array of strings that identify the communications protocols that your app supports. 此项包含一个字符串数组,这些字符串标识应用程序支持的通信协议。

Hope it helps..!! 希望能帮助到你..!!

Goto app Info.Plist file and added the privacy key according to your requirement. 转到应用程序Info.Plist文件,并根据您的要求添加了隐私密钥。

Location : Key : Privacy - Location Always Usage Description 位置:密钥:隐私-位置始终使用说明
Value : $(PRODUCT_NAME) location use 值:$(PRODUCT_NAME)位置使用

Key : Privacy - Location When In Use Usage Description 密钥:隐私-使用时的位置用法说明
Value : $(PRODUCT_NAME) location use 值:$(PRODUCT_NAME)位置使用

If you added the above privacy keys and still crashing the app. 如果您添加了以上隐私密钥,但仍使应用程序崩溃。 Then enable the appropriate " Capabilities " 然后启用适当的“ 功能

Example : If you are using " Uses Bluettoth LE accessories " 示例 :如果您正在使用“ 使用Bluettoth LE附件

Project -> Capabilities -> Background Modes -> Uses Bluetooth LE accessories. 项目->功能->后台模式->使用Bluetooth LE配件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM