57
Provisioning Profiles like a Pro Monday, September 9, 13

Provisioning profiles like a Pro

Embed Size (px)

DESCRIPTION

Learn exactly what Provisioning Profiles are and how to use them better in your day to day workflow.

Citation preview

Page 1: Provisioning profiles like a Pro

Provisioning Profiles like a Pro

Monday, September 9, 13

Page 2: Provisioning profiles like a Pro

Jay GravesCTO

Monday, September 9, 13

Page 3: Provisioning profiles like a Pro

Lots of Apps

Monday, September 9, 13

Page 4: Provisioning profiles like a Pro

Ship It

Monday, September 9, 13

Page 5: Provisioning profiles like a Pro

Provisioning ProfilesHow do they work?

Monday, September 9, 13

Page 6: Provisioning profiles like a Pro

Provisioning ProfilesWhat are they?

SMIME / PKCS#7

Originally designed for email signing & encryption.

Monday, September 9, 13

Page 7: Provisioning profiles like a Pro

Read a Provisioning Profilevim

Monday, September 9, 13

Page 8: Provisioning profiles like a Pro

Read a Provisioning Profileopenssl

openssl smime -in ./your.mobileprovision -inform der -verify

openssl smime -in /path/to/your.mobileprovision -inform der -verify -noverify

https://skabber.snipt.net/provisioning-profile-tips-tricks/

Monday, September 9, 13

Page 9: Provisioning profiles like a Pro

Important Valuesapplication-identifier

<key>application-identifier</key>

<string>ABCDEFGHIJK.com.your.bundleid</string>

Monday, September 9, 13

Page 10: Provisioning profiles like a Pro

Important ValuesEntitlements<key>Entitlements</key><dict>...<key>com.apple.developer.ubiquity-container-identifiers</key>...<key>com.apple.developer.ubiquity-kvstore-identifier</key>...<key>get-task-allow</key>...</dict>

Monday, September 9, 13

Page 11: Provisioning profiles like a Pro

Important ValuesProvisionedDevices

<key>ProvisionedDevices</key><array><string>7af8ee3af8e4e13193bd834bab50e1d...</string> <string>a9f0d0477a6d3e8dad0ff984f7ba77e...</string> </array>

Monday, September 9, 13

Page 12: Provisioning profiles like a Pro

Important ValuesUUID

<key>UUID</key>

<string>E0EF8ACE-E83A-475C-9DA7-C67A147659FD</string>

Monday, September 9, 13

Page 13: Provisioning profiles like a Pro

Important ValuesDeveloperCertificates

<key>DeveloperCertificates</key>! <array>! ! <data>MIIFnDCCBISgAwIBAgIIEIdrqpJlb9MwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNVBAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlv...

Monday, September 9, 13

Page 14: Provisioning profiles like a Pro

Important ValuesDeveloperCertificates

-----BEGIN CERTIFICATE-----MIIFnDCCBISgAwIBAgIIEIdrqpJlb9MwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNVBAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlv...-----END CERTIFICATE-----

openssl x509 -text -in cert.pem

Monday, September 9, 13

Page 15: Provisioning profiles like a Pro

Important ValuesDeveloperCertificates

Certificate: Data: Version: 3 (0x2) Serial Number: 10:87:6b:aa:92:65:6f:d3 Signature Algorithm: sha1WithRSAEncryption Issuer: C=US, O=Apple Inc., OU=Apple Worldwide Developer Relations, CN=Apple Worldwide Developer Relations Certification Authority Validity Not Before: Nov 3 21:38:10 2012 GMT Not After : Nov 3 21:38:10 2013 GMT Subject: UID=9K9F9LCV74, CN=iPhone Distribution: Massively Overrated, OU=9K9F9LCV74, O=Massively Overrated, C=US Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (2048 bit) Modulus (2048 bit): 00:c8:57:f9:cf:af:c2:4d:7a:8a:16:62:47:4b:c2:

Monday, September 9, 13

Page 16: Provisioning profiles like a Pro

Install a Provisioning ProfileDon’t double click them.

Not human readable.

Monday, September 9, 13

Page 17: Provisioning profiles like a Pro

Install a Provisioning ProfileDrag them into the Finder

~/Library/MobileDevice/Provisioning Profiles

Monday, September 9, 13

Page 18: Provisioning profiles like a Pro

Install a Provisioning ProfileDrag them into the Finder

Monday, September 9, 13

Page 19: Provisioning profiles like a Pro

Install a Provisioning ProfileDrag them into the Finder

Much betterMonday, September 9, 13

Page 20: Provisioning profiles like a Pro

Tools for using Provisioning ProfilesTerminal.app

Monday, September 9, 13

Page 21: Provisioning profiles like a Pro

Tools for using Provisioning ProfilesTerminal.app - bash alias

alias prov='openssl smime -inform der -verify -in'

Monday, September 9, 13

Page 23: Provisioning profiles like a Pro

Tools for using Provisioning ProfilesAutomator Service

Monday, September 9, 13

Page 24: Provisioning profiles like a Pro

Tools for using Provisioning ProfilesAutomator Service

http://cl.ly/MTZb

Monday, September 9, 13

Page 25: Provisioning profiles like a Pro

Tools for using Provisioning ProfilesAutomator Service

Monday, September 9, 13

Page 26: Provisioning profiles like a Pro

Xcode

Monday, September 9, 13

Page 27: Provisioning profiles like a Pro

XcodeHow does it see profiles?

CODE_SIGN_IDENTITY = "iPhone Developer";PROVISIONING_PROFILE = "";

Monday, September 9, 13

Page 28: Provisioning profiles like a Pro

XcodeHow does it see profiles?

