Giter Site home page Giter Site logo

xcodeenvironments's Introduction

Xcode environments

Example project for setting up different environments in Xcode with configurations & schemes. This allows us to easily switch between environments and create builds.

Setup

  1. Rename the existing configurations from Debug & Release to Debug Dev & Release Dev. These will be the debug configurations.
  2. Duplicate the debug configuration twice and create Debug Stag & Debug Prod. Do the same thing again for Release Stag & Release Prod. Configurations
  3. Add a User defined setting, called BASE_URL, and set the values for each configuration. User defined setting
  4. Open the Info.plist and add a key called BaseUrl with the value $(BASE_URL). This will allow us to read the value of the user defined setting from the app Bundle. Info.plist
  5. Rename the current scheme from the app name to Dev, and create two new schemes Stag & Prod. Make sure all the schemes are Shared so they get commited to source control and are shared between all devs. Rename schemes
  6. Edit each scheme and set the correct Build Configuration for each step. Run, Test & Analyze should have the Debug configurations, Profile and Archive Release. Dev scheme Stag scheme Prod scheme
  7. After this is done we can read the baseUrl value in the app code from the main bundle info dictionary.

Example

Access the baseUrl from code

if let info = Bundle.main.infoDictionary, let baseUrl = info["BaseUrl"] as? String {
  print(baseUrl)
}

Options

There are a lot of options that can be different between app environments

  • Different bundle ids can be set for different environments. This will allow us to have multiple versions of the app installed side by side on the same device. The issue with this approach is that we will not be able to distribute dev & stag builds to testers via Testflight since an app on AppStore connect is tied to a specific bundle id
  • Different app names or icons are a great name to easily distinguish which version we have installed.
  • Preprocessor macros can be used to toggle parts of the code for each environment.

xcodeenvironments's People

Contributors

andrejkolar avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.