Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing info.plist file for C++ command line tool application within Xcode

I want to create a camera calibration application with opencv for a university course. I have created a command line tool application on macOS High Sierra. Unfortunately it came without an info.plist file. My application crashes with the following error message:

CameraCalibration[2314:193066] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data. Program ended with exit code: 9

I have already tried adding a info.plist file and setting it in the applications' General tab. I have also added the NSCameraUsageDescription key and string. Unfortunately my application keeps on crashing due to the exact same error.

like image 805
CoderOfTheForce Avatar asked Apr 04 '19 14:04

CoderOfTheForce


1 Answers

You can embed an Info.plist in your binary by setting Create Info.plist Section in Binary and setting a path to your Info.plist file in Xcode > Target > Build Settings > Packaging (changes marked in bold):

Xcode target Info.plist settings

Your Info.plist might look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleIdentifier</key>
    <string>com.mycorp.myapp</string>
    <key>CFBundleName</key>
    <string>My App</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>record from the microphone</string>
    <key>NSCameraUsageDescription</key>
    <string>record from the camera</string>
</dict>
</plist>

N.B: when running in the debugger in Xcode (11.2.1/Catalina 10.15.1) I still get a privacy exception, however the plist is embedded in the binary. I guess this is an Xcode bug. Dropping an Info.plist into the Products directory works around this, although you seem to have to re-authorise microphone/camera usage every time the binary is modified.

like image 193
Rhythmic Fistman Avatar answered Nov 13 '22 22:11

Rhythmic Fistman