Xcode 中缺少 C++ 命令行工具应用程序的 info.plist 文件 [英] Missing info.plist file for C++ command line tool application within Xcode

查看:22
本文介绍了Xcode 中缺少 C++ 命令行工具应用程序的 info.plist 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 opencv 为大学课程创建一个相机校准应用程序.我在 macOS High Sierra 上创建了一个命令行工具应用程序.不幸的是它没有 info.plist 文件.我的应用程序崩溃并显示以下错误消息:

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] 此应用程序崩溃,因为它试图在没有使用说明的情况下访问隐私敏感数据.应用程序的 Info.plist 必须包含一个 NSCameraUsageDescription 键和一个字符串值,向用户解释应用程序如何使用这些数据.程序以退出代码结束:9

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

我已经尝试添加 info.plist 文件并在应用程序的常规选项卡中设置它.我还添加了 NSCameraUsageDescription 键和字符串.不幸的是,由于完全相同的错误,我的应用程序不断崩溃.

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.

推荐答案

您可以通过设置 Create Info.plist Section in Binary 在二进制文件中嵌入 Info.plist并在 Xcode > 中设置您的 Info.plist 文件的路径目标 >构建设置 >包装(粗体标记的变化):

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):

您的 Info.plist 可能如下所示:

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>

注意:在 Xcode (11.2.1/Catalina 10.15.1) 中的调试器中运行时,我仍然遇到隐私异常,但是 plist 嵌入在二进制.我想这是一个 Xcode 错误.将 Info.plist 放入 Products 目录可以解决这个问题,尽管每次修改二进制文件时您似乎都必须重新授权麦克风/相机的使用.

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.

这篇关于Xcode 中缺少 C++ 命令行工具应用程序的 info.plist 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