CODE_SIGN_IDENTITY = "iPhone Developer: Jay Graves (E6L876QFM6)";

PROVISIONING_PROFILE = "0FEB5831-22D3-4B1D-A973-59ED243E8103";

Monday, September 9, 13

Page 29: Provisioning profiles like a Pro

XcodeBuild error

Monday, September 9, 13

Page 30: Provisioning profiles like a Pro

XcodeUpdate the profile.

Monday, September 9, 13

Page 31: Provisioning profiles like a Pro

XcodeProject Diff

Monday, September 9, 13

Page 32: Provisioning profiles like a Pro

•Automatic Profiles•Good if you don’t have multiple projects.•It can select the wrong profile.•Rules on automatic selection are not defined.

•Specific Profiles•Much more control over which profile is selected.•Can be a pain to update the project file every time a profile is updated.

What does all this mean?

Monday, September 9, 13

Page 33: Provisioning profiles like a Pro

Monday, September 9, 13

Page 34: Provisioning profiles like a Pro

Scenario1 Project 2 Builds

Monday, September 9, 13

Page 35: Provisioning profiles like a Pro

•Add a Duplicate Target•Large project file change•Duplicated all of the Configurations•A 2nd info.plist has been created.

• Add a new Configuration•Still a large project file change•Still duplicated all the build options•Easy to forget new build options

Multiple Build ScenarioPossible Solutions

Monday, September 9, 13

Page 36: Provisioning profiles like a Pro

Multiple Build ScenarioA better solution

.xcconfig file

Monday, September 9, 13

Page 37: Provisioning profiles like a Pro

Multiple Build ScenarioCreate a .xcconfig file

Monday, September 9, 13

Page 38: Provisioning profiles like a Pro

Multiple Build ScenarioCreate a .xcconfig file

CODE_SIGN_IDENTITY = iPhone Distribution: Double Encore

PROVISIONING_PROFILE = 1203C18-8F08-45D8-A5AC-76AD9319CDDC

Monday, September 9, 13

Page 39: Provisioning profiles like a Pro

Multiple Build ScenarioBuild with a .xcconfig file

xcodebuild -xcconfig second_build.xcconfig

Monday, September 9, 13

Page 40: Provisioning profiles like a Pro

This can be better!Automate it

•Every Provisioning Profile contains all the information we need.•CODE_SIGN_IDENTITY is in the DeveloperCertificates•PROVISIONING_PROFILE is the UUID

Monday, September 9, 13

Page 41: Provisioning profiles like a Pro

This can be better!The script

http://bit.ly/xcconfig

#!/usr/bin/env  pythonfrom  M2Crypto  import  SMIME,  X509,  BIO,  m2import  plistlib...plist  =  plistlib.readPlistFromString(blob)developerPEM  =  "-­‐-­‐-­‐-­‐-­‐BEGIN  CERTIFICATE-­‐-­‐-­‐-­‐-­‐\n%s-­‐-­‐-­‐-­‐-­‐END  CERTIFICATE-­‐-­‐-­‐-­‐-­‐"  %  plist["DeveloperCertificates"][0].asBase64()

Monday, September 9, 13

Page 42: Provisioning profiles like a Pro

This can be better!The script

http://bit.ly/xcconfig

developerCert  =  X509.load_cert_string(developerPEM)items  =  developerCert.get_subject().get_entries_by_nid(X509.X509_Name.nid["CN"])...open(outXcConfig,  'w').write("CODE_SIGN_IDENTITY  =  %s\nPROVISIONING_PROFILE  =  %s\n"  %  (codeSignIdentity,  plist["UUID"]))

Monday, September 9, 13

Page 43: Provisioning profiles like a Pro

What have we accomplished?

•Real file based Provisioning Profile selection.•Zero ambiguity about which profile will be selected.•No mismatched Profiles in Xcode’s Code Signing Identity.•Other than downloading the profile from the iOS Dev Center there is no work for you!

Monday, September 9, 13

Page 44: Provisioning profiles like a Pro

OK, OK, Enough with the Provisioning Profiles

already.

Monday, September 9, 13

Page 45: Provisioning profiles like a Pro

Keychain Access

Monday, September 9, 13

Page 46: Provisioning profiles like a Pro

Multiple Keychains

Monday, September 9, 13

Page 47: Provisioning profiles like a Pro

Switch Keychains

security default-keychain -d user -s /FULLPATH/My.keychain

security unlock-keychain -p ******* /FULLPATH/My.keychain

unlock keychain

Monday, September 9, 13

Page 48: Provisioning profiles like a Pro

Switch Keychains

Error: User interaction is not allowed.

unlock keychain

Monday, September 9, 13

Page 49: Provisioning profiles like a Pro

Switch Keychainsunlock keychain

Monday, September 9, 13

Page 50: Provisioning profiles like a Pro

Keychain Error

Code  Sign  error:  Certificate  identity  'iPhone  Developer:  Your  Name  (NNNNNNNN)'  appears  more  than  once  in  the  keychain

Monday, September 9, 13

Page 51: Provisioning profiles like a Pro

OTA Install

Monday, September 9, 13

Page 52: Provisioning profiles like a Pro

md5checksum

Monday, September 9, 13

Page 53: Provisioning profiles like a Pro

md5 checksumdoesn’t work

Monday, September 9, 13

Page 54: Provisioning profiles like a Pro

Install multiple appsat the same time

Monday, September 9, 13

Page 55: Provisioning profiles like a Pro

Install multiple appsat the same time

Monday, September 9, 13

Page 56: Provisioning profiles like a Pro

Install multiple appsat the same time

Monday, September 9, 13

Page 57: Provisioning profiles like a Pro

Thank [email protected]@skabber

Monday, September 9, 13