Samantha Withanage Samantha Withanage - 3 days ago 5
iOS Question

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.

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.

Answer

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.

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

You have to declare the description in Info.plist

Here is the full list of Info.plist keys which you have to declare for iOS10.

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

To declare the protocols your app supports, you must include the UISupportedExternalAccessoryProtocols key in your app’s Info.plist file. This key contains an array of strings that identify the communications protocols that your app supports.

Hope it helps..!!

Comments