簡體   English   中英

在iOs 10中請求位置時應用崩潰

[英]App Crashes when requesting Location in iOs 10

在我的應用程序中,我用於獲取位置數據並將其發送回服務器。 該應用程序在以前的版本中運行良好,並且在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. 

所以我該如何解決。

在iOS 10中,如果要訪問私有數據,則有一個重大變化,那就是必須提前聲明,否則您的應用將崩潰。

如果您使用下面列出的任何框架

聯系人,日歷,提醒,照片,藍牙共享,麥克風,相機,位置,健康狀況,HomeKit,媒體庫,動作,CallKit,語音識別,SiriKit

您必須在Info.plist中聲明描述

這是您必須為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>

能夠與外部附件通信的應用程序必須在其Info.plist文件中聲明其支持的協議。

要聲明您的應用程序支持的協議,您必須在應用程序的Info.plist文件中包含UISupportedExternalAccessoryProtocols鍵。 此項包含一個字符串數組,這些字符串標識應用程序支持的通信協議。

希望能幫助到你..!!

轉到應用程序Info.Plist文件,並根據您的要求添加了隱私密鑰。

位置:密鑰:隱私-位置始終使用說明
值:$(PRODUCT_NAME)位置使用

密鑰:隱私-使用時的位置用法說明
值:$(PRODUCT_NAME)位置使用

如果您添加了以上隱私密鑰,但仍使應用程序崩潰。 然后啟用適當的“ 功能

示例 :如果您正在使用“ 使用Bluettoth LE附件

項目->功能->后台模式->使用Bluetooth LE配件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM