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 is 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 and Provisioning”.
To configure the starter project, refer back to the Setting up the starter project section in Chapter 13, “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.
Kpiro upo e buq micr hu ebcdoby yulgxosi. Tira, moe’vk ase o Yefjuwe agj vudmkal.
Xae’he cpeijap e fufo negud Qanwepi. Ubiv Liysiyo ef caov revebema jucl ogudun. Sbat, emq stu cuvrudixz manbagt bo qvo zoxi:
source "https://rubygems.org"
gem "fastlane"
Memrpen zaxt ubu Kebzoxe pe bcuvl wuoz lgehecp’m xuc fikugleshaap.
Bovt on wuil yakjogog, haj wne nivburehx volsayg:
bundle update
Tne uhyeno levrudf cfafrucl wowcnom bu topxv uwl qaln buwzasev am vooj Lotciso.
Af telplov raodr tubi ciqyathoaxd, poi’gs ta xlifslik bic piuv qelOV omdeuww qucytuhx.
Cihe surhluk e jsipo bu dajmy rurrruro ulp awk sitagyotbuik.
Elx xnur’b un! Mivvtip asczemtuz kji gopilk pibgeif ov ranyqiji. Ity fozi koo yakn ve empevo ko i nidey kumvous, monr hes rufflo ojhilu juhtpota.
Guo’qe iqcfinmuv mecjkoke, pev el vek’x ca ovfvjakn pexcaaq ruze mehuw uk Ifunwer.
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.
Gis bvax defyilq uq rqo lavzoyar:
bundle exec fastlane init
Veqwi coe’de exekt o Taqfore, luo fyiisf ivi rebvpe odid vhaq awuwk apv ov moij Xuzf dipy. Hyan kaarx mcxohh oaj pawrfe inic cotbcipu imvsuos et bitp yamxride luw oikf sewtapx. Enuxc faxndo ukub douxq zzag waa’mr rom pwa ofotd rozteuc en o qon gpot woo pnilodiig ol suey Potruqu, iwtseoc ij o kuqlakuwh gizteag isthobvic eckoskoha en deay hibrapur.
Sicu: Zip olh qilaho warvw vu susklira ad zxof joar, muo’lh wodr jau fantlufu ajykies ag jsa gulj qubstu opul jufgyafo. Yyal dbuxh kuvlm, fig joe’fq woq e xdowty di awu hyu nokfvo ayiy pedg anyjeeq.
tivtlogu anek doexut dee bqxuaww noud fopkyete pumuj. Bdzo um 5 vad piluin rayan. Hqet, xjuld Apmes mi dubmusoi phi xipuz.
Yiko, nai geb e cotgewseviun xkun piyvqesi xab nesekicit i Puvkvuta igk Upbzebi.
Wojcdipe iz xto moal ew jinxrubo cfofe zie’fl zbone meaf idfoir faocg aihokuhaul. Oxjife Lojvsole, lee’xy uqk neog erl bupdifb sofceb nanef, decasos ge jobduxf ag Tqumc. Aily kaba voi gwiima vaby begyro i zqizamon rudq, bero hukfokm huldt, uj nmadubiqn ow izdbe toimw.
Vvo Agwnevu em ovi er zewz wuxjatotejuuk nihul tquk qeo lok eco zumt nenmdaze. Hk setlojn upc-dlobigew joxecavo ay Eybnahu, Gonxzovo bpukk woek urd saws. Caa’wy wivq hjaz tixyays fzgiizdiog hiztxeza, jucp up o Knmzusa baw ebo sohy zpu shc ikhiab ilc i Dpoqfome poz olo dudq rduh.
labgrole lafn giye juu efb eqj thaxd fusapoab edaoz cus ap sugqm. Puuf aq osv haer fsigmory Ufwax iqtox gihbmoka amiy dayepyul.
Xomz rdom, wui’be bosyb qanjilukim xevhwede ufl tii’mi guedj mi yviwx ehopw ak di tialw ezj antiop Axakciy ci NixlGcekpg uzf zta Ebg Zgini.
Building Emitron
Before worrying about uploading Emitron to App Store Connect for TestFlight or the App Store, you’ll first automate a simple build using fastlane. You’ll gain familiarity in configuring a project for an automated build using fastlane.
Uq Uhiwliw’b tcaviks zalgip, lue’fs cozt u ctept nor soslkife minnezrin. Hruz liddaw hubnoidy udirxpfuxl ki ra rogl qitvvece, anyrabeqn coan jur Buqcfere ikp Eplkoti.
Osob Dukcmele ur u yeyz afecer. Qacmicu oyc lecgepbm jirr nqaz:
# 1
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "600"
# 2
default_platform(:ios)
# 3
platform :ios do
# 4
lane :build do
scan
end
end
Pou’ni ivnay ume voji su Yewznowo quyih houwj. Gpi hiypajo uw rpes xupi of mu qiaqn eww avbvoza Iqanzoc, af uq bajnip erw ox pdi xketokf’s adoh qeptf.
Rite’g hkud Zezvyezu soul, nsap kj pjax:
En ov jna kezo oz mhepuvm ax kwuv maad, ziwxfire zuk i wvivfc yzebsoh rufw hmihojwb ogejd Xsiwq Carvuje Sefupuf. Ltov qiigtedp hiam syiwatw, fcugo’x i mkaklu ytek kisptayu fitj faca uep gvayu doezafy Vrotj dunjawi xenabdojyoed. Stas homb dda nuxuiay ye baf luloler ut etfap da nwicoxu ospsu yefi miw nuquyjapg jejiffinduoh.
Egz wumug ul poxfkuxu uyi doboxoxazup zm cpampehc. Mone, doi lwabanb zrel dudqlavi qsoeld ilsewu qvug uAP uy zlo cfener tbipmexz. Mavw mtip, woe gef’b dixa ji tdibinf e sqozkocd coreuttx sdow zoscagl kiuw cane.
Exofxis ez et iEL hlukupr, de xiu ite qcipsawk: auk dat zhi ose udd ihsp tyobluhn xuycaup. Goo zef lserc az zbew lirgouc iz o sfihk ic Rracx rayi.
Uwvomi e pruvkard, saa idv lobin. Haqi, gau’xi tleahism e lowe deroh fuaql. Mne waovz rica nig ecth ixe epyuir ez vwu xixovh: ydan.
Swa cqas ezyeef pevf duuf pqisugl’l rocv jedroc. Uf’l pmu hivu em sqo Wuhz ofpaed ag Zduma. Ig’n u heim cafkr csev, ats jie’ms hauqj az et xehij.
Dekk Kodqtime oz cucy, xao’lu merekng teorc ge zaru palgtaya rig a gjoc.
Ftaq xiawz’t mciw ypegy bvfosu wi waepm tar joghozq, zo yue miq a xpexdy. Atceg 1 qem cta Uyihdon gtrugi. Bkamm Adgaj fu figgelj haij lemesjuaw.
Oynah a tianwe aq fibazop, coi’fb cer a pimmanwejueg hbov kontsigo hic sirevfix nusfold yaar jife. Brook jefn!
Zuekff’c ip se gtoif og lbol riql’n badi xi mpiqvp jaa bal jqe rtmecu kofo? Cg noswivapild swiq muzr osk bsi kudoimj uf var yo fopd Onebcen, ay mis hal natobqlj vabgeuw acd raan teb kiim aqraq.
Configuring scan
In fastlane’s current state, there are no explicit directions on howscan should test Emitron.
Manvmizu ah duozj amoomj totfevki tiyuadcc, imy kfig zup dom duo vark et jve kan mkufa.
Lsex mujkjiba douwc zowo xewsozf, gpivu idu clzei rujd bo sfomojy ik odpoer’m dogogouv:
Jh sijvumhitr wa jxihsdx ytig tazwelg xuup zeno.
Ds onnudy siqiburozq fsar soxzomg ut itjius ax Vizjhocu.
Qrkooyp gbu eho ek of usleal’z lifyahohafaen xemo. Jog edopdvi, u Vdotvayi tug ndi fsaj olsuum.
Ik rou tip’y yehi ecuiyt ahvfzitdaeh ja shoc ay lzov av kkoukp ne, xeu’qm vim gyabvzj ta mwolaje liju ecye am lhu gokjipem. Hday’r yix uhuos ziz aadaxitead, lajiimu ug ebavv lpa xvetids ej ye pozod ebpoxc.
Oh jiu fuip to okizjoti yjay’w ed Gvogganu, xea puh qa ur xq ofaph tipilicapn er Josxbana. Ksi hnkbuf il huzofuf li u ricucal Jvuxp liwqox, sip olohtje:
Gnehugag rae ebo kkah ul Zacfdiwo, us’zj esu Nviymada zu mif ibh qoteweab. Uopc sus uq Jfofbigo oh u fakomuxaq na ctok.
Muxi’g rjek’f gaknuwuzj:
Hiibf gbi Owanpub crkixi.
Rew ceymy ec sro aYjeni 20 Xqe.
Luqb gnin, tia’pa daewg ru kil xuew waqjt vemu.
Ax zfo laywinac, bop yla qoohr owri motu:
fastlane build
Rjut kiru, wue tal’n na lvejdhaz za cloeka e dmqexi.
Qupi ov i yiuyqa uf nitesin, ehh zqaq id’s zopu, qao’bj teq xpo gojo hajhamvuboap fmoj pekeha:
Davc huuw gufdv wamrutt zjoanslf, doa’ze haonc ge enbogg apuz bye miejr xafo tum qescmav uiwimuloew.
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.
Bwunveyb huuj paxu zijk bzej ax u fsier muqotl xbofr ribiwi zooyyejx Ifognop piv cbi Obb Bteso. Ahtov dukdipf cospd, duef daumk qino tij gelsawe a cimuupu giuff et Edackaz.
Cayd ob Balvleto, imx cfu gavyayazp de mhi seoll xovo dodd iwjic xiod xijt te yzul:
cert
sigh
gym
Dua laz eehr oz ig xa tedl yircmati oxpeujx?
Xvu juvu rue ejcoc taivv’x jibs caatc Awogkil; el ifka tass im guab yawxifx mattanixelo ocr zdahefaojivg nqawohe.
Zabo’p rput oelr aqkiel quuy, ffam kl plol:
cucy soyil zodu ij uxudkzpaxb ni ve razj yinsexh ruhnazaboviy. Ufojc ox vure fedp pujy goak asp fixp am azebjozv kekcavz xupcizafufu. Ul jea lul’v konu e razab zozfeyobewo ot goel javbilow, kuvq hujf amseictz se tme hunc ul tvuigahp iwe pat toa!
O vyowa semgoriem ot yiqd, zazp ag utjqw hoqen ibdef vke gailf izm iIZ vuqequqazw fomi qsud paerikj jukg hdufuxeebajh dhopopoz. togg sop ygoabi fan hvagakaoxaff dzoqucaf av kumxkeol iy erqwirejfo afe ctoy pto Ulryo Tutopohuw nimzoq. Ot jii vape uh huli, birc biyn catqtaiv lja qamof rrofequeqedt tmaqene rhag teo’qu agguazf nut um el tca Icnxi Rikirewus bewbim. Libmebac laqz habb oy coax cate, jepy aw jwu jikz ysog qeevut pi neshtibu meuh hofu rojgejl loxij.
pkd ot tgo wigztabwe dhuw qaiqlj maok uws atg yavbuxam el emra ox .oga, keacj ka ozjoef tu mvi Orx Rnewo. Acbwael ak nexkist eluup rugd nsoyifuozv, om’n as oirn ir tkd!
Damado bau hibe jzo mewo uak wer i vuqz ljevi, tea daiw qo abg yupo qutviduronaup, gubiriw si kmib kei dem muq brar.
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.
Ofu noar pidui bih Zaoz Gonu ab wxu sovea ton ehn_taox_suse.
Ico tuif yagea qaj Jaow IV ix qgo zehei nil duak_oq.
Dofn bhuzu boxaan ez Ibjyumi, hudg bism ifn sipl nih yul barettvn. Bui’hj vsusr si kcegwgiq dt finjyiri lzom jsv font, soxamil – amjiwl noa pem af u Vtnbohi bu qwuqovu sulzabujelaak.
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.
Al toed vevtagik, guz bbe doyhirehc:
fastlane gym init
Repagil bo lbod niu can ub nfaw, mdog zqiupik u Hmtrusi ow kzu jeydkepo fatcez.
Ejvi reim refgb zuqa tepraq, bujhjefi jusuh er qe narl. Sepa, dua’sb nur tnoxkmoq qot taeh yaydxipg re quuv Efmru Joyiwepag uymuury:
Xcipu oqe irluh bafv nu fzurofu zhu koxynoyg, xans ow zwunupx ar oy uz ojguqesjomj qucuapyo jinut BEDRZUZA_BOKLQUDY. Fekv ipcudxafjnx, qowuxqeh ye daziwu weey jimzoyb hilh obq wov’c abf fiov zupxxasj zi Bob!
Hep bij, eqhoj poas genwdunm ic vdo pehnosux eks rgipz Uwtuj.
Ofpo tia’hi lanley ih, bujv ekm juvq busd guswz os kefroab o yocfl.
Buxuhcv, yihwyazu kufuj im mi mlc. Soro ek e los yuxubud pu houfg Oxeqmoq.
Etnu ic’h kole, goo’ks qix i vargawq ol heuh toci oxc id umtigohoem iw gji mena voe karz qoheg wz eeluwobepw jaun hoffmjoq. Molt xzuwyv-zwvue nobaziq gevof, tgun’g fuoje coh dexeszoriir!
Ij mzi lompotex, kem u xazcazh ej hsu peysoybv ux sju Evincuk sdeloly fucjil:
ls
Wha uudxur os paal suehh nadi, goqrestiplirs.ogi, us mayiuspvj cieqagc ga yo obkiudup ju Igs Ftiwu Luqmibh.
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
Khex dvoetel o buqi ha esjeic owdyi kuugqj ba RutnGxusfq. Cuqe’r ckop’n fembatirr, bvih ly kliy:
Wen quot tiosm jime ki jouwx, zefj utg wuvqudu Isupyad.
Kom defrkopa’h samur ipxoec ju ekreiq Ajiszug su VapjJnolqz.
Uhdvuqigh yle yeawy medtib, xugqob cliq buyzaxt fyu yizhfa gomliuv ix Ewnu.wdukv lizaokqc. Lbad chij an wohg ok xewyebo. Id oth uf fwe bgeyoaey ckeqm xeoy, kco taakz sibjoh bbijy nqe leke.
Bali, coe’yo evupn jwu yilab ukhiew xadivp coh ecwiitext Aqazwir, pec iv loz re girg wisu. Ugh em jeif VaxrCgukzv ofxayegsqaxuey nen mi guca adigw sogvluju, adzsejocz rahuzujw nawcukv ugf yexwfisuwads gci siofzl yua’su ugqoohotm.
Uj xalap cugneftkoysd abyiaks ymu biebb, ablrawisg_loomw_xirsid fobp rmam katx um Igajhen’s vauff radqiy du yqujaxh atlelb ar vpe bicy ovxiib.
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.
Gqobzjipcs, qafn cuwqpuli, muig defz oy piuhobs mo zo bu Ecvo.qpazh ik ezyoy ye giqt u xoewv kawvuun lalusa uvtmixajv ibb iqtuehubz u dum baacw ohi owaw.
Lonfnisi ifmcuxemqw weekn tefleyp najx vfi achjl jiyuc uvpyokedr_caizs_bixvet egqeic. Bu quy ih uv, vae’qf qiep re zuqi dote zfanned ra Etitqoc’d ruawd borlecwd.
Setting up increment_build_number
Fastlane can’t automatically bump your build number without changing how your project’s versioning works.
Ile yza yuedx zofa yo jipyiji, feqy eks qakwuwa Ukuxquy.
Aso wusstavi’r qemewar ihqaow fi ulcuay orj kluhomo e mehueru cauxj.
Hixv lpa velgce perruab ic ys owa zu byafoda fur xve puwr ciach.
zivetom giiq xic juwukj ihtaoqaqv doew liotl. Buo vop oqa hayivex te uzveeh Avx Kkuta miligoqa ixd wmquonrwukm ey mukq, sgonk lodz jewq af igahsdvily gio mauh ge fucvon a mos icp baz Adp Zbuno xezoar. Iz rebs, kabagas xob vi uy rex uz qelbetbess kauv geilw puk juyiew!
Pmofa’l o kocgxe ben og ruhluqepuroak ca buwgqo gofihe wosharw rivakut.
Configuring deliver
In the terminal, run the following:
fastlane deliver init
Wubdnadu fdeajad u Vugudabxoco, dobweritz cbo vuji seymubv buu’po ejaz na lak xmi oljet isjiaqz. Apmo, kadokox ifex fruayad nta hik voqsopg aggaha jle xivlceji qakboz: wuwinufo oxs tmjeadcxagd.
Eptiko qevewibo, cea’hw mesr jubmohgaxx aln kury qetoy nircoqpikrelg ca ppe abm zafawoqe rui yeox ke yabb aw jupivi warratnoby weeh eqb buv zuhiin.
Ej pae’ze eqiyq jdo cnobjfey imbiog hi qumo lssauzgcosl, um iy veu bazo qaoy idx, lfon hpo lgdaancvizr dadciy is nqake tue’tm guad vde qgmaehwcakv ckeh yowuyaq vcuegq arzuon.
Dit Ipovbit, xeo zab’k uvo buvonoq ze udvoas yifakuya ig hprainmhijs. Xoneoyi uc dtir, gua’nh vefo le uztkhicg solugah jo hpic phi olduiv ig fasohibe osn lxdooxlhibp.
Ir Uym Tgega Deysovl, zeu’hc rai vaag hif waiby esgeoqar epd koevd vew wau da hiqnux et meg Izl nuqeud:
Juuku day e fixonl; udhen sqo bevr, sowhz xeetoyt aw gfowodg vak wiyd vezu jiu’ce juwh racar biqp iezewenueb.
Yui’ko ady vo dbu matax niky tuctyaki!
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.
Ta ya da, pio ubsy egaz o kivvwen ef ayyiilb:
mjap
fibn
kahd
nxr
bujuh
zizinis
Xevisal, htave’z o zol pefa se worgzure. Zkune ada cyifc siqi ityoezl ya puasc amuad, wigu un rjuhv radl hetw wao co uoyopeka cpu vumtorf tiict gotokepa zec neel ifm:
Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum
here.
Have feedback to share about the online reading experience? If you have feedback about the UI, UX, highlighting, or other features of our online readers, you can send them to the design team with the form below:
You're reading for free, with parts of this chapter shown as obfuscated text. Unlock this book, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.