我可以在不更改整个文件 structure/Xcode 项目的情况下更改 Cordova/iOS 应用程序的 "displayed name" 吗?
Can I change a Cordova/iOS app's "displayed name" without changing the entire file structure/Xcode project?
所以,我正在开发我的第一个 Cordova 应用程序,我有一个可能是典型的菜鸟问题...
我用这个命令创建了我的应用程序:
cordova create MyFirstApp com.[my_domain].myfirstapp MyFirstApp
我可以看到这在名为 MyFirstApp 的目录下创建了一个复杂的文件结构,一个名为 MyFirstApp.xcodeprojXcode 的项目,以及许多以 MyFirstApp 开头的文件(例如,MyFirstApp-Info.plist、MyFirstApp- Prefix.pch,等等)。
一切都很好。
但是,在完成开发后 - 我意识到我希望应用程序的名称 显示在用户的主屏幕上不同的东西(例如,"Cool App!")。
我可以只更改 "displayed name" 而不会弄乱目录结构和 Xcode 项目吗?
看起来 config.xml
中的 name
节点不会 这样做 - 这个值似乎控制的不仅仅是名称的显示方式。 (例如,如果我更改它,cordova build iOS
失败并且 Xcode 开始抱怨...)
编辑 MyFirstApp-Info.plist
中的 Bundle display name
个节点。
从您的 cordova 项目的顶层
导航
platforms/ios/[appname]/[appname]-Info.plist
里面
<dict>
标签
应该有这样的条目
<key>CFBundleDisplayName</key>
<string>[The current name]</string>
将此更改为
<key>CFBundleDisplayName</key>
<string>[The name you want]</string>
不要包含 [ ] ...它们仅用于演示
重建你的项目
您可以通过将以下内容添加到 Cordova 的 config.xml
来更改 *-Info.plist
文件中的 CFBundleDisplayName
<config-file parent="CFBundleDisplayName" platform="ios" target="*-Info.plist">
<string>My App</string>
</config-file>
您可以将短名称添加到应用程序 config.xml
中的 name
元素:
<widget ...>
<name short="HiCdv">HelloCordova</name>
</widget>
或者如果上述方法不起作用,您可以试试这个:
<platform name="ios">
<edit-config file="*-Info.plist" mode="merge" target="CFBundleDisplayName">
<string>Your Display Name</string>
</edit-config>
...
</platform>
将该代码放在 config.xml 文件中,以便名称在构建之间保持不变,这意味着您不需要每次都手动编辑。
这段代码适合我:(config.xml)
<platform name="ios">
...
<config-file parent="CFBundleDisplayName" platform="ios" target="*-Info.plist">
<string>Your Name</string>
</config-file>
</platform>
所以,我正在开发我的第一个 Cordova 应用程序,我有一个可能是典型的菜鸟问题...
我用这个命令创建了我的应用程序:
cordova create MyFirstApp com.[my_domain].myfirstapp MyFirstApp
我可以看到这在名为 MyFirstApp 的目录下创建了一个复杂的文件结构,一个名为 MyFirstApp.xcodeprojXcode 的项目,以及许多以 MyFirstApp 开头的文件(例如,MyFirstApp-Info.plist、MyFirstApp- Prefix.pch,等等)。
一切都很好。
但是,在完成开发后 - 我意识到我希望应用程序的名称 显示在用户的主屏幕上不同的东西(例如,"Cool App!")。
我可以只更改 "displayed name" 而不会弄乱目录结构和 Xcode 项目吗?
看起来 config.xml
中的 name
节点不会 这样做 - 这个值似乎控制的不仅仅是名称的显示方式。 (例如,如果我更改它,cordova build iOS
失败并且 Xcode 开始抱怨...)
编辑 MyFirstApp-Info.plist
中的 Bundle display name
个节点。
从您的 cordova 项目的顶层
导航
platforms/ios/[appname]/[appname]-Info.plist
里面
<dict>
标签
应该有这样的条目
<key>CFBundleDisplayName</key>
<string>[The current name]</string>
将此更改为
<key>CFBundleDisplayName</key>
<string>[The name you want]</string>
不要包含 [ ] ...它们仅用于演示
重建你的项目
您可以通过将以下内容添加到 Cordova 的 config.xml
*-Info.plist
文件中的 CFBundleDisplayName
<config-file parent="CFBundleDisplayName" platform="ios" target="*-Info.plist">
<string>My App</string>
</config-file>
您可以将短名称添加到应用程序 config.xml
中的 name
元素:
<widget ...>
<name short="HiCdv">HelloCordova</name>
</widget>
或者如果上述方法不起作用,您可以试试这个:
<platform name="ios">
<edit-config file="*-Info.plist" mode="merge" target="CFBundleDisplayName">
<string>Your Display Name</string>
</edit-config>
...
</platform>
将该代码放在 config.xml 文件中,以便名称在构建之间保持不变,这意味着您不需要每次都手动编辑。
这段代码适合我:(config.xml)
<platform name="ios">
...
<config-file parent="CFBundleDisplayName" platform="ios" target="*-Info.plist">
<string>Your Name</string>
</config-file>
</platform>