<commit_before>iOS Command-line Deploy
=======================

This Bash script will compile your iOS app, and copy (SCP) it to a configured server.

Please note, this script suits a very subjective build/release process that might not suit your project / organisation.

Assumptions
-----------
The following assumptions are made. Other scenarios may well be supported, but they have not been tested.

* Project name is a single word, lower-case. E.g. `myproject`
* Workspace name, if using a workspace, rather than a single project, is similarly named
* The target is of the same name as the project/workspace (which is the default in xCode)
* You are using xCode v6.1.x

Requirements
------------
* OS X, with standard developer tools install (xCode, PERL)
* The *Term::Key* perl module. Install with `sudo cpan Term::Key`

Installation
------------
1. Make sure the `deploy.pl` script is copied to the root level of your project/workspace. I.e. the folder that contains your `.xcproject` file (which is really a directory).
1. Edit the script and change the configuration parameters at the top of the file to suit your needs. See the *Configuration* notes below.
1. If using xCode 6.1 see the *ResourceRules.plist* common problem section below, and add the build parameter.
1. Set up Keychain access for your signing key (so this command line script can access the signing key).
	* Open the `Keychain Access` app (use Sherlock to search for it)
	* Under the *login* keychain (top-left), search for the signing private key. It can be quite tricky to find. Also, note you can not use the search box, you have to navigate to the key. Searching for it, and selecting it won't allow you to change it (a *Keychain Access* bug). The signing key will be named like "iOS Distribution: My Company Inc." and it will have a *kind* of `private key` not `public key`)
	* Double-click the matching private key to reveal its properties.
	* Click the *Access Control* tab, select the option `Allow all applications access this item`, and save.

Configuration
-------------
Use the following configuration parameters (at the top of the script) to suit your project:

* **projectSlug** The xCode project name (try and keep it lower-case and without spacing/punctuation). I.e. if this is a value of `mypoject`, then the folder `myproject.xcodeprj` should exist in the same folder as this build script. The generated `.ipa` file will be called after this slug as well.
* **isWorkspace** If set to 1, the entire workspace will be built (not just an individual project). The workspace needs to be called the same as *projectSlug* above.
* **identity** The name of the signing identity. This is the official name on the iTunes Connect / developer account. You'll see it under xCode's Preferences > Accounts. For individual accounts, it's normally just the developer's name (e.g. "<NAME>"). For company accounts, it's normally the full legal name "My Company Inc."
* **config** The build configuration to use. Normally, this will be `Release` (the xCode default)
* **scpDestWithChangelog** If this is set, the final application (and optional changelog) will be copied here (using `scp`). The string should be of the form `user@host:/path/to/distrib`. E.g. `myuser@/var/www/mysite/iosapp/`. If you don't want to copy the changelog, use *scpDestWithoutChangelog*; both are optional.
* **scpDestWithoutChangelog** If this is set, the final application will be copied here (using `scp`). The string should be of the form `user@host:/path/to/distrib`. E.g. `myuser@/var/www/mysite/iosapp/`.
* **bundleID** The Bundle Identifier name for this app (you can get that from iTunes Connect, or from xCode under your targets > General tab)
* **displayName** The user-friendly name to call the app (used in the Ad-hoc download confirmation prompt)
* **sslURLBase** The URL to use (SSL is now a requirement for Ad-hoc distribution) where the user will be directed to when downloading. The generated app name will be appended to this URL, so make sure it has a trailing slash!

Common Problems
---------------
ResourceRules.plist: cannot read resources
__________________________________________
This happens in xCode 6.1 (looks like a bug) and affects all command-line building (such as servers / continuous integration). To resolve, in xCode, navigate to your project > *Targets*. Select your target and go to the *Build Settings* tab. Search for *Code Signing Resource Rules Path* and add the following value (for all, or just for *Release* configuration):

	$(SDKROOT)/ResourceRules.plist

User interaction is not allowed
_______________________________
You need to follow the Keychain Access step in the installation steps above.<commit_msg>Update usage instructions<commit_after>iOS Command-line Deploy
=======================

This Bash script will compile your iOS app, sign it, generate a `.plist` file suitable for Ad-hoc distribution, and copy (SCP) it to configured destinations.

Please note, this script suits a very subjective build/release process that might not suit your project / organisation.

Assumptions
-----------
The following assumptions are made. Other scenarios may well be supported, but they have not been tested.

* Project name is a single word, lower-case. E.g. `myproject`
* Workspace name, if using a workspace, rather than a single project, is similarly named
* The target is of the same name as the project/workspace (which is the default in xCode)
* You are using xCode v6.1.x

