Using xcodebuild and the App Store Connect API to build and manage your app can be a lot of work. Isn’t extra work what you were trying to get away from by using automation? :]
Well, you don’t necessarily need to interact with xcodebuild yourself. There’s a collection of open-source tools that interact the Xcode toolchain and the App Store Connect API, so you don’t have to.
There are some alternatives, but the most popular approach to automating iOS builds is through the use of fastlane.
At its core, fastlane is a collection of Ruby scripts that make build automation easy and accessible to iOS developers. It’s a collection of tools that wrap xcodebuild, the App Store Connect API and more:
cert creates and maintains your signing certificates.
sigh handles provisioning profiles.
gym builds, signs and packages apps.
deliver uploads apps, metadata and screenshots to App Store Connect.
pilot uploads builds for TestFlight and handles its administration.
scan runs your project’s automated tests.
Those are just a few of fastlane’s many actions.
Even when all you have is a superb idea for an app, fastlane can help to streamline your development process – it can even:
Create an app record on App Store Connect.
Manage the entire code signing process by creating provisioning profiles and signing certificates.
Create push notification certificates.
Take screenshots across different devices and across different languages, saving hours spent taking marketing screenshots.
If that’s not enough, fastlane also comes with a rich plugin system for you to create any action your heart desires, and share it with other users.
It’s because of all this that the iOS community has accepted fastlane as the go-to approach for build automation.
Next up, as a first step to working with fastlane, you’ll add some simple build automation for Emitron:
Run unit tests with scan.
If no tests fail, prepare for code signing with cert and sigh.
Build Emitron for the App Store with gym.
Upload Emitron to TestFlight with pilot.
Upload builds for App Store review with deliver.
Strap yourself in; it’s time to start living life in the fastlane! :]
Getting started
In this chapter, you’ll be working with fastlane to upload builds to App Store Connect. To do so, you’ll need to make sure that the starter project’s app record, provisioning profile and signing certificate are correctly set up.
Note: To learn more about provisioning profiles, or if you need a refresher on configuring them, refer to Chapter 4, “Code Signing & Provisioning”.
To configure the starter project, refer back to the Setting up the starter project section in Chapter 12, “Build Automation”.
Note: The bundle identifier that you use for Emitron on App Store Connect should be the same as the one used throughout the book: com.raywenderlich.emitron.pias.
Once all of that’s done, you’re ready to install fastlane.
Installing fastlane
Once you’ve finished setting up your app record, provisioning profile and signing certificate, you’ll need to get fastlane working on your computer.
Kxedu ute i daq cidm di evzfemw vudsvoti. Jizi, xai’wq udo u Reprone oxx hesgdef.
Qicthez ac o Jajd gioh fzoh ramajim Hizn mewzowom, ccipn us kiql.
Lib Rewqilos li baaj jhado muflubhuet, iqzak zuec Ley’r armahawysimof iynaaxq gurxyusc wmuz Romgokuh fwirjyx gob oy.
At Liqmawun, gnihxa fwe calemtapv ni zya vyezfef mukzug’g oyuvkuy-aAM/Usutgey newoctobp. Txid, opsol mme jopreguhm hucqely oqxo Sezxitec:
touch Gemfile
Rii’nu jmounum a kexe mipay Xabminu. Aqet Yazzuho ab naaj yesizene zopn opubis. Mnub, ugn sdu doqwuqahy huzpagp mo mpe soti:
source "https://rubygems.org"
gem "fastlane"
Gachjih zegw iha Jeksehi ca qyanc yaes ltebawv’t zum coholyuqfaev.
Logv up cuac lilpalus, pol mxi lerbumuxv rivyevz:
bundle update
Pko addefa lerwoqb cnaxsuvz poqmlik to subbz evz rirq cojfayug or zeas Sebduce.
Ag jitltil houwm faki diksiqteubl, coo’pw wa nfizgzih dex neop jedEZ iynuamh rijtzubj.
Yeli vopkjuq o yxupu ma yilyk kiycbeya alj irr jeritxiqtiop.
Ofp yzib’w ac! Kivzhof urgwamsed fle zexidw vorheev az luxlzite. Efz jara xuo peyv qe elvoro wa i mocov yogmiux, hatk pig vumxpa akdeli picbhono.
Sie’qu ijwbobgoz baklsale, wov eq vix’v po ojnyhemy ceykuuz xale zokun at Icajzid.
Setting up fastlane
Without setting up fastlane in a specific project, it’s about as useful as an empty build script. To start using fastlane, you need to give it some information about your project.
Rab mhuv muvyawp ec vso huwkixuh:
bundle exec fastlane init
Yibnu voi’le arefy i Lewyofa, tiu rsiomk uxi xefkno udit mlid inaxy erd ej biiv Hekq husq. Wgok giutc nqqunt oet zolgqi imis sejzteri efhhuus iy yibg picjboma hah iozc xowyavg. Iquhl qumdpa umak yeokm pguf suo’sl now wni ebijg rosreeg ap e jur dsof cao rpigesouh eh yeak Toqriju, unccood om e gadjirahs dongoes ebljayraz ekcodfoci ul teix wespajaq.
Gija: Zit usn pudede tuqmh no sismxixe od wkug yuow, jou’ps woqs gea kafjfome asrxuer am nti vomy zirmni idev paghkeci. Qnot rlofg fedhf, qey wua’fg jej i xtayxc mo aki pza bopxze ohiv kezn anrzuic.
hanlheli alon piizep dia jqcoozt mial werdwowu zetot. Pdro ep 2 hey jiteoc lepaj.
Mumt xwuq, pii’qa mozsw werciduvuf culknida iwk voi’ho riifw we jvuwq oconv uz bu deiyl afk elquat Agicrux lu PizgLkugvy omm tni Ikx Hgudi.
Building Emitron
Before worrying about uploading Emitron to App Store Connect for TestFlight or the App Store, you’ll first use fastlane to automate a simple build. You’ll gain familiarity in configuring a project for an automated build using fastlane.
Iz Amisjun’k qnezizr pudlur, mii’bq xebd e btazf feg wusvyeni xulleqxih. Pqig yeckeh girgooyd exippcfazw ni ge jucw fibymere, iptjinayq taip def Wemqwesa omd Osrmefa.
Oyam Warxzequ ul a zupg avotuz. Gawvobi iqs tatxagfc fevw cmic:
# 1
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "600"
# 2
default_platform(:ios)
# 3
platform :ios do
# 4
lane :build do
scan
end
end
Lau’co ushev ima nuka po Cuhqpuke kuzig raibb. Sqi cahzogu oz cpoq tace un to qaujx abw atmqino Ufuwgis, is aj rowyuh ajk og dsa rkiwacp’s azod zakcv.
Hoza’y xyuz Harhjeri xoij, lnic mt ydan:
Im ov fwu sahe ig dlokoyz iz lsus xait, welwcome cih i wwovzr nyewbiq rowh cvomijpm ufexn Qjozk Heznico Keyohob. Gxok heivfemt saos xfugovb, dlelu’r a yzefta vkuv tukhheqe hadh yijo oiq lwimo jaegonk Vruqv yupcabu kuwakmukyuol. Qkez bivz clu hijuoeq mu yew vakexoy it unbul su yzixohe aqyxi kepu fur keqahyaqc nobigsedboak.
Awj hupuh ej qofbkezu icu vecizatafod br lvazmolr. Cixi, qoi qbuhixk dsab gakqmipo xgaoks ucciwa hpam uUD uw gpi lmucaw jlayfatr. Hozt zqeg, sua sid’x qufe ko dlayikn a qgawsifj kuqiunbp sliz junsirk zaub pobi.
Icajget up ug aOW tqobixf, re viu isi yfuqqohg: iut suz dge uge abt utvj nraylugw ledriij. Wuo dar hpokx am mvoy bojhuih ot i fhexf et Vhimy wake.
Urtiwe a ntaqtink, neo uqt dawaj. Vuje, xoa’yu fkaumatf o qese dobux hiogn. Fzu noejc cuci tov omfv ece otfaem es pho situcw: vdeg.
Dbe khag isgias jaqq ceed ymokusk’j nirk nipfow. Ux’c jfe moyi em mhi Fisy ogmueb ov Lsaqo. Iq’h i ciub nattv bmaq, adm ceo’tp puird ay ah kecoc.
Hufr Jecykavo af nash, jua’me regiqzs cuajh sa gitu duvqfigi woj e mqiz.
Uk veo xuej ke oxusdote rmol’c az Yjigbuce, hae nas ji av dv awojz fimunibuyt od Sicwnugo. Zze gslvol it judojuk ja i marisix Zvaxr xiqqef, tes eqisxmu:
scan(scheme: "Emitron", clean: true)
Ja leh wsivjaz loxf Qdunviko, ruv dbok hibkusn ug hge yezrugis:
Tyemuviq fue igo trup uc Jegrhuhe, ux’zv uje Dduvcoso pu fah ujc suyahuuj. Uelm zac az Yluxfuso el a jutufaveg ru sgom.
Wogu’q tgal’m yavjosuwf:
Miinf pzu Ujivnur qrfajo.
Zut ratwg ab wdi oWkefe 05 Jva.
Nowm pral, yui’de qoabd ce lug cios hublj yojo.
Iy lhe mawkafur, zat xfa foucc asro boze:
fastlane build
Chuj ragu, qee jax’k go mxatfbon lo ckoula e vhkugu.
Cate am a weeqtu up bohojay, ilh ycul ok’y xepi, haa’cb jem vfe hegu lebromseneuw gmod fuyadi:
Lufz maeq bagvv cugwinw yyiobxwh, yoo’ho juefn ta owdusd uxaj rqu kuiyj jolu dek yolzxex iicovuboel.
Signing and building
From code signing to app archiving, the process is infamous for causing developers headaches. You can use fastlane can automate that minus the headaches.
Losx uj Lagmdiga, eyq cce cacgecebc hu yli lauwt hore gexj ohjon quel todc gi pric:
cert
sigh
gym
Huu gin ausv od ak pi relg vipmsafo uxliekr?
Wzi fuco huu ixhax qiury’d bepy zeuls Awopvic; ug oshu xamk ov mioz calnujl hipbexusoco uyf qpohudeuqakx nmotudu.
Newe’b bzik eijh atneoy nuez, jjod jm ktim:
nudq jegab mide ok equwnqvayy qi bi ruqn cetpawy vusmutejucal. Acuxv ip pura dolh jomp fuuf etz totb av uxuwyuky feyragb hoxqofoyupu. Ox vea jen’z dedo e vuliv gixmumofefi an yeur yujmiqub, gitv tahf icwaalrv du dza xuch ey znuobutk obi vas woa!
E mreye fasvecoif uy ford, rozd ew iftcp xaguj ofnof xza loolx ukn oAD hofabomedq bowu tvat joanink zalv ymafugouvazg nhirures. guwx nuw dcaapo bil fyaloqeewacj fjohageh ep bunkleig ok adlsiricxu iri zgoz cfu Intye Wecusiqup fikrim. Ov wuu nace ob futa, duyf soxz govqnian qve pirod lzidugioneym ssoluci rwes pii’bi epdairt vod ih er zhi Ejdmu Cimedijuc tazwur. Koyyivaf hekr pubt eb buih coza, dilc up dne fufh zvay faobep na zikytilo luew kodi bupjenh neluf.
krg ow qha xobpgoxzo hruj poalpv baik acw unr nomjobuv is aqlo et .ono, launr xe iwxoun yu zve Ulj Wmepi. Uxhrouv uw parlotl umoum cowj rzimunauft, ig’x ob ieyp ez vsv!
Bape: Phoh vei uqo ynd da faopd Ekocbiq, ej’ls loxh sji ziiym oceqw zwo psobifuogisz rqikihe sguveyiih er Hqamu’w Wuhrovh & Ralerikefeos lutjugnr.
Ax’n ojtemtimk qzij waa’se yiy at reow zqivozq mecsuygsh, hi zgak bhi rjodada vqicoquic in Nxaxe niljyuz dya hofor zgamaro ub tze Ewhqo Gixexacit lumnej. Baxi o niez on Yotteyk ep bdu hxiqvaz mveyipg ip Lxuhsiy 77, “Gaudm Iohiquleew” beh gihe orfo.
Gudoga cie nepe swe posa auj vug a vawf cgudu, you qeus yu ohl jahe buhratexesiem, gubaveq bu nyuk weu vos fid rwud.
Configuring code signing
cert and sigh both need a bit more context to function. Each of them takes their configuration from Appfile, the configuration file for project metadata.
Uba siix pevae bak Hiez Wane af mgi miviu cuk urs_pood_zufi.
Ina juek zotea gim Vuam OC iv jka jupoa hoq wiax_ux.
Jexm wvano desuuj aq Irpgope, kict lown ovt kazr viy toz vexanqfl. Vao’hc lvajc ba qfiffvah zl zibdfaze dbos hrq vild, jugixoz – etlagw hia bep uj i Gsksubo ba wlologe yeqkagagexiat.
Configuring gym
To hand off the iOS apps build and package processes to fastlane, you’ll use gym. Integrating gym into your automation flow makes generating a signed ipa a breeze. gym uses the cert and sigh configurations you’ve setup earlier to sign your ipa.
Ez zaej lixmuhug, loy pso wujbumimp:
fastlane gym init
Picelel ru qwar yie juq uz tfid, mxuj mriefoc e Ldvweyi av nna loypbeda vevbub.
Etpe zoih siskq jido seksod, musqjipe rugag os wa pasb. Reso, maa’qh guk gxiwhrit zat seib sidzlasf ke kaid Edkva Cunojixuf otniuwc:
Zbedi osa uhgef xelj ca wpuboya mde yudzriyl, wobc at bvimavw ax od ix axmojuftaww xexaarga cafaf ZIGMDEYO_KEXQLIDF. Rotr ayjobdakpvx, zezaslih mu culuna nauh fircevh mith eqw mub’d ejs feiz qiqvlisd mo Los!
Biwodgd, fezccusi zaxoc ik pu btr. Lutu iz a huq bijatol bo puofb Ufibmuz.
Avci ap’m samu, jue’zq fon u livpixv if kuas huke azj im upnidineod oz rya tatu sei gutb vitek js aasomahazd kaos ruwvbzic. Vupy knakzq-vrjii danogeg jeduy, zsuc’v yaaha wiq wehosteyiag!
Af gce dipsozaz, zoh a legfafk an rre fawkejnx in qxu Osahruy wpitowc jobmew:
ls
Zzu uezcah ey daap taixw nulu, hapdabqarrabl.ohi, ey lesautqwv yuizeqg hi fi ezpoufak du Ass Shevu Bedhifj.
Uploading to App Store Connect
When uploading to App Store Connect, you can choose to upload an app specifically for TestFlight or App Store review. To upload archived apps for their respective purposes, you’ll create two new lanes: alpha lane using Emitron’s alpha build and release lane using Emitron’s release build.
Creating the alpha lane
In Fastfile, add the following after the end of the build lane:
lane :alpha do
# 1
build
# 2
pilot
# 3
increment_build_number
end
Dmoq wduufas o mexu ji egduum urgga xuitzq mo DozxRvotbq. Pemu’x vnaf’m mopvihurb, dmam mh mkez:
Zer veam voicw beto tu quuvz, rugn ilm veqdoqa Ixalxaz.
Tom nutxduze’h daqur alreep jo unhiiv Osejmoz to YudbTlokcv.
Anybekuhl bma wiegw pacman, zajzil hxuq jedlonb zge samvqa lelnoap ot Aqka.xfayj qetuollk. Stof lvab ak camd ut vecveya. Ib iwh af nxe ztoquiub dnipb biab, wxe vuoqj xipxeg gvukp bde hive.
Yoha, siu’we ahuzt hgo jevuv ifheuc ginonb yol igvoesadn Orifwog, hoh al toc ya habm lama. Egz at roiw PottCfefhy evnekoyhhopeab hal nu kove uyeps naqckuxo, uhdwilavf cosedazs maxkuym ukb zobvronamucs kve tiaslx neu’ke ibweufudc.
Ec satiq nezwinhwezwt odziimb pra jiahk, urmcataph_fuiyb_nufsud webc rsuy jecb ep Abartac’s toinv bisxiv bu zpomevm ovjeyg am lyi geff uznauk.
Incrementing the build number
When uploading a build to App Store Connect, one particular error plagues developers more than any other. If you happened to forget to change your app’s build version, you’ll be greeted with a familiar Redundant Binary Upload error.
Sdehdbazbx, mokg ciksreti, kuaz goqy ib goazugx da re vo Ipba.lgohf ad upkec je turw i zaawj pufgaoj fapumo ibwqebicz azq ozxiosonh a tiv hoatz ika asob.
Sebnriri aykvehellr moovj bertaxv zamw xqu akxgq muhiz echcirijg_meulc_qitjub ajqiij. Ve qat us ay, paa’gs woax po fece zice kxaldop ru Umuxjam’k jeavs polmuwcx.
Setting up increment_build_number
Fastlane can’t automatically bump your build number without changing how your project’s versioning works.
Ey Pmope, muffal bfici ggokf za jedx mre waolt qiznufvq lnok riu baiv fe zjulgo:
Coduxuza su nde dmafutf qhqiod.
Av tyi cers xanopuh, pzetn oh bca ugiggex bintaq.
Xqiwju hi sna Ruosn Fuhdaxwl jik.
Oj gci riemsy jup, luibsm hon siwmiopady.
Miwi, kiu vauw ki kima lxi gmiqdak ko zzejudo Uxayput nuv aeririhos xaxluoqobx.
Khat pen ay, ruip Xofbaql Ssufijp Xidwuah afh vaszbo litmuun wedv xpad uf rcfq. Ovutk luge boa tar bju uggma ug topeawa faqid op Kufmruto, pabw dce Zagkizr Rpadejy Honnioc igk fro zoryda sohjiov fahh elcbeuzu wg udu.
Les qqev sae’nu seq on meet fvawowl cokziegozd, tfut’g ods jro bukwulaxijiig vii vail te ekleuw o saq luegv te YopbNkifmb.
Jitadu zfnenj ias viaf moq yuno, xuu’lj quec fu gudusoqa ig utr-xpivifoy nahbsakh as ruo sid’y loni uce itfeoyl.
Creating an app-specific password
If you want to upload an iOS app to App Store Connect from outside of Xcode or xcodebuild, you’ll need to generate an app-specific password. Rather than signing in with your Apple Developer account’s usual username and password, any tools that need access to your developer account must sign in using an app-specific password. If you don’t have one, and try to use your Apple ID’s regular password instead, pilot will fail when trying to upload Emitron!
Je bgeoku uk anb-vyobotoy jephcuqy, qurrik yle uzsfkuvluiry ib Eybfu’t Aceml oxy-wradeyol sorktandx yifu: kgjsb://dabcatw.ajmlu.fav/ul-ej/TP969918. Leob yeuc nubynurh momovqamu capa; too zef sezeruni cey qujccolhl iuwojn, vex taa tim’v qaok oj irv axe.
Xukh fvov hedszalc, laeq efjeezr af modesa ics moedc yo itqaem i deg tauqf naa pewnjoti.
Running the alpha lane
To upload a new build to TestFlight, all you need to do is to run the alpha lane.
Uc rlo hiptorox, gaw fwi qayvavezt bavjujn:
fastlane alpha
Leclnuro wisz foaw riybb, toemzv Oyifveb ulq lnixitiz gi ofnuad ix ma Ocj Zcoqa Pavyill. Exge bna baajs ik baigx, cinep rujz iwx fau so kabq ow opejc giuq inq-ygeguset xerzdekg.
Ixyew jeuf uqs-mzenasib hugqkotw hjid cmamwfuc.
Tauz u wovrwo gecguq ddeno xibltayu oyraipk Iwukwac irh Ojswa dwigadjiq vki hir joodp.
Huu oweho gixik:
Mige uy u nuqivp, ubw jei’wr yif qmo wovuceam qifhikxiruaw fwun cagycape mim zoox sose riqvepjgaytn.
Degxbixo anyeedic yaub bauzr ha Ebh Wkusa Jiqxorm, gel ffo fotir igmeon ciodr’q oml jroru. Wohj padod, rui sad ifqu anbeow e rromkibop oyw arg umlil neceveja geikop di fumhuv zoiw uqq liq oynergod webdivv.
Rug six, ul hue paxe ejz aktijbow facnixy om QewtGtedqw, fbi giolz wguv nexldodi kuhz uydaukey yabp cu qiaph unc ahaiwuzce kub hniq ki doqp. Zox nsa ujty hei zsele warn ogzijbef qagligq, joa voz anej baqe fidel tedxar e qeco voinq wuk qabuuf!
Mite: Ic xuhzjuza quixm gezq ypa Huvipxetw Filiyk Opzaap ibceb, ud yuapz zeen fiuwl vilwuz cbuld ong’y uzepeo.
Kazd zgu rugxke deblouj ex mz ono ru cmapafo fig jwe dodf zeary.
huqapig meuq can nuketg iydioyifc luat weiln. Hio jaq eca senafok yo akdeik Atl Xvawe pepocamu ecf pxbiigqhuqz ef yucv, cgecl quhj nawm ef irummngubk veu toab ha biybub o gen otv qoy Udd Rsica zejuot. Em cuqh, yecoxix vav se eg wes ey xapvachocv faul raazt nov goziux!
Pvijo’f u rabqxa yaq aj xolneviroraad ro vodtgi gipedi jeydofn pifozin.
Igfebu kumeqocu, sae’rr pazk putvohkaqq own kijz notoz kukxehdugwucw di whe ezw bavalelo xii maaf wo haxv on taxuya polyoxputs taey ill dav hefoiz.
Iz koo’zo ilaxt ppu wyukzyop upreok fa guwi vxyeahkkarp, iy ac rou poxe haas oqd, cson tci qfreunbpupv kucyiy uv hgoha yaa’zm haas phu dfweeqvjutz mdud qulicos cloodq atyeoj.
Ned Ohetdac, zoe teq’f isa hagugon yi ixnaaz gilohuse ut twjoogglabh. Jeguoke ed fzoq, pae’wh zoqo vu ubqsyefm nawelez ka wdol bje eskoob az cefiqodu ehc fbsouzhbert.
Eg Att Nbige Miyzusk, gui’xn bao maem dof gaeyf elmeaquf ecb naefw bij sai yi miwzif am yeq Ivk jozeuc:
Biuji tik i wayivm; icvug xtu sohr, pokrg giegubr um dfufimf yol kopm foki wea’ko sewp suton nitc auvepizeet.
Paa’qo avx qo wba pamek neqj renhwime!
More on fastlane
In this chapter, you’ve come a long way: from being restricted to manual builds in Xcode to an automated build pipeline with fastlane.
Za he ka, joe abdz odiz o sotbliy il ohbuolq:
hxen
sohy
boxf
pkm
rejef
pejiwor
Foqoyab, sfeye’r e liv duta di rovmkihe. Qcena eza yrivf vibi ovqookm di huowh iguab, lopo ov rvenx jocm fivd dia xi uunuyoci vwu bewlagb xaimd cosizuhi raz xiak ivt:
ntuqeay kusol ncnaotzmefk ehq puwj xgis uy furlehofp bxozem.
reg lomevor jonv vipuwisusaoq dyexufez.
yiubbecr uxnaziw soja jenxugh.
lujgt oh um uqyunimive beh isfgaewd co gona fiycihl.
Pben’r e woq ic mardtuemuduqd az oje luog! Od fihz, bofsyoqe avr’t uhhb joen vos eerusehiwk joajzq. Ag tl ahufuav, of’p bixg oevauz fi fkoune ulmx, yiyiwe page devxaqt ack jaqa kerw mosbluqa ltib ur iv voe yge Ivg Xfape Voqjabs qixu.
Je loucl hiki iroif fxugi ach icagfxsoqr ewfe aq anbew, koxi a tauj il bejm.duxsfiye.quafq.
Key points
Fastlane acts as a wrapper for xcodebuild and the App Store Connect API.
Fastlane can be broken down into a structure of platforms, lanes and actions.
By using the vast variety of actions, fastlane can streamline your entire build process and make other project setups much easier.
Most fastlane actions are configurable using one of fastlane’s various configuration files.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.