如何在 Xcode 5 中更改应用程序的包标识符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19501393/
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
How to change the bundle identifier of an app in Xcode 5?
提问by openfrog
Xcode 5 won't let me change the bundle identifier. The app name portion after com.mycompany.
is greyed out.
Xcode 5 不允许我更改包标识符。后面的应用程序名称部分com.mycompany.
变灰。
I created a bundle identifier in ITC which slightly differs and I want to use this new bundle identifier.
我在 ITC 中创建了一个稍有不同的包标识符,我想使用这个新的包标识符。
Do I have to create a new Xcode project with the correct identifier?
我是否必须使用正确的标识符创建一个新的 Xcode 项目?
回答by Idan
Actually this is pretty simple:
其实这很简单:
- Select your target
- Select 'info' tab (you can do the same by finding the plist file on the project)
- Search for "Bundle Identifier" key, The value on your end should be
com.mycompany.${PRODUCT_NAME:rfc1034identifier}
.
- 选择你的目标
- 选择“信息”选项卡(您可以通过在项目中找到 plist 文件来执行相同的操作)
- 搜索“Bundle Identifier”键,你端的值应该是
com.mycompany.${PRODUCT_NAME:rfc1034identifier}
。
If you want to change the grey field just replace the "com.mycompany" with whatever you want. the other field is the "Product Name" (which is read dynamically from the relevant key), You can change it by set the "Product Name" key on "Build Settings". You can also do it pretty ugly and change all the bundle identifier to whatever you want but I don't recommend that because if you would add more targets it would be static and harder to maintain.
如果您想更改灰色字段,只需将“com.mycompany”替换为您想要的任何内容。另一个字段是“产品名称”(从相关键动态读取),您可以通过在“构建设置”上设置“产品名称”键来更改它。您也可以将所有的包标识符更改为您想要的任何内容,但我不建议这样做,因为如果您添加更多目标,它将是静态的并且更难维护。
回答by Artyom
- Select your target under the Targetssection.
- Go to the Build Settingstab.
- Scroll down to Packaging.
- Change the Product Nameto the desired one.
- 在“目标”部分下选择您的目标。
- 转到“构建设置”选项卡。
- 向下滚动到包装。
- 将产品名称更改为所需的名称。
回答by sam
In Xcode 5.1.1, you can do it by simply renaming your Target. Double-click on the Target name to change it.
在 Xcode 5.1.1 中,您可以通过简单地重命名 Target 来实现。双击目标名称进行更改。
回答by Timur Kuchkarov
In your projects Info.plist(or in Info tab of project setiings, which is the same) change ${PRODUCT_NAME:rfc1034identifier}
to desired name. After that it wouldn't be greyed out.
在您的项目 Info.plist(或在项目设置的 Info 选项卡中,这是相同的)更改${PRODUCT_NAME:rfc1034identifier}
为所需的名称。之后就不会变灰了。
回答by ushika
I had to do this for my project too and found it easily done in Xcode 5.1.1 by just renaming the project name in the Navigator and allow Xcode to find all the strings you need to change automatically. Just make sure you check-in or create a snapshot of your project first.
我也必须为我的项目执行此操作,并且发现它在 Xcode 5.1.1 中只需在导航器中重命名项目名称即可轻松完成,并允许 Xcode 找到您需要自动更改的所有字符串。只需确保首先签入或创建项目的快照。
回答by 1owk3y
Your bundle identifier is based on PRODUCT_NAME.
您的捆绑标识符基于 PRODUCT_NAME。
By default, PRODUCT_NAME is based on TARGET_NAME, which is quite difficult to change (XCode6 at time of writing). So don't be afraid to impose a different name here if necessary.
默认情况下,PRODUCT_NAME 基于 TARGET_NAME,这很难更改(撰写本文时为 XCode6)。因此,如有必要,请不要害怕在此处强加不同的名称。