“This app has attempted to access privacy-sensitive data without a usage description” error handling

(error handling, info plist, location)

取得手機座標時,需要在plist文件中定義

Privacy — Location When In Use Usage Description

但若出現下圖之訊息

This app has attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain both “NSLocationAlwaysAndWhenInUseUsageDescription” and “NSLocationWhenInUseUsageDescription” keys with string values explaining to the user how the app uses this data

可參考本文設定權限

使用Source Code開啟plist檔案
(右鍵 -> Open As -> Source Code)

增加 “NSLocationAlwaysAndWhenInUseUsageDescription”

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>
取得現在位置以便呈現資訊</string>
<key>
NSLocationWhenInUseUsageDescription</key>
<string>
取得現在位置以便呈現資訊</string>

執行後,會先詢問取得位置之權限

--

--

--

學習 Swift iOS App 開發的學生作品集

Recommended from Medium

Guidelines, Roadmap and Resources for beginner to advanced iOS app development using Swift

Laptop running Xcode

Dependency Injection in Swift

Concurrency in iOS

MFMailComposeViewController behaves differently in iOS 13 simulator

SwiftUI — Sidebar Menu Tutorial

Day 4: 20 days of learning challenge

UIResponder with DiffableDataSource part 2

How to Swipe CarouselView with Xamarin.UITest

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Peggy Tsai 

Peggy Tsai 

iOS & Golang 隨手記 www.linkedin.com/in/peggytsaifc 歡迎+Linkedin交流~

More from Medium

What are the components of a URL? Why things should be encoded? What does it look likes in Swift?

WebRTC in a Nutshell (Ep-III)

Left Rotation HackerRank Swift Solution

Split mirror photo effect for iOS