Requirements
------------
* OS X, with standard developer tools install (xCode, PERL)
* The *Term::Key* perl module. Install with `sudo cpan Term::Key`

Installation
------------
1. Make sure the `deploy.pl` script is copied to the root level of your project/workspace. I.e. the folder that contains your `.xcproject` file (which is really a directory).
1. Edit the script and change the configuration parameters at the top of the file to suit your needs. See the *Configuration* notes below.
1. If using xCode 6.1 see the *ResourceRules.plist* common problem section below, and add the build parameter.
1. Set up Keychain access for your signing key (so this command line script can access the signing key).
	* Open the `Keychain Access` app (use Sherlock to search for it)
	* Under the *login* keychain (top-left), search for the signing private key. It can be quite tricky to find. Also, note you can not use the search box, you have to navigate to the key. Searching for it, and selecting it won't allow you to change it (a *Keychain Access* bug). The signing key will be named like "iOS Distribution: My Company Inc." and it will have a *kind* of `private key` not `public key`)
	* Double-click the matching private key to reveal its properties.
	* Click the *Access Control* tab, select the option `Allow all applications access this item`, and save.
1. Copy the Provisioning Profile you want to use (e.g. one you created for Ad-hoc distribution) to the root level directory. Make sure it is the **only** `.mobileprovision` file in the directory.

Configuration
-------------
Use the following configuration parameters (at the top of the script) to suit your project:

* **projectSlug** The xCode project name (try and keep it lower-case and without spacing/punctuation). I.e. if this is a value of `mypoject`, then the folder `myproject.xcodeprj` should exist in the same folder as this build script. The generated `.ipa` file will be called after this slug as well.
* **isWorkspace** If set to 1, the entire workspace will be built (not just an individual project). The workspace needs to be called the same as *projectSlug* above.
* **identity** The name of the signing identity. This is the official name on the iTunes Connect / developer account. You'll see it under xCode's Preferences > Accounts. For individual accounts, it's normally just the developer's name (e.g. "<NAME>"). For company accounts, it's normally the full legal name "My Company Inc."
* **config** The build configuration to use. Normally, this will be `Release` (the xCode default)
* **scpDestWithChangelog** If this is set, the final application (and optional changelog) will be copied here (using `scp`). The string should be of the form `user@host:/path/to/distrib`. E.g. `myuser@/var/www/mysite/iosapp/`. If you don't want to copy the changelog, use *scpDestWithoutChangelog*; both are optional.
* **scpDestWithoutChangelog** If this is set, the final application will be copied here (using `scp`). The string should be of the form `user@host:/path/to/distrib`. E.g. `myuser@/var/www/mysite/iosapp/`.
* **bundleID** The Bundle Identifier name for this app (you can get that from iTunes Connect, or from xCode under your targets > General tab)
* **displayName** The user-friendly name to call the app (used in the Ad-hoc download confirmation prompt)
* **sslURLBase** The URL to use (SSL is now a requirement for Ad-hoc distribution) where the user will be directed to when downloading. The generated app name will be appended to this URL, so make sure it has a trailing slash!
* **changelogPath** The relative path to the changelog to copy alongside the app, if any. It is optional. If not specified (an empty string), then the app is still copied to both *scpDestWithChangelog* and *scpDestWithoutChangelog* destinations, if configured. The changelog, regardless of local name, is copied to the destination as projectslug_changelog.txt

Usage
-----
The script takes one or two arguments. The first argument, required, is the version number (which should match your bundle number in xCode) and should only contain numbers and a period/full stop (e.g. 1.0.31).

Optionally, you can run the script with a second argument, `nobuild`, to not build/sign the app, and just **scp** it to the configured destinations. It assumes the app built previously by this script still remains in the current directory.

Common Problems
---------------
ResourceRules.plist: cannot read resources
__________________________________________
This happens in xCode 6.1 (looks like a bug) and affects all command-line building (such as servers / continuous integration). To resolve, in xCode, navigate to your project > *Targets*. Select your target and go to the *Build Settings* tab. Search for *Code Signing Resource Rules Path* and add the following value (for all, or just for *Release* configuration):

	$(SDKROOT)/ResourceRules.plist

User interaction is not allowed
_______________________________
You need to follow the Keychain Access step in the installation steps above.
{'fraction_non_alphanumeric': 0.08646902318510072, 'fraction_numerical': 0.002565564424173318, 'mean_word_length': 4.236318407960199, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5636871', 'n_tokens_mistral': 2743, 'n_tokens_neox': 2657, 'n_words': 1552}