I have defined my Root.plist inside Setting bundle which appears in the device settings. Now, I want it to display different options based on the kind of environment I build the project on.
I have defined a TEST and PROD schemes (different build configuration) in XCode and I want Root.plist to be defined differently for these build configuration. How can this be done?
Can we have 2 plists defined and link them with different build configuration or can we modify the root.plist at the compile time based on the build configuration or scheme chosen.
Please advise.
A build configuration file is a plain-text file you use to specify the build settings for a specific target or your entire project. Build configuration files make it easier to manage build settings yourself, and to change build settings automatically for different architectures and platforms.
Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.
You can do this by importing it under your Project's Info tab, under Configurations. Save this answer. Show activity on this post. XCConfig files are certainly the way to go for sharing build settings across multiple targets or even projects.
I have worked it out this way:
1) Add 2 settings bundle (one for test and one for prod) to the project and add them to the target.
2) Add a Run script on the Runner target to selectively copy the required Settings bundle into the build file.
if [IS_PRODUCTION]; then
cp -r ${PROJECT_DIR}/Settings/Prod/Settings.bundle ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
fi
if [IS_TEST]; then
cp -r ${PROJECT_DIR}/Settings/Test/Settings.bundle ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
fi
3) Once done, just run on different schemes to see the desired results.
I do something similar to @Abhinav, but instead of using a run script, I just use the Target Membership section of the File inspector to determine which target uses which Settings.bundle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With