개발/swift

Swift How to set build environment?

lemonade 2020. 10. 25. 10:00
반응형

How to set build environment?

 

Sometimes we have to maintain different environments like staging, production.

For that, we may have different app icons, server URLs, bundle display name, bundle identifier, license key for each environment.

 

This can be done by either of these.

1. To create multiple targets
2. Using multiple Info.plist

3. Use boolean values to check different conditions 

 

Today, we'll talk about third option!

 

You can use boolean value to check environment like this.

 


Xcode set DEBUG options when scheme is debug.

 

You can change environment by edit scheme.

 

 

It's easy to change environment And no need to worry when archive.

 

You can see environment set release on archive!

 

But much better, you can use same variable by using user defined setting.

 

 

 

For example of add env_url value.

 

You can set user defined settings in target - build settings.

 

Add value by clicking + button (next to all, combined on top) and choosing “Add User-Defined Setting”.

 


And then set value in .plist too.

 

 

Noted, you can get info.plist dictionary like this.

 


Thanks.

Happy Codding :)

 

반응형
그리드형

'개발 > swift' 카테고리의 다른 글

Swift How to manage keyboard with UIScrollView?  (0) 2020.10.29
Swift How to save data? Userdefaults  (0) 2020.10.28
Swift UILabel linke break mode  (0) 2020.10.22
Swift divide result 0 issue  (0) 2020.10.20
Swift property observer  (0) 2020.10.20