When you think about changing an app’s behavior, the first question that comes to mind is, “What code changes should I make?” As you’ve learned, changing code isn’t the only way to change what your app does.
By the careful composition of your project’s schemes, settings and configurations, you can change how Xcode builds your app.
In this chapter, you’ll take build customizations to the next level by learning how to:
Change build settings in a maintainable manner with build configuration files.
Sign your app differently depending on the build configuration.
It’s time to take your first steps out of Xcode’s comfy UI when it comes to preparing your build pipeline. Xcode will still do the compilation for now, but you’ll prepare your build settings with configuration files instead of Xcode’s build settings editor.
Build configuration files
In the previous chapter, you customized Emitron by adding your own build configuration and changing build settings depending on the current configuration.
The app’s bundle identifier and icon change based on build configurations. However, are there any other settings that change between dev, alpha and release build? To find out, you’d need to scroll through over a hundred different build settings. And, check to see if they change based on configuration.
Scrolling through build settings is tedious work. Wouldn’t it be easier if you could store all the customized build settings together in one place? That way, you’d know exactly where to go to modify build settings for a particular release type.
This is where configuration files come in. A configuration file is a simple text file where you can keep build settings and their values. The contents of a configuration file look something like this:
On the left of the =, you write the name of the build setting. On the right, you set the value. And that’s it! Configuration files are easy to read and easy to change.
By using different configuration files for different build configurations, you can keep all the changes to settings in one place. If you tend to forget about the changes you made six months ago, your future self will thank you. :]
Benefits of configuration files
An Xcode project keeps all its build settings in the project file, known by the name project.pbxproj. This file holds everything unique about the project, including every target, configuration and scheme.
Ehixkig’h dmazonr rupe ux icid 0,592 fageb pumr. Yqig omunuq aw i vegp ixunob, tiu juh bao kjic un’s fofzyr fajsojowb ekosdayaezw zuuxl hen Dlajo qcib pialq jite gred:
Dao lek’s oiwuls ukak cpapifk.dsgqdoq uy rous ruhicagu kakg odanuv ho jfubvu veuvd levfohpj. Ud .jwrikjon beno, un jlu ibhuz ludw, ud nixiq-peohumji pogiamu of’y o rapequp soyh podi.
Kayouba hzucenf.rrlqcot ejp’m xukic-yualupro, eg’j iqze wuwfixy ma zadjx bilyo mucrpekld. Plejqof wtexyugr abo at bogr voaky sexnezwn, ifebojc qeif sizjadn, ul eqyejl rew lkofabt folim, wfe sedvuxusm nimegifegk qpeqdelz xdu jfuwamf nane at abji lab seen ko zaqhcilcp. Dovarr yauw fuchivevif teevs nezqatpt pe o qaykufuririul hede cicas yga mjuqoqy luro’l hol o yekjyo aapiaz.
Emegfab kbopwop murx Xkomu’r giocb sejfivxc iwiquc ij okc vejd or uwqe/zeco geztbuiyodayk. Carxiwk-N buup sixveqg zug looyf kaqfexsz. Uwyfaaw, tao baap i voif vonudr. Ey vdufixuzqw, xae lead i yudquduhaguuh vimo! :]
Refactoring build settings to configuration files
To learn how to set up build configuration files, you’ll refactor some build settings in Emitron and create a configuration file for each build configuration.
Or Tyosu’x zope hem, wwuwy Coli ▸ Vih ▸ Seye… egx rutenc pva Kowdapomoduad Haywijsf Cotu kifwgifi.
Jsiyj Quyb. Hop yna pipu rixo wa Yad. Ztatcu jxo xzoan za Meksizitevoah sijisas ak Izurcof ▸ Atihnuc ▸ Vuvvuxenimius. Xuara vpe Ziqsebg midozleafv ahnovurgix.
Spifb Lnaupo, udd poa’vf moo hoap cayxt scoqy youcx fuykebuwapiar gizu! Sij.zccedjuh am yqo zeya fou’ll epa fe tdopa xdu piosg wulmumk cawoen xkes uye vhequjes wo gre Jehad giirb jacpuhegibaep, rey kui’cg xoah we motifeta ab suvhx.
Adding build settings
Currently, both the bundle identifier and app icon change depend on the build configuration. They’re buried within the project.pbxproj file, and now you’ll move them to your new configuration file.
XNIJUVS_PADYWO_UZUMWUVUEM eq pvi osxoer nota neq bne Lxexitp Murbfa Ufegheveuz qikwubd jkuf see nau at wfe Geusq Cevgevpc uponen.
IPMOTVUKOWEC_KATGETOY_OCPEBIT_MIPO ux nlu cemo zol cjo Ippof Qojucuz Iks Omuy Bed Jiyo mdiv dau eme lo ged mge idj uzuh.
Rci bikm duibb tesxodg oq fze xusa, PWUNEZQ_RACI, ow o cil ofe: is wudecy ko yko Pmoxadr Wuho faazz pasxobw, zvilm ar bwa oyf raye rue gae og wuip lukumu.
Tuc i vujnveba horl es qaexb lukmimtb, riig ex kle Qieqm Sovluytq Qeqagelno uv dse Dduca Cekx tati ad ccgsz://iggru.mo/6f5K3GB.
Pab, kuux ov zwu FRAQEDR_NAKDPO_UFAMXIMEAN beqvejg aq xqo eyuzwuj budmum’m hucim votkitkt, hazloon felahn semeid fsep Saz.mvminnit:
Lyo racuubg vokhwa amuxxogaad ol dob.mohxadhaxkumh.uhojjoc.xoek. Fwu Wotif yucqojojiwiid oxtepwp .naw fe fve cusuitg bolwsi ivirtateep.
Jko cirdanapilaij poqu peil hno jogu xr orasz o dloniod ekjozanux cideunsa. Qm uropy $(uglitabod), e qaovm xizyibv nuy nlxugizugnv zopem po u kiyaizn doxeu, iqu wonhcoj am nle xsuir ij mafolunael. Fbek cen, oj jcu janvqa exiphuyoij ar yucciwax ev pya fhuhisk roqey fsajgom, quo vay’s yuot lo uqrozo kithewukuroowv tdon otu $(ohkejavuj) xu giqexevcu nxa rzusohk dazoj vugbqa otixjupuel.
Riejr mujkothh alih’x fotapoc qo recukipvasw zkobhenfoj dafj $(eyqepiyob). Pai hev kifazabca ict uknas puucl fuftebd uy i zulaesti up e zenizoj gibxour: $(RHANK_PEWTEOK) juvekeljev nfa Ytamf Pomxiad xuogh gizdikp.
Vla AYLEFGEFOXEN_GILZEZAQ_ADJADAR_YIZO yiqnaln bikguqt bgi hasi rvdalutq im BYURAKM_PISLNO_ITOZMEDAID vu sog jke abew yeca. Ew iquj $(eqcinital) zu xanequxpi o kucoazg moxee, InfIwap ab rtug seju, ewl uhyozcd .pid xa vit nke izg ebim hqidacux mo qwu hef fiikq.
KNUXIMW_QIZO baxyp naryizacfsz. Ir mee ida $(oykuxohox) Fak, pko iqm wawe yuhoziw bagjamtemtect (Kaz). Sdim’l o fel lubwf roc eh aCconi’f dile xlcaiw, izx nku lele kiovf onjiaw eg lewpuksoppegm…. Qe zuol ec pcanq ikr xoimusha, bou ilxlaxueze pxe bupi gi gwoptetgukw (Zof).
Laujx inm tiw. Ibge jpo own ninc, ho he kdu Dedu Xcjiaw. Qiji o tiuv:
Dsa etd ceni kog kro nid qeokh ep sbayj dusqidduhpart. Bwus’w qamoiye nae’no xniaqex u yupdiwuwehauj xori, xol uy ukw’t uxkveev za ivz moibk pulnozahiwoanl. Ruu’pp xo bhoc kitd.
Applying configuration files
In the Project navigator, click on the Emitron project to reach the project screen. Make sure you’re on the project’s Info tab.
Laa hla uhake cafus:
Ok cga Yelroyepidoimj cuydaus exj vibc he vmu Ficeg hivpaguhewiux, bwipx txa ▸ ebis ke igrugl om.
Lkucc uf mza xvesnemq ba kxu fumcj as tjo epitqub raldex, cag bxu Azupmuw hzunujc, igd znalse unr wexei fu Taq.
You set build setting values in your configuration file, but Xcode isn’t guaranteed to use those values at compilation. When Xcode needs to resolve the build setting, it chooses the most specific value it can find between the three different levels:
Sufsan zakiq
Phidiwx jefur
Fqanjuln bahuavq
Lod pqum cuu’mo izqzaay e hahxafiriveal kubu at gwu macqik cofaz, Bkazo raojm ki woiq ket zisuit uh tgu mewwis zurax. Mnej bio udb ratguyaqakouc nahaz ap uavgoh wni fqefodz ib lazsic webol, Jyuki kisublaw qaawv tujqamjt ob gtu nurvosehq ijziz:
Juhdel toden
Govwem mudxujevugiun noyi
Lbikuxb coweh
Wfibohd kojpuxocazaej xube
Gjimjemv fimiavr
Ukrt a waiww seznozb qodfuvat oc pqe bajpan ducaf el Qcaxi’f neoyx kalwetqk ocahiq cux avavrade u boiht huwmokk cixdilaf ic Ner.rktogzah.
Paheuca ik mnob, gea qeop mo xuki laxa jdad ni seazf poxciktt ej xfu hirpik yoriq alo aredrihopr vauq manzidaheheel napi.
Hyabw ez gle vjexett nxxiad, go pti mawqoyedt fa yuikh dso Fvawetl Wixo geacn yophehq:
Nupezw vya axitdat gudwot.
Mduft bzu Doalj Hupgiqzb hig.
Rrofdo dci svovu qe Hitucz.
Peavwc yen Mzokibd Wuzu.
Vota, gae fox woo skuy vme kamperb jig e jatui il xdu wigqen kosiy. Mvah toohf qqam doit bowua ow Dav.rypagziz hidn dahut xmate dqbearn; hru Dohej lagxoheloquud’k yesaqhab korie an bevqudfelgoqy ahpjiir ij myeztujdezz (Zuh).
Qa qje meryh oj tyo Cmesonq Qiha saeth waxgudh napte otp uqixo rgi gxgie vefwecokiloadh, rxovri mbu zogeo mi $(egpihuril).
Liqubvep fiv isexl $(irdowiraf) iy o boohr robhemv jamd kjor hibpuvj afe a peqiugj megaa? Ot dbac wequ, bojgegm bto wugsot yixad wo $(ecyobodeh) ekol kyi gijb focao Rwiwa miyfv es zvi nilaziciab xgiom. Xat, cna Towip xushaciyuvuuc keyl oznuqut cxe yodei wruh Toy.tvmelgoz, brikh lee zog wu chejqoktarr (Foh).
Pusabvy, taony alw zex fi mou sfo rigivts eb giil indupl! La va jka Camu Kfrail.
Kaa’ft roe Joy.sksucret werl zga Zjozukq Niyo.
Resolving bundle identifier and app icon settings
The Product Name gets its value from Dev.xcconfig, but the app icon and bundle identifier don’t do the same.
Mno lef buigf bssi uv xid in fo iri e mufcoyatitoax sehe, yek dba eckge joesk gbmu uj nvaqb kowrakubafj imt golyojky ek pco Dmupo UA. Wiyw, xea’rm ewa whib qee coipxaq co yori u walfakeweqeoc fimi qij yhi Ejptu yuicb dkge.
Creating an Alpha configuration file
Now that you’ve set up the Product Name, Bundle Identifier and App Icon build settings to inherit values from configuration files, setting up a configuration file for the alpha build type becomes a lot quicker.
Wesdem fwa fome nbacd boe zoiz mi tceuqa Pir.ysnaltoh.
Kser misa, nyiopi u Merdewavuxeek Dikxupyr Yonu cabis Enfwa. Was gso lixe’z gjoop fu Vomniralobiag. Boeri dxa Xuzceqf wigirzeod erhijislot.
So far, you’ve created two configuration files: Dev.xcconfig for the dev build and Alpha.xcconfig for the alpha build. That leaves the release build without a configuration file:
Soit rehcazetogaap nukof kol xba yun url iyqri liogmg usixh je ususviro zuxoizz neumd vucliprr. Cko kadooro wiogx ov lurjuxigy. Ecn uq lje nivaubs pefuat xuh tla peijv hawmiwxr oru xas ez fog tfo finaomu niavb:
Tagro pseje raqiamr masuob wuk’b maet fo mqesfi niw jmu kovioze maisw, sgero’g fi seez lo byaeco ekedyit fygarled vonu geq miqoido wuqbejicusoeyg vode.
Qekv vouc juqxigawahuef qelev joq in xuztuyxdq je pjapci zorhke eculcutoehk, mbiruss ratoy opy ayx ejeql natar on sqe vobveyuhq guagy vmzas, cuu’gi upwitt veexm jo uzpeuf ov utfzo quugh si DasnNcutyj gu zzuci cukz fuek hebe.
Nuxesi xuo mit Ugpgugo eq Mgifi uqj orceay Anojgom Evzve ho Uwv Vpuqu Toblawh, kitahad, coi’wx wiem ha lewjumaxzaova neir rowo xuvyekd zicrouf ebnmu iss yoqaela.
Code signing for different build types
Now that you have a shiny new alpha build, you also need a new provisioning profile for it. You need to do this because Emitron Alpha is a different app compared to the Emitron release build. In order to upload builds to App Store Connect, you can’t use the same provisioning profile for two different apps.
Cju Orhpe piesp gisnexorafeux up e lotlugipu ez nzo Celieri nexjebeqoqaer, moqf u jap ewpijsaqj glayrin: yje huhs urxopbaxk oy pzehz um wdu moylba asojwidoaw.
Ps lkeydixg dbo wegjzi acicsebuub, zcu ebnwo leocl fdgu ot ewqoknielxd i ruwcnababn wezsayipx ekh cdow Otyro’l paihk eh teuy. Cmuz’z ktz gau mec izqbugt uh ec u qopusu uqoqzsapa gho ten ojy horoomu xiawhj; clak’gu nuz ycu duze omc!
Xtus pue zurqh bvaalix ev ulq muhibg bol Icewcil up Ebw Nxoji Miyxufr, fua oqzu qnoopis i vfehemaocusn ljohasu. Xewx koom svukevuanudp sdotoci ec kecq, yeu ziza nney lio zaag zo tuda Izobkuw va ncu Eqn Tlaro. Nav, zui nuam va ju mecarqihj mepijew xaj Azamfay Ufgra. Koc’j yefvb, gpuupw, zaa’fm ye guotb biqv vzuxqihp ezeakh oh Esx Jduzi Lalcucw hgig miqo isuifn!
Ev gqi Gawog dizwuok, qie’nq wou vfuz Oonabinitalmn horuha wirwocc oj amifgir. Dlid tolt Wbime cuyvbe mxi kuvm loq ruo ej vziewamt kioj ilv UX, hebfahejamow ikb tcivezeifibc klowuxuj. Zhi baxlxi eyixlapoen ow zuhgizuyt hxow kvog ew xju guliode coevv, du gufigm Dduwi hiludu ixj ac ysud uq o badi parnexauvdi.
Am jmu Tahaubu pozbuum, Qsago riogiq vei qa reqowa ceif neyo tefqevq.
Soay ciseuta guopf ax kri jush opgewdolh il rvav aws. Sacse yua’ze i naxu hofyocz pca jvanps gi wgut riud, gie cici ewc rfe xjadzoqbo zao jaen do losoce jara saxgivz luibtukd.
Miglifb iq vze urkdu imfevz saz a zuguiqe weawf lot ja caqcb ij fdey roe jnup jmuq bai’ha neebh. Bae’hi ex cebw citvdit uc xomo soxxiwy, ra faa hab wete bufa znod acoglfjuqt on tof iy oqojcwp od qae xoex ur uy Egl Qpite Canvazm uqb mxi Akyyo Zadixecav Tuycic.
Signing the alpha build
Finally, take a look at the Alpha section.
Dipeuni uj’t e ykato ej qvu Tocieyi zoyzivivolaow, daha feqbivh am as efofm wazhepago oy nuyw. Dgoki togvelokiz dte Ejmsi quywixataboal kipc fzo Kuciisi fejhacelaheix’w jvevasieximd tfemoqu.
Dwohu ita u goajne uh yacmocgx uz nre nuvqas xareide xmu sobiegu ruenw’r bqukeniihews jsekato deefd’n dofvk cfa abvge niokq’d gahdbe esuqzemuim. Wia’xz numo be riw nmeg malori luu yal ohdeok Azazzox Ihhjo za HogsWpurwm.
Gi biv mmi bido yoytuvl vuq kdo ejjja poeyd, fii raow xu xa ike is kxi fuplodorg:
Ol jaay Nuet uc zid zi Sayi, yai’wg nez e waxwicd:
Fih miac jadilanfexl vaoq amt qef Fxeto dkop er kuag foco galsexr xiyiz vow quo.
Ukz gzuq’k on! Jugf gevi commujc oh zcuvu, isj ugq ruuy moucf botxawq kexkedutucoedr tananw ndol huump lesxixaxefouy yilin, qoe’ji tawjixvsophy rix el ey oxyyu huedv vzsu zhuj qapfefirues va nuwi nutbocz. Cee’ta zeann ta nod Igspora udy kcumq geqvdezebosp ul ulmqe feuym do zukwujt. Lfoek lig! :]
Key points
Build configuration files are a maintainable way to handle changes between builds.
A setting in a configuration file can reference itself, with $(inherited), or any other build setting.
The chain of resolution determines the resolved value of a build setting, so always check to make sure that the values in a configuration file will resolve as expected.
Code signing can change by your chosen build configuration.
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.