Skip to content

Ruby lib and scripts to manage Apple development (provisioning profiles, certificates, pbxproject, etc). Former iOSProvisioningProfiles.

License

Notifications You must be signed in to change notification settings

ScoutHarris/apple-dev

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apple::Dev

This is a set of scripts written in Ruby used to manage provisioning profiles and certificates either locally or through the Apple Developer Center (ADC).

The project also contains a few scripts related to managing the provisioning profiles in Xcode.

They are used in continuous integration environments (for example Jenkins) to update, compile & validate iOS or Unity3d projects.

Required dependencies

To manipulate provisioning profiles, you will need plist and json to access the Apple development center site, you will need mechanize >= 2.2 and encrypted_strings.

mobileprovisioning.rb

$ wget http://www.apple.com/appleca/AppleIncRootCertificate.cer
$ ruby ./mobileprovisioning.rb 65RAGE----.mobileprovision -c AppleIncRootCertificate.cer -d -O plist.xml
$ tail plist.xml
    <string>D7NQRKKW84</string>
    </array>
    <key>TimeToLive</key>
    <integer>340</integer>
    <key>UUID</key>
    <string>A7D868EA-B1F3-4280-BD01-464653A-----</string>
    <key>Version</key>
    <integer>1</integer>
  </dict>
</plist>
$ ruby ./mobileprovisioning.rb 65RAGE----.mobileprovision -c AppleIncRootCertificate.cer -d UUID
A7D868EA-B1F3-4280-BD01-464653A-----
$ ruby ./mobileprovisioning.rb 65RAGE----.mobileprovision -c AppleIncRootCertificate.cer -t
distribution
$ ruby ./mobileprovisioning.rb 65RAGE----.mobileprovision -c AppleIncRootCertificate.cer -d Name
TestFlight WWTK All Projects

apple_dev_center.rb

$ ./apple_dev_center.rb -u [email protected] -p xxxxxxx -d devcenter -O devcenter/site.json
$ ls devcenter/
A7D868EA-B1F3-4280-BD01-464653A-----.mobileprovision site.json DL29------.cer
$ prettyprint devcenter/site.json
{
    "certificates":[
        {
    	    "name":"XXXXXXXXXXXXXX",
    	    "displayId":"DL29------",
    	    "profile":"TestFlight XXXX All Projects",
    	    "type":"distribution",
    	    "status":"Issued",
    	    "exp_date":"Jan 22, 2013"
    	}
    ],
    "profiles": [
        {
            "name": "iOS Team Provisioning Profile: *",
            "type": "development",
			"appid": "D7NQRK----.*",
            "uuid": "A7D868EA-B1F3-4280-BD01-464653A-----",
            "statusXcode": "Active"
        }
    ],
    "devices": [
        {
            "name": "------- iPad 2 Wi-Fi",
            "udid": "96b9d40cdc20417928dd71c4a0cc03----------"
        }
    ]
}

Storing the password (encrypted in a configuration file)

If you don't want to have your password on the command line (so that it doesn't appear in log files), you can generate a config file.

$ ./generate_apple_dev_center_config.rb -l [email protected] -p YourSecretPassword -s "an optional seed key" > /path/to/config/apple_dev_center.config
$ cat /path/to/config/apple_dev_center.config
---
default: [email protected]
accounts:
- login: [email protected]
  password: l1/ChJtwxlmDnav8D4dZafRi6NOdme4Z
  teamid: ''

Then use the apple_dev_center.rb script as following:

# To avoid having to place password information on the command line
$ ./apple_dev_center.rb -u [email protected] -c /path/to/config/apple_dev_center.config -S "an optional seed key" -d
[...]
# or to pick the default account and an empty secret key
$ ./apple_dev_center.rb -C /path/to/config/apple_dev_center.config -d

Use a proxy

To use a proxy set the environment variable https_proxy:

$ export https_proxy=https://proxy.yourcompany:port/
$ env|grep https_proxy
https_proxy=https://proxy.yourcompany:port/

Select a team

Select a team, if you are a member of multiple teams:

# By the team id
$ ./apple_dev_center.rb -u [email protected] -p xxxxxxx -t 2xxxxxxxx6 -d devcenter -O devcenter/site.json

# By the team name
$ ./apple_dev_center.rb -u [email protected] -p xxxxxxx -T "My development team" -d devcenter -O devcenter/site.json

Or save the team to the config file:

# Team id
$ ./generate_apple_dev_center_config.rb -l [email protected] -p YourSecretPassword -t 2xxxxxxxx6 -s "an optional seed key"

# Team name
$ ./generate_apple_dev_center_config.rb -l [email protected] -p YourSecretPassword -T "My development team" -s "an optional seed key"

The team id has precedence over the team name.

The first team from the team selection is selected by default if neither team id nor team name are given.

Use with Jenkins

In a CI environment, you will probably want to avoid printing out the password and use the config. I like the build secrets plugin to be able to send that to any slave.

Here's a useful step by step job configuration.

  1. Generate your config file

     ./generate_apple_dev_center_config.rb [email protected] YourSecretPassword "an optional seed key" > your_apple_dev_center.config
     zip your_apple_dev_center.config.zip your_apple_dev_center.config
    
  2. A build step with the build secrets plugin in which you attach to a environment variable a zip file containing your config:

     APPLE_DEV_CENTER_CONFIG => your_apple_dev_center.config.zip
    
  3. A shell script that creates an adc.zip file containing the site.json and related provisioning profiles:

     ls -lR $APPLE_DEV_CENTER_CONFIG
     mkdir -p adc
     rm -f adc/*
     ruby ./apple_dev_center.rb -C $APPLE_DEV_CENTER_CONFIG/your_apple_dev_center.config -S "an optional seed key" -u [email protected] -d -O adc/site.json
     zip -r adc.zip adc/
    
  4. [optional] Archive the artifact adc.zip, deploy it on a common place, etc.

Technical information

Provisioning profiles are PKCS7 signed messages. The message itself is an XML plist. The script extracts the plist.

TODO

I am considering the following improvements:

  • Extract out the password storage functionality into an reusable encrypted password store for use by ruby scripts (in CI environments).
  • Package the ruby scripts into libs and a gem to ease installation and update.
  • Add some functions to upload devices or sync an externally managed list of devices onto the Apple Developer Center.

Feedback

Question & feedback: [email protected]

Links

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Ruby lib and scripts to manage Apple development (provisioning profiles, certificates, pbxproject, etc). Former iOSProvisioningProfiles.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published