IOS packaged test Release environment configuration-Previous article __ios

Source: Internet
Author: User
Tags configuration settings
Requirement Typing

The development of iOS project, sometimes due to the needs of the project, often have a test environment, release environment, enterprise environment, such as configuration of different environments.
This in the code there will be a lot of if-else judgment processing logic, and often because the project emergency line caused a parameter forgot to modify configuration, resulting in production accidents, this problem has been more puzzling developers, resulting in the development of the program is not strong. Solution

It is found that Apple provides a unified configuration scheme for different environments, and here is a demo I wrote to configure different development environments. 1 First create a single View application, generate a PCH file, and configure the PCH file path in build setting, my project configuration path is $ (srcroot)/autobuildconfigset-demo/ AUTOBUILDCONFIGSET-DEMO.PCH

2 Add configuration Settings file name to Enterprise

3 Repeat step 2 to create the file structure as follows

4 Add Enterprise compilation mode to configurations under Project

5 Setting the Compile mode corresponds to the configuration settings file we created, as shown in the following figure

6 under Targets search macros the following figure

7 Add the set compilation parameters to the corresponding mode.

Debug_version=1
enterprise_version=1
release_version=1

Used to determine the schema of various compiled macros in a PCH file, as shown in the following figure 7,8,9

8 PCH folder to add the following content

Test environment
#ifdef debug_version

#define BASE_URL_STR @ "http://www.baidu.com/"


//Enterprise Environment
#elif defined ( enterprise_version)
#define BASE_URL_STR @ "http://www.google.com/"



//appstore environment
#elif defined (release _version)
#define BASE_URL_STR @ "http://www.sina.com/"

9 Add print log as follows

10 The compilation mode of the compiled schema is adjusted to Enterprise mode

11 View Print Log

IOS Packaged test release environment configuration - medium
IOS Packaged test release environment configuration - Next

GitHub Demo link address welcome star, a lot of encouragement

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.