如何告诉 Xcode 我的 info.plist 和 .pch 文件在哪里

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4159090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:35:49  来源:igfitidea点击:

How to tell Xcode where my info.plist and .pch files are

xcode

提问by Andrew

I renamed my project and it's files and now Xcode is still looking for the old info.plist file. Where do I set the locations of the .plist and .pch files that it needs.

我重命名了我的项目及其文件,现在 Xcode 仍在寻找旧的 info.plist 文件。我在哪里设置它需要的 .plist 和 .pch 文件的位置。

In my Project Info window, under Packaging there's an item for Info.Plist file, but it was blank, and when I try different paths, nothing happens. On compile it still says it can't find the plist by the old name.

在我的项目信息窗口中,在打包下有一个 Info.Plist 文件项,但它是空白的,当我尝试不同的路径时,没有任何反应。在编译时它仍然说它找不到旧名称的 plist。

采纳答案by Andrew

Found it. It was in the settings for the Target.

找到了。它在目标的设置中。

  • Choose Target in the Groups and Files pane on the left.
  • Right-Click and choose Get Info
  • Search for "Info.Plist" and type in the filename for the correct plist file into the property of the item named "Info.Plist File".
  • Then search for "Prefix" and find the item named "Prefix Header".
  • Change it's property to the name of the correct .pch file that you are using.
  • 在左侧的组和文件窗格中选择目标。
  • 右键单击并选择获取信息
  • 搜索“Info.Plist”并在名为“Info.Plist File”的项目的属性中输入正确的 plist 文件的文件名。
  • 然后搜索“Prefix”并找到名为“Prefix Header”的项目。
  • 将其属性更改为您正在使用的正确 .pch 文件的名称。

I think these different "Info" windows are confusing. You have to make sure the right file is selected in the Groups and Files pane before selecting "Get Info", and it's hard to tell if what you're doing is actually making changes to the Info.plist file, or where your changes are being saved.

我认为这些不同的“信息”窗口令人困惑。在选择“获取信息”之前,您必须确保在“组和文件”窗格中选择了正确的文件,并且很难判断您正在做什么实际上是对 Info.plist 文件进行更改,或者您的更改在哪里被拯救。

回答by Serendipity

I know this answer is answered and closed, but I'm going to add my discoveries here as it is slightly different for Xcode 4.2:

我知道这个答案已被回答并关闭,但我将在这里添加我的发现,因为它与 Xcode 4.2 略有不同:

  • Select your project
  • In the left side of the middle pane, select your app under "Targets"
  • Select the tab "Build Settings"
  • Search the following keywords: "info.plist" and "pch"
  • At this point it should be pretty clear which are the ones you need to modify.
  • Click on "Validate Settings" and you're done.
  • 选择您的项目
  • 在中间窗格的左侧,在“目标”下选择您的应用
  • 选择选项卡“构建设置”
  • 搜索以下关键字:“info.plist”和“pch”
  • 此时应该很清楚哪些是您需要修改的。
  • 单击“验证设置”即可完成。

回答by CuriousMarc

One more wrinkle to this. It still would not find the new plist file because it was in a folder inside the main project hierarchy on my disk. In this case, the name you should put in the build settings is relative to the project file, like "FolderName/Info.plist" for example.

对此又多了一层皱纹。它仍然找不到新的 plist 文件,因为它位于我磁盘上主项目层次结构内的文件夹中。在这种情况下,您应该在构建设置中输入的名称与项目文件相关,例如“FolderName/Info.plist”。

回答by Bùi ??c Khánh

For Xcode 10.1 when rename or move info.plist to sub folder.

对于 Xcode 10.1,当重命名或移动 info.plist 到子文件夹时。

  • Select your project
  • Choose targets
  • In Generaltab under Indentityyou can specify new info.plist file
  • 选择您的项目
  • 选择目标
  • General选项卡下,Indentity您可以指定新的 info.plist 文件

回答by Nurtugan Nuraly

Just close project and reopen it. Then you will see on the project target, choose plistbutton on the Generaltab See this screenshot to make sense

只需关闭项目并重新打开它。然后您将在项目目标上看到,在常规选项卡上选择plist按钮查看此屏幕截图以使其有意义

回答by ltrainpr

I know this is an old post, but I just ran into this same problem using Xcode 8.2. I had already duplicated .plist and .storyboard files in finder, but my Xcode project did not pick them up. In order to add files to your xcodeproj just right click on the project or folder in the Project Navigator and select Add Files to "Your Project Name". You should be able to select the files you need (use Cmd key to select multiple individual files).

我知道这是一篇旧帖子,但我只是在使用 Xcode 8.2 时遇到了同样的问题。我已经在 finder 中复制了 .plist 和 .storyboard 文件,但是我的 Xcode 项目没有找到它们。为了将文件添加到您的 xcodeproj,只需右键单击项目导航器中的项目或文件夹,然后选择将文件添加到“您的项目名称”。您应该能够选择您需要的文件(使用 Cmd 键选择多个单独的文件)。

If you created a new .plist or .storyboard file you'll need to link to your target membership. To link just click on the file in the navigator and on the right hand side in your standard editor > file inspector > target membership select the appropriate target membership.

如果您创建了新的 .plist 或 .storyboard 文件,则需要链接到您的目标成员资格。要链接,只需单击导航器中的文件,然后在标准编辑器的右侧 > 文件检查器 > 目标成员资格选择适当的目标成员资格。

The correct way to do this without duplicating files in finder is by selecting the file to duplicate and then going to File > Duplicate on the Xcode navigation menu.

在 finder 中不复制文件的正确方法是选择要复制的文件,然后转到 Xcode 导航菜单上的 File > Duplicate。

回答by Vic W.

I am working with Xcode 9.3 and "boldly" changed my app name without understanding that I was inviting trouble: I got it.

我正在使用 Xcode 9.3,并且“大胆地”更改了我的应用程序名称,却没有意识到我在招惹麻烦:我明白了。

Fortunately, it is now easy to rename a project or app with reliableresults if in Xcode you select the blue icon on the left/in the project navigator and then edit the "Identity and Type" "Name" field in the "File Inspector". This brings up a dialog, and clicking on "Rename" works reliably.

幸运的是,如果在 Xcode 中选择左侧/项目导航器中的蓝色图标,然后编辑“文件检查器”中的“身份和类型”“名称”字段,则现在可以轻松地重命名具有可靠结果的项目或应用程序. 这会弹出一个对话框,单击“重命名”可以可靠地工作。