<commit_before>---
layout: post
title: Configuration Resources
---

You can create different builds of your app for different purposes, for example: Test and Release. Release is your regular production version of the app but Test might include debug features.

To achieve this you will want to leverage configurations in Xcode to create variants of your app in addition to the default Debug and Release builds.
Build settings can be changed per configuration but resources can't - they are assigned to targets in the Xcode project.

So I wrote a *Build Phase Script* to add resources at build time. It chooses them by which configuration we build.
With this script configurations can produce builds with different bundled resources.
Some examples of what you can do with this is to include a `Settings.bundle` with dev switches or debug flags only in the Test version.
If you are creating seperate Beta and Release builds you can include correctly named App icon assets (Check your build product `.app`) and have different icon variations for the different builds too.

*Check out the full gist and you'll see I even wrote tests for it!*
<script src="https://gist.github.com/Ashton-W/a47ec8b128ecbe470632.js?file=CopyConfigurationResources.sh"></script>
<commit_msg>Configuration Resources rev4<commit_after>---
layout: post
title: Configuration Resources
---

You can create different configurations of your app for different purposes, for example: Test and Release. Release is your production configuration of the app, but Test might include debug features not meant for the AppStore.

To achieve this you will want to leverage configurations in Xcode to create variants of your app in addition to the default Debug and Release builds.
Build settings can be changed per configuration but resources can't - they are assigned to targets in the Xcode project.

So I wrote a *Build Phase Script* to add resources at build time. It chooses them by which configuration we build with.
With this script configurations can produce builds with different bundled resources.

Some examples of what you can do:

- Add a [`Settings.bundle`](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html) in the Test configuration with [Feature Toggles](https://en.wikipedia.org/wiki/Feature_toggle).
- Use unique App icon assets for Beta and Release builds so you can easily identify them on your iPhone (Check your built `.app` for the correct asset names).
- Include staging server certificates in the Test build of the app for SSL Pinning.

*Check out the full gist and you'll see I even wrote tests for it!*
<script src="https://gist.github.com/Ashton-W/a47ec8b128ecbe470632.js?file=CopyConfigurationResources.sh"></script>

Note that without editing it this script looks for directories like this:

    Resources/
    Resources-Beta/
    Resources-Debug/
    Resources-Release/
{'fraction_non_alphanumeric': 0.05443341321465252, 'fraction_numerical': 0.008558712769599451, 'mean_word_length': 4.619230769230769, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6324806', 'n_tokens_mistral': 714, 'n_tokens_neox': 678, 'n_words': 399}