我可以在不更改整个文件结构/Xcode 项目的情况下更改 Cordova/iOS 应用程序的“显示名称”吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28373464/
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
Can I change a Cordova/iOS app's "displayed name" without changing the entire file structure/Xcode project?
提问by mattstuehler
So, I working on my first Cordova app, and I've got a probably typical noob question...
所以,我在开发我的第一个 Cordova 应用程序,我有一个可能是典型的菜鸟问题......
I created my app with this command:
我用这个命令创建了我的应用程序:
cordova create MyFirstApp com.[my_domain].myfirstapp MyFirstApp
I can see that this creates a complex file structure under a directory named MyFirstApp, an Xcode project named MyFirstApp.xcodeproj, and dozens of files beginning with MyFirstApp(e.g., MyFirstApp-Info.plist, MyFirstApp-Prefix.pch, etc).
我可以看到,这个名为目录下创建一个复杂的文件结构MyFirstApp,名为Xcode项目MyFirstApp.xcodeproj,和几十间开头的文件的MyFirstApp(例如,MyFirstApp-Info.plist中,MyFirstApp-Prefix.pch等)。
All of that is fine.
所有这些都很好。
But, after finishing development - I realize that I'd like the app's name as it appears on the user's homescreento be something different (E.g., "Cool App!").
但是,在完成开发后 - 我意识到我希望用户主屏幕上显示的应用程序名称有所不同(例如,“酷应用程序!”)。
Can I change just the "displayed name" without making a mess of the directory structure and Xcode project?
我可以只更改“显示名称”而不会弄乱目录结构和 Xcode 项目吗?
It looks like the name
node in config.xml
doesn'tdo this - that value seems to control much more than just the way the name is displayed. (E.g., if I change it, cordova build iOS
fails and Xcode starts complaining...)
看起来name
节点config.xml
不这样做 - 该值似乎控制的不仅仅是名称的显示方式。(例如,如果我更改它,则会cordova build iOS
失败并且 Xcode 开始抱怨......)
采纳答案by Marcus Adams
Edit Bundle display name
node in MyFirstApp-Info.plist
.
中的编辑Bundle display name
节点MyFirstApp-Info.plist
。
回答by Sean Lynch
You can change CFBundleDisplayName
in your *-Info.plist
file by adding the following to Cordova's config.xml
您可以通过将以下内容添加到 Cordova来更改CFBundleDisplayName
您的*-Info.plist
文件config.xml
<config-file parent="CFBundleDisplayName" platform="ios" target="*-Info.plist">
<string>My App</string>
</config-file>
回答by Simon L. Brazell
You can add a short name to the name
element in the config.xml
of your app:
您可以为应用程序中的name
元素添加一个短名称config.xml
:
<widget ...>
<name short="HiCdv">HelloCordova</name>
</widget>
Or if the above doesn't work, you can try this instead:
或者,如果上述方法不起作用,您可以尝试以下方法:
<platform name="ios">
<edit-config file="*-Info.plist" mode="merge" target="CFBundleDisplayName">
<string>Your Display Name</string>
</edit-config>
...
</platform>
Place that code in the config.xml file for the name to persist between builds meaning you don't need to manually edit every time.
将该代码放在 config.xml 文件中,以便在构建之间保留该名称,这意味着您无需每次都手动编辑。
回答by Benjamin Conant
From the top level of your cordova project
navigate to
platforms/ios/[appname]/[appname]-Info.plist
从cordova 项目的顶层导航到
platforms/ios/[appname]/[appname]-Info.plist
inside of the
<dict>
tag
there should be an entry like so
<dict>
标签内部
应该有一个像这样的条目
<key>CFBundleDisplayName</key>
<string>[The current name]</string>
change this to
将此更改为
<key>CFBundleDisplayName</key>
<string>[The name you want]</string>
DO NOT include the [ ] ... they are just for demonstration
请勿包含 [ ] ... 它们仅用于演示
rebuild your project
重建你的项目