Automate iOS Deployment with Hamper and Schezhen

34
AUTOMATING IOS DEPLOYMENT KIRAN PANESAR @K_PANESAR

Transcript of Automate iOS Deployment with Hamper and Schezhen

Page 1: Automate iOS Deployment with Hamper and Schezhen

A U T O M AT I N G I O S D E P L O Y M E N TK I R A N PA N E S A R @ K _ PA N E S A R

Page 2: Automate iOS Deployment with Hamper and Schezhen

I ’ M T H E C T O O F M O B I L E X L A B S , A N D W E M A K E N AT I V. C O M .

Page 3: Automate iOS Deployment with Hamper and Schezhen

W E ’ R E I N B E TA . B E N I C E .K I R A N @ M O B I L E X L A B S . C O M

Page 4: Automate iOS Deployment with Hamper and Schezhen

I O S A U T O M AT I O N I S G R E AT.

xcodebuild - Jenkins - ios-sim - UIAutomation - TestFlight’s API - etc

Page 5: Automate iOS Deployment with Hamper and Schezhen

T H I S M A K E S I O S D E V E L O P M E N T FA S T A N D F U N !

Page 6: Automate iOS Deployment with Hamper and Schezhen

B U T , W H AT A B O U T D E P L O Y M E N T ?

Page 7: Automate iOS Deployment with Hamper and Schezhen

1. Sign into the Provisioning Portal.

2. Create an app ID.

3. Create a distribution certificate.

4. Install distribution certificate.

5. Create provisioning profile.

6. Download and install profile.

7. Fight with Xcode’s profile management for some time.

8. Tell Xcode to use the profile for distribution.

9. Build.

10. Export archive.

11. Upload to TestFlight, App Store, HockeyApp, etc.

( D E L I B E R AT E LY S M A L L )

Page 8: Automate iOS Deployment with Hamper and Schezhen

T H I S M A K E S I O S D E V E L O P M E N T S L O W A N D D U L L .

Page 9: Automate iOS Deployment with Hamper and Schezhen

– Y O U

I D O N ’ T D O T H I S V E RY O F T E N . W H Y D O I C A R E ?

Page 10: Automate iOS Deployment with Hamper and Schezhen

P E O P L E D O N ’ T C A R E E N O U G H A B O U T I T. B U T T H E Y A LWAY S C O M P L A I N .

Page 11: Automate iOS Deployment with Hamper and Schezhen

T H I S I S A R E A L P R O B L E M F O R U S .

Page 12: Automate iOS Deployment with Hamper and Schezhen

N O P R O V I S I O N I N G P O RTA L A P I .

Page 13: Automate iOS Deployment with Hamper and Schezhen

S O W H AT ? B U I L D O N E .

Page 14: Automate iOS Deployment with Hamper and Schezhen

I N T R O D U C I N G H A M P E R .G I T H U B . C O M / M O B I L E X L A B S / H A M P E R

Page 15: Automate iOS Deployment with Hamper and Schezhen

A C O M M A N D L I N E I N T E R FA C E F O R I O S P R O V I S I O N I N GG I T H U B . C O M / M O B I L E X L A B S / H A M P E R

Page 16: Automate iOS Deployment with Hamper and Schezhen

H O W D O E S I T W O R K ?

Python, Selenium, PhantomJS

Page 17: Automate iOS Deployment with Hamper and Schezhen

W H AT C A N I T D O ?

• Authentication.

• App ID registration.

• Certificate generation.

• Provisioning profile creation.

Page 18: Automate iOS Deployment with Hamper and Schezhen

I N S TA L L AT I O N

brew install phantomjs...sudo pip install hampercli

Page 19: Automate iOS Deployment with Hamper and Schezhen

S T RU C T U R E

hamper <module> <verb> --<argument> <value>

Page 20: Automate iOS Deployment with Hamper and Schezhen

L E T ’ S S E E W H AT I T C A N D O .

Page 21: Automate iOS Deployment with Hamper and Schezhen

S I G N I N

hamper auth login --email [email protected] --password passwdAuthenticating user...User successfully authenticated.

(Password stored in the device’s keychain for future requests)

Page 22: Automate iOS Deployment with Hamper and Schezhen

A P P I D R E G I S T R AT I O N

hamper identifier create --app_name MyApp --bundle_id com.mxl.new_app

Generating app ID...App ID successfully generated.

Page 23: Automate iOS Deployment with Hamper and Schezhen

C E RT I F I C AT E G E N E R AT I O N

hamper cert create distribution --csr_path /request.csr --cert_path /out.cer --bundle_id com.mxl.new_app

...Generating certificate (this could take a minute)...Certificate successfully generated.Downloading certificate (this could take a minute)...Certificate successfully downloaded (/Users/kiran/out.cer).

openssl genrsa -out private.key 2048openssl req -new -key private.key -out request.csr

Using openssl to generate key and CSR

Generate a certificate

Page 24: Automate iOS Deployment with Hamper and Schezhen

P R O V I S I O N I N G P R O F I L E C R E AT I O N

...Waiting for Apple to generate profile (this could take a minute)...Provisioning profile successfully generated.Downloading provisioning profile...Profile successfully downloaded (/Users/kiran/p.mobileprovision).

hamper profile create app_store --name MyApp_Production --bundle_id com.kp.my_app --profile_path p.mobileprovision --exp_day 20 --exp_month 04 --exp_year 2015

Page 25: Automate iOS Deployment with Hamper and Schezhen

– Y O U

W H AT C A N I D O W I T H T H I S ?

Page 26: Automate iOS Deployment with Hamper and Schezhen

T O T H E A P P S T O R E !

Using Hamper with Shenzhen (Mattt Thompson)

Page 27: Automate iOS Deployment with Hamper and Schezhen

R E G I S T E R A N A P P

hamper identifier create --app_name MyApp --bundle_id com.mxl.new_app

Generating app ID...App ID successfully generated.

Page 28: Automate iOS Deployment with Hamper and Schezhen

G E N E R AT E T H E P R O F I L E

Waiting for Apple to generate profile (this could take a minute)...Provisioning profile successfully generated.Downloading provisioning profile...Profile successfully downloaded (/Users/kiran/p.mobileprovision).

hamper profile create app_store --name MyApp_Production --bundle_id com.mxl.new_app --profile_path p.mobileprovision --exp_day 20 --exp_month 04 --exp_year 2015

Page 29: Automate iOS Deployment with Hamper and Schezhen

I N S TA L L T H E P R O F I L E

uuid=`grep UUID -A1 -a p.mobileprovision | grep -io "[-A-Z0-9]\{36\}"`

cp p.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/$uuid.mobileprovision

H O L D O N T O T H AT U U I D , W E ’ R E G O I N G T O N E E D I T I N T H E N E X T S T E P

Page 30: Automate iOS Deployment with Hamper and Schezhen

B U I L D A N D A R C H I V Excodebuild archive -workspace my_app.xcworkspace

-scheme MyApp -archivePath output.xcarchive PROVISIONING_PROFILE=$uuid

xcodebuild -exportArchive -archivePath output.xcarchive -exportPath ./ -exportFormat ipa -exportProvisioningProfile p.mobileprovision

Page 31: Automate iOS Deployment with Hamper and Schezhen

U P L O A D !

ipa distribute:itunesconnect -a [email protected] -p passwd -i 234234235 --upload

U S I N G S H E N Z H E N

Page 32: Automate iOS Deployment with Hamper and Schezhen

W H AT ’ S N E X T ?

• Prompting interface.

• Integration with openssl to generate CSRs.

• Integration with iTunes Connect to create an app, fill out metadata.

• General reliability improvements.

B E C A U S E I T ’ S I N B E TA .

Page 33: Automate iOS Deployment with Hamper and Schezhen

T H A N K S !G I T H U B . C O M / M O B I L E X L A B S / H A M P E R

Page 34: Automate iOS Deployment with Hamper and Schezhen

K I R A N PA N E S A RE N G I N E E R I N G . M O B I L E X L A B S . C O M

@ K _ PA N E S A R

K I R A N @ M O B I L E X L A B S . C O M