iOS

Using .xcconfig Files

Using .xcconfig Files

.xcconfig files are extra files that help you configure a particular build type. These files can be readily edited outside of Xcode. They're just plain text files that define and override the build parameters for a project or target's specific build configuration. They make build parameters easier to read, despite having highly precise formatting rules. Furthermore, they can be used as a blueprint for future initiatives. There's less chance of human error and less fiddling with Xcode's Build Settings tab.

Configurations

A project can have numerous setups in Xcode. A new Xcode project will come with two options by default: Debug and Release. These two combinations may be sufficient in some cases.

However, this is not always the case in my experience. We'll define three settings for this walkthrough: Development, Staging, and Production. Each of these will have its configuration, debugging, and release steps. Let's get started on these right away in this iOS Tutorial.

Select the project file in the Navigation Area (the top-most file). Then, from the Editor Area, make sure the project and the Info tab are selected. Examine the Configurations section.

It's simple to create a new setup. Create the following with three environments, each having a Debug and Release configuration:

  • Debug (Development)
  • Debug (Staging)
  • Debug (Production)
  • Release (Development)
  • Release (Staging)
  • Release (Production)

Duplicate the "Debug" Configuration by selecting the icon at the bottom of the Configurations section.

Repeat this process, renaming the current Configurations, until you have the following:

Schemes

An Xcode scheme specifies a set of options to utilise during development and tests to run, and targets to create. By default, Xcode projects have one scheme, which is called after the project. The scheme selection in the toolbar allows you to access different schemes.

We'll have a plan per environment for this project. Let's get started on the other two.

Go to the Scheme selector in the Xcode toolbar. Select Manage Schemes from the Scheme pop-up menu.


In the Scheme Manager, you can see a listing of the project's schemes, as well as the location they're in and whether or not they're shared. To open the settings pop-up, click the gear at the bottom of the current arrangement. The duplicate should be selected.

The Development scheme will be the one you come up with. Ascertain that the right configuration is in place for each action, as follows:

Create a new scheme for staging and double-check that the right configurations are in place.

Finally, double-check that the default scheme is utilising Production settings, and make sure they're all designated as Shared, so they're not just for your Xcode environment but the entire project. If this box is not ticked, others who open this project will be unable to use these schemes. When you're finished, you should have something like this:

Top course recommendations for you

    OOPs in Java
    2 hrs
    Beginner
    100.4K+ Learners
    4.43  (4497)
    Building Games using JavaScript
    2 hrs
    Beginner
    29.5K+ Learners
    4.47  (420)
    Introduction to DevOps
    3 hrs
    Beginner
    54.9K+ Learners
    4.58  (2414)
    Introduction To AngularJS
    2 hrs
    Beginner
    22.8K+ Learners
    4.54  (865)
    Introduction to JavaScript
    3 hrs
    Beginner
    87.5K+ Learners
    4.45  (3789)
    Data Structure & Algorithms in Java for Intermediate Level
    4 hrs
    Intermediate
    14.4K+ Learners
    4.48  (1984)
    Building Games using Java
    2 hrs
    Beginner
    26K+ Learners
    4.28  (152)
    Algorithms in C
    3 hrs
    Beginner
    26.3K+ Learners
    4.44  (580)
    Angular7 for Beginners
    3 hrs
    Beginner
    19.1K+ Learners
    4.54  (651)
    Angular7 for Intermediate Level
    3 hrs
    Intermediate
    8.5K+ Learners
    4.59  (215)