Unit Test, access to privacy-sensitive data

Hello everyone,


I am testing my project with XCode, which has a CLLocationManager that updates location. I have added the "Privacy - always usage description" in the test and project info.plist file(both, main project one and unit test one) + Changed the info Target to add my TestUnit. But when I run the test here is the log :


2017-08-28 10:30:44.853 xctest[6485:63797] This app has attempted to access privacy-sensitive 
data without a usage description. The app's Info.plist must contain an NSLocationAlwaysUsageDescription 
key with a string value explaining to the user how the app uses this data


I wonder if anyone has ran into a same issue as mine, like accessing privacy-sensitive data in the Unit Test..


Thanks for your concern.

Replies

It sounds like you’re running your unit test standalone (the Xcode documentation calls this a library test) rather than hosted within an app (an app test). That’s what I generally do too, but it won’t work in this case. You will need to run the unit tests within an app that has

NSLocationAlwaysUsageDescription
set in its
Info.plist
. If you don’t have a suitable app lying around, you should create a new dummy app target for this.

Once you’ve decided on the app you want to test within, you can target that app via the Host Application popup in the General tab of the target editor of the test target.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"