简体   繁体   中英

How to create a multiple choice key-value in info.plist

I would like to be able to achieve this:

在此处输入图片说明

Basically, if you want to choose another Country for the setting "Localization native development region" you juste have to go the right, of the row, click on the up/down arrow icon and you will be able to choose another option, like this:

在此处输入图片说明

This is what I'm trying to do. I would like a Key called "Environnement" with two possible values: "Dev" and "Production". Seriously i can't find the documentation to achieve this..

Thanks you guys ..

That is a special picker for some of the default iOS settings, which means that you won't be able to do what you are trying.

I think you want to use this new setting in your plist to for example call a development API instance instead of the production one.

You may want to create separate Targets to manage the different environments that you have, right now is Dev and Prod but you may run into a Stage or Test environment in the future. With a separate target not only you can identify which environment but also change the app's bundle identifier to install both versions on the same device and change the app name to do MyApp DEV , MyApp TST and MyApp for production. It will give you a better version control.

Once you have created a target for your dev environment you will need to add a C flag to identify each one of them.

Dev Flag: 开发环境

Prod Flag: 产品环境

Then declare your constants for what your specific use case like:

/* 0 = dev  1 = test 2 = prod */
#ifdef PROD
#define BASE_URL @"https://api.mydomain.com/"
#define ENVIRONMENT 2

#elif TEST

#define BASE_URL @"https://api-test.mydomain.com/"
#define ENVIRONMENT 1

#else

#define BASE_URL @"https://api-dev.mydomain.com/"
#define ENVIRONMENT 0

#endif 

And you should be ready to go to manage different environments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM