美文网首页归藏
XCode 新建 Command Line Tool 模板,访问

XCode 新建 Command Line Tool 模板,访问

作者: 半城coding | 来源:发表于2020-08-26 15:51 被阅读0次

场景

今天一个做 c++ 开发的同事给我贴了个 error info,咨询我怎么处理

A334C3458419C2AAA9F144E99AEBAACE.jpg
我一看错误就告诉他在 info.plist 文件里面添加key 为NSCameraUsageDescription vaule 随便写的一个键值对。
然后同事回复给我说『我的工程里面没有 info.plist』文件 !!!。
我跑过去一瞅 还真没有 Info.plist 文件

解决方法

1、在项目中新建一个 Info.plist 文件,


3C6BA35CA75ACB3CE5B564A985FF6A30.jpg

2、在 Info.plist 文件中添加 权限文案 key - value

<?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>

3、设置 build Settings


B207D3DC5A69408F822D365ED2EA132A.jpg

4、添加脚本将 Info.plist 文件 在 build 期间 copy 到 Products 目录

AE1BD8BE2F180A56D5CBAA3E9E2EB22C.jpg
cp -rf ${SRCROOT}/${TARGET_NAME}/Info.plist  ${BUILD_ROOT}/Debug

注意: Debug 模式 copy 到 Debug 文件下。 Release 模式 需要拷贝到 Release 文件夹下

相关文章

网友评论

    本文标题:XCode 新建 Command Line Tool 模板,访问

    本文链接:https://www.haomeiwen.com/subject/npxfsktx.html