问题
I have three configurations in my iOS project:
- Debug
- Adhoc
- Release
Now I want to change the name of the App as follows:
- MyAppDebug
- MyAppAdhoc
- MyApp (Note that this one does not have a suffix)
Is there a way I can easily achieve this in Xcode with some type of "compiler-if-else-macro-thing"?
回答1:
Changing display name of app for respective configurations: one way to achieve this is by using the same info plist file that you have.
Part 1: create an user defined variable
- Click on target project file.
- Then at bottom right corner locate button "+" Add Build Setting.
- Click that button "Add Build Setting" and select "Add User-Defined Setting" enter name for New Setting as for ex: "BUNDLE_DISPLAY_NAME".
- Expand this new setting to see the configurations under it. Give the desired name to be displayed for each configuration. For ex: Debug -> MyAppDebug
Part 2: use it
- Select your appname-info.plist file.
- Locate key "Bundle Display Name" and value to it should be this new user defined variable ${BUNDLE_DISPLAY_NAME}
Then for appropriate configuration it will select name from BUNDLE_DISPLAY_NAME variable in build settings.
回答2:
Sure. First you have to create separate Info.plist file each configuration. Then in you Project's build settings find the line where Info.plist is placed, expand that line and choose separate Info.plist file for each configuration you have. Then you can enter desired name in corresponding field in each Info.plist file. That's it :)
回答3:
Also you can have two different info plist for different configurations which is different files and then from Build Settings > Info.plist File
section you can change it.
来源:https://stackoverflow.com/questions/8971488/configuration-dependent-value-in-info-plist-file