Defining a preset based on assembly configuration

I defined my Root.plist inside the settings set that appears in the device settings. Now I want it to display different parameters based on the environment in which I built the project.

I defined TEST and PROD schemes (a different build configuration) in Xcode, and I want Root.plist to be defined differently for this build configuration. How can I do that?

Can we define 2 layers and associate them with a different assembly configuration or can we change root.plist at compile time based on the selected assembly configuration or schema.

Please inform.

+7
source share
5 answers

I worked like this:

1) Add 2 sets of parameters to the project (one for the test and one for prod) and add them to the target.

2) Add a Run script to the Runner target to selectively copy the required set of settings to 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) After that, just run on different diagrams to see the desired results.

+9
source

I am doing something similar to @Abhinav, but instead of using a space script, I just use the Target Membership section of the File Inspector to determine which target is using which Settings.bundle.

Settings Bundle Target Membership

+9
source

I used the @abhinav approach, but slightly modified it to fit my project needs. We have two goals: BUT , both of them are used to create separate applications.

Steps

In the file system in the project directory, create a folder structure:

 <project_folder>/Settings/debug <project_folder>/Settings/production 

In the project, create the following groups:

 Settings debug production 

Create Settings.bundle , add it to the debug group and save it to the debug folder. (do not add it to any target)

Edit .plist so that you like the page with the widest options (usually Debug collections have more options).

Copy the package from the debug folder to the production folder

Add Settings.bundle from the production folder to the production group in the project (do not add it to any target), so you have this structure

project group structure

Make sure none Settings.bundle added to any target

Remove installation items from .plist that you do not want to send using the App Store build.

Add Launch Script Phase After Resources Copy Resources

 if [ "${CONFIGURATION}" = "Release" ]; then cp -r ${PROJECT_DIR}/Settings/production/Settings.bundle "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app" fi if [ "${CONFIGURATION}" = "Debug" ]; then cp -r ${PROJECT_DIR}/Settings/debug/Settings.bundle "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app" fi 

Note. I have two build schemes: Release and Debug. I enclosed the path in quotation marks because my target has a name with spaces.

+3
source

The only way to conditionally link elements such as a set of settings in different assemblies is to duplicate your goal. Just add the correct set to the desired target and save all the code. It is different, but in the long run it should work much better.

+1
source

Simple approach:

1 - Create another target with a copy of the existing target; 2 - In the new phase of creating the target elif [$ {CONFIGURATION} == "Release"]; then cp -r $ {PROJECT_DIR} /Settings/ReleaseHHAppStore/Settings.bundle $ {BUILT_PRODUCTS_DIR} / $ {PRODUCT_NAME} .app c

this will allow you to make another custom setup if required

0
source

All Articles