Xcode 13 中的 Info.plist 在哪里?(丢失,不在项目导航器内)

人气:137 发布:2022-10-16 标签: xcode swiftui swift xcode13

问题描述

有没有人想出如何在 Xcode 13 的 Info.plist 中添加/编辑值?我看到他们从导航器窗格中移动了 Info.plist...但是虽然我可以找到它,但我不知道如何编辑它.

解决方案

这是一个功能".

你不再需要它了.来自

第一次添加/编辑时,Xcode 会自动生成一个新的 Info.plist 文件,该文件与 1 同步>自定义 iOS 目标属性.Xcode 稍后会为您合并它们.

[1]:它们没有完全同步.一些属性如 NSCameraUsageDescription 只会出现在自定义 iOS 目标属性中,而 Application requires iPhone environment 会出现在两者中.我不知道 Xcode 如何确定这一点.

想要完全返回 Info.plist 吗?

您可能希望将应用的所有属性集中在一处.或者您可能不信任 Xcode 进行合并.我在 WWDC21 上与一位 Apple 工程师讨论了这个问题……这里是如何恢复经典的 Info.plist.

创建一个新的属性列表"文件(文件 -> 新建 -> 文件)

将其命名为Info.plist

复制并粘贴 Project -> 中的现有值目标 ->信息 ->自定义 iOS 目标属性Info.plist.

复制粘贴

注意:目前您一次只能选择和复制 1 行.如果您想节省一些时间,这里是 XML 格式的

在此处粘贴路径:

项目 ->目标 ->构建设置 ->Info.plist 文件

Generate Info.plist File设置为No

最后一步.从 Copy Bundle Resources 中删除 Info.plist(选择,然后按 - 按钮).

项目 ->目标 ->构建阶段 ->复制捆绑资源

是的,太多了.但是,您是否想要经典的 Info.plist 取决于您 - 两者都很好并且不会改变您的应用.

Has anyone figured out how to add/edit values in the Info.plist of Xcode 13 yet? I see they moved the Info.plist from the navigator pane... but although I can find it, I'm not sure how to edit it.

解决方案

It's a "feature."

You don't need it anymore. From the Release Notes:

Projects created from several templates no longer require configuration files such as entitlements and Info.plist files. Configure common fields in the target’s Info tab, and build settings in the project editor. These files are added to the project when additional fields are used. (68254857)

So, instead of inside Info.plist, edit properties like NSCameraUsageDescription here:

Project -> Targets -> Info -> Custom iOS Target Properties

The first time you add/edit, Xcode will automatically generate a new Info.plist file that’s kind of synced1 with Custom iOS Target Properties. Xcode will later merge them for you.

[1]: They’re not fully synced. Some properties like NSCameraUsageDescription will only appear in Custom iOS Target Properties, while Application requires iPhone environment will appear in both. I have no idea how Xcode determines this.

Want Info.plist back, completely?

You might want all of your app's properties in one place. Or maybe you don't trust Xcode with the merging. I spoke with an Apple engineer at WWDC21 about this... here's how to get the classic Info.plist back.

Create a new "Property List" file (File -> New -> File)

Name it Info.plist

Copy and paste the existing values from Project -> Targets -> Info -> Custom iOS Target Properties to Info.plist.

Copy Paste

Note: Currently you can only select and copy 1 row at a time. If you want to save some time, here are the default contents in XML format. To use this, right-click Info.plist -> Open As -> Source Code, then paste.

Copy the path to Info.plist in the attributes inspector.

Paste the path here:

Project -> Targets -> Build Settings -> Info.plist File

Set Generate Info.plist File to No

Last step. Remove Info.plist from Copy Bundle Resources (select, then press the - button).

Project -> Targets -> Build Phases -> Copy Bundle Resources

Yep, that was a lot. But whether you want classic Info.plist or not is up to you — both are fine and won't change your app.

897