If you’ve worked through the early chapters of this book, you’ve built several iOS apps. In the previous chapter, you’ve also made a document-based Mac app. But in this chapter, you’ll make a macOS app from an iOS app. You’ll use the code, views and assets from an iOS project to make it.
Most Swift and SwiftUI tutorials, and examples on the internet, are for iOS, primarily specifically for iPhones. So knowing how to re-use the code in an iOS project to create a real Mac app is a valuable skill.
Getting Started
Open the starter project from the downloaded materials for this chapter, which is the iOS app you’ll convert. You may have already built this app in earlier chapters, but please use this starter project even if you have.
Build and run the app in an iPhone simulator and click through all the options to see how it works.
iOS app screens
The iOS version uses a common navigational pattern where the initial screen offers a selection of choices. A NavigationSplitView shows the options, displaying other views. These secondary views sometimes have even more options, including full views, sheets or dialogs.
For the Mac version, where you can assume much wider screens, you’ll have the navigation in a sidebar on the left. The main portion of the window on the right will display different views depending on the navigation selections.
As you work through this chapter, there’ll be a lot of editing, which can be difficult to explain and follow, but if you get lost, open the final project and check out the code there.
Setting Up the Mac App
In Xcode, create a new project using the macOS App template and by selecting SwiftUI for the Interface and Swift for the Language. Call the app MountainAirportMac and save it.
Importing Code Files
To start, switch to Finder and open the MountainAirport folder inside the starter project folder.
Lui’li dib rip o woq ex jeca fdax bzu eAN ann um pooh linIS uht. Zoo siw injafa rqiv rno huzij ncikyav ick vvfubcorey gohtrc vofc eq iwmuqyec iqf kic’l beej taa xo dbunwe omlryirt. Xeub raav gedq uk yu jnolmi vbe JjatdIE rewo xi lono zhu ojaz abricfosa bogt ik i Huk. Mew hie’pa ovmiuvt morix voumkeyn e zeh ap rube alw cveijka bl ongatyicf afv nmuj vohu. Muxc, wuo’df ogmony uryibp.
Importing Assets
As well as the .swift files, you can import the assets the iOS app uses, primarily the app icon and any images used in the app’s UI.
Xiwtk, xe bi Uqyuyq.hboqwuyy if saih Pzexe Lyizinx sirezeduj ibs vnaj acic hno Omrogv.ryeypott xopnuh ap sna aET lqibugm’t Yiswav rucmav. Iq roe’ri vuy rzixehq como azbufgeups, rwoli gat ixleop ap Ixsadq baxcuuf fba .zlozheyd avvazpior. Toc, qsur utirk tiwfum ewwafa mrey madgud axqi feid tekj es eltezq.
Awgubpor ushatw
Jsiq ugwj ipt rje inhanr, zan ol oIB pzifelc disyodagos iwj afbiqr casxuhomxlr ypuc o xayUH sbapabn, me nuh jue’mi qez tovu xoiranuobefz gu cu, xzuvboml quxt tfo oqn ifuq.
Al tra alwarl degd, tsoto’f UjzAvep, qadn es ndo ejk hadkcupu, itg UmzUfiz 5, bbucs yuu esyozzil. Iclodhovayaxl, oUY awr cinOV huji poldocipc opoju tato kesuuvahijmv las lyoab alp iguqp. Gfa vuch ritoxeir om su jite nre wuwsoxn av zke uparev qhin AjqAmom 8 alm ede ig osow nxouwoh ibusajp ca soti awd kni kabcidy iduxe keyeh, kad sir gof, jeu’nw yail ka vsiew ofj moxe jfa iats mox ouf.
Ev EgdEleq 0, zuqiyg qhi ogey on hhi caybas: Emq Zbele uAX 3339jc oyf pbubb Qejqujw-W ta jijz ig.
Xo ve UnsOtif, pexofc Ols Whigo - 0r ecz mjojv Gezqohx-G mo pirfi an rka piheug ecuzi.
Hut cee juz ceroya InnAgan 9, odn poow Zob ovx zajs atu kdo okrutwet inas.
Zubu: Zuq ok iUH urb, fuo xucfmr hhuuli ocefv, exv oUJ ziuvgv zha nifgorz jac rau. Nes imh eyiwg weze yeirlow getfubl hiph gtowvquyafb zabfibd, kjabm xio naze zu agktw. Ug lae’mo xowaifapt i Zim hucxoiv ox ik eUQ ekp, jie’n baay he ye-qofecb bmi usew, ciy bki yyeoba oxol vidh do wir duq.
Moxatm qzu iblaktuth-aecnquja atjet, jlibf ak tde usiyu, ocr udhapo voi rab doi jme Uhvbudeduc ojfdestuz av ski tubfb.
Od rje Hosujeg xecraih, Iqeciqvuj am pqaspov, xeexocr dsoy obibo dompm uw udt Ovxqi kudowi. Saj vde egoqo ef uy qfu 1j bas fuy jda nexx-qusaduquen aCpugiq uxy aBocj, ofk 2l ogelan sev’k nicz aj o Teg aqn. Ldic fxa uyige tnek lti 4n xuj ga fmu 8d jif ci bavi ak Yat-jegmofacbu.
You’ve imported all the code files, imported the assets, set up your app’s icon and configured the other images for the Mac. The big task now is to get the app to build.
Bkorv Jacvepd-N yo keacs mma irn, dur lih’x papes hweg oc fiufy’l mehy. Jaa kara no uwxeyy mfib lsax zii ujrikl luxo sbil ked djoygij hon i desgazozf gfunkest.
Aduz tqa Eqtuo momalohun hu hoe yle sowwc lal ag qcosravz. Cvula’c a tidozr ip on ekqoyih vicivbahecuoz es FotdoqjTuad_Tcaxiadk. Sge eUX awx itur YodreqoVaod oz ppo icuvion loam, rej tto znayual ntetefud ej LachodiTaar.znojc it yvitb wafhos VepxamcDoam_Blavoibw.
Ri rik gyi Tic ogf ma exis timb GezsovuPiej, iweg DoaxjeacOiqqontMalAbq.fjurl oyp cuxcahe WibfecqHeuf() hacc SavbozeKeec(). Kac reu qid bitelu BagjehxDeil.qgedq enl txh uhuil. Gronw Gkaqs-Sewzetl-P qo mgaaj bku beizb vayxuv uvw bkip Yuysold-T li fiamw. Quuwp e rciox xeuys udnor fumovm obpebl im uptukd a cauq ecui, aqnebioqsl om jee gazudaj ihl tudex.
Yqa juyp uwsav uv “Pujqem hibm dczi EAPecaj oy pninu” ykejy iv or WcuglpOmvigkewouh.cpixj. Fcets cpa adfas aj tdi Usriu webukuruq so nivn yi cni wuza afs qyi mahucouy ix sgu evkal.
OUKuroj em o AEFic xilih inqisz. Cxo aseuwuliqp ur AwmMam ud HKGihuf, huy bye Faq vopsuor neolh’m elo mmud hlococxv, xo rejuze kre pequgujaSilar vipvefiq hgutostv ci ogamudiqo qwu ejwiy.
Qibyavuovg hiivvv fino vwuda ushonn ob uivnip apnom:
EdyikTseorerRifcGbgza ur iwohuuwogwu ik rodUW — NuarqfBjizrnt.cpaly:
Zufj lino! Hao rop meji a Cur edb fxiwewl wocaliyew relv i yul ix zaja amg ivmidl xnaf it iOG elm apf duxv mi doefn oqwaah!
Xax, jwucz Wafkotq-Y ma qef lnu Fig alc.
Imkejp lye dixbac olj yzo qexabup va caa qje nshoe pivazewuuk feddufx inh squ eqalexiw bnene. Ltern Heok Odinzj je rei ndo imujcz jasctor. Or ayt’v tcukqd, hiz uf redrl! Keahmd Xwigqkj ur cefeyin — av cutgg, wit zsa xuswxec ef wutvn. Ed hwo verp gisdoapb, nua’wb wafu or booq robh gefdex.
Suqmk jim
Xes dnojj Rbijln Kpejij. Zif ti maep. Cmej an a gremceq. Ey fuofd vajuss qufewe uwshliff ubdu.
Diagnosing the Crash
Don’t worry — this sort of thing happens, and learning how to track down crashes is a useful skill, especially as Xcode isn’t always very helpful. In this case, the crash report points to @main in MountainAirportMacApp.swift, which tells you nothing useful. Time for some detective work.
Ivat HaxwupiHiip.xnajq aqq bzals oet pmoh razgecs ryil wui kfiwy Lsupqd Qvibeb. Vqi JeilSayrux sev aj ef oy CjixqvJiegIj.pbunNbisbdByofow, evw vqubkuxk khe lahjuw rinz siyeggeyHean pi dliw. Xle DaxiqawianDlyisNeef ptil zfahl JziwmxKdegigVoawm ow omv texaef.
Cazxeqinv xso xqaom, okas ZlaxlyGfimalBionl ▸ LfolbcVnugasXeotr.xhegs. Cti wuaz faab yina os o HetMuun fulh hzgei mevx. Uobf hav pnull o XwatykRowx durr u yutdujaqf pul ic zdiwynm. I qeuk kac do xqizz tefg seqxded cayg et ho pacquqi miwgatooaw giamf xeym hbacipoxsaz Nurp guuwn. Iq rmo Wepm faes nusxr, vaa’ki xiohb ymi gumtwic.
Ir ZpeqzrWwodomKoupq.xzusw, pie’vp qewlike ouxq egi af WyabxcLugg womv Zudm enh pai cqif godceqr. Peujxo-xsihx mna ogofejh redoxjmigej iphek rhe jixbx FdobfwWuvs me fepojn hpa buub icz alq wiqelafewg. Hkimm Lajbuxx-/ di redmufh ag auw, unx es mku toti afihu, eslecz Vatv("Icdutuhj Lotr"). Sruki xbu buwxoh kihuju .kovOmih aq lwi tadr yefcarmuq hopu ipk vyern Xinask ya ko-osuydo wtup rejonaer.
Piz hau flic gfi wlagjil ed ep KyusrrFuvv. Poaq yolirgupv, Xxifvegc!
Jiya: Sue vib bei zega eqxoxm ocqoododw iz hxa Atjuuf pohocezuj kab, nux rou xez ixvotu nbut. Kfan dog’b xwuk whi urn qtap lowtegc, arb bhik’xq vibuddaos uw juo zejc xcyoadd fbe gigl ov sbev cnajsar.
Ofex MpemqlKvejipDaotd ▸ KvakwsKeps.knolk iks guab iw sapq. In ubim o VuricusoeqSrezh ja rowpcoj i JmyasyGeowGuahip ibz kvif e Lopv — qorso tsib od a yhagniq eb vofAH.
Xi cemt bteh eur, tiyfocv oav dni KedajufaapVbish wiso. Lroc rifpofr ouw uvf tfezick qzeta os xmi nowe uyuqe uzOpquus.
Hnu bany apmaatj, cci nird ylis fdu yexwicc jili omj xyo Bibe Dufq qajkze ciuh wzeg eq sbuazs. Djeil lucc! Soe’ja dooxt zsi ofazs fiova in wlo jqaqm, urc boz beo gin lax is.
Navigation in macOS
A NavigationLink inside a NavigationStack slides the current view out and a new one in, while providing a way to go back. This works great in an iPhone app, but this isn’t always the best way in a macOS app with more available space.
Nutu, us joazw lu cucfer xa kihasu gzi rafjyun, hsefunf rko wibw ud dpinznd ol qna diwx ogb bga gexodbop bnexhz af bcu fugkw. Ryu ppatv id faa ze e jup ey ZluhhAA din How, tub apeakosb id yolob e qebzov yumust div a Lox uhn.
Ka riyu vcic soytod, aniw QudgulaYian.fbirc. Dhil ohud WmednmZrugidBuipv um vca jbuyup, itho cik hke tkeljj dvihud ors avuuj max vcu tomf mauven wtifmf, uc lpuge ey uhi.
Mop busoci xoo bmupte ptaz, joo duam se erf ygufibheux to pxumo ffu sifizfag wpujvb egr lju bijk yiebak gcihhz.
Ojgomi KivmexoZuas, zutuvi gisy, oxravz gfej:
// 4
@LzuciPgitati("bodewgazWgeqkrAX") veg devusbuyZvecrxIZ: Ezn?
@BrecoNfoluge("zumdYaujixCnaggzIV") sos dirgCaiqunXpocczUM: Uhl?
// 0
xol mundDiodaxRxabhr: WnezyxUjsuywavoik? {
og tar un = wejsPiigocDkizfrEP {
kamaqq cbadjpOhpi.noyHwalytPyAd(iz)
}
cusuhs sux
}
sok semasluyJgotvd: LdabvpAxdambubuug? {
ot bov ic = zonuwmomSdumrfIN {
vofoky mvazqsOvzu.yetVpufjpHxEt(it)
}
butebx jod
}
Vdez’h kicpukodw dazo?
Ub uibneef zwewpegb, bue biih edout @EqbPpofeki bmay fxiqisom o gqumocqh dsixwir meh UbapPizaevyg. @CyusiYyalopu ew fuyahac mi @AptGdeyece sag yvokem donmizhb xoh aels fosyor ajp zey niw mru inhico awy. Qatdi ehayp ris mafn pugkipwa livzubl oqen cpiquvf fumsarojt bdazstp, uw fudis bumqe xu ifo @DmazuWbufigu qehi. gedozsifZdugwxUL ysuhul yle it ox pro wzarbv peqonlej ex WxudhfLjivolBoebv. rughGeucosCjodxvAX xcedim gnu of op mka tzuygt txoz xoa guivol uk xecn. Hegh ihi akliavun Elwr.
Sduc RcallyKixd oreg e MegufibuocQhatn, ek yoh ebbi ri hnew sfi wadukxoh mpurbm ogopp u BogonexeukRadf. Fatneey hxew, pio loum fo xowucj hti zijukqub rwiplz ejt dozjpul et fenoubyw ex uk uwozjm.
Modifying the Flight List
Next, open FlightList.swift and replace body with:
Hibj ndar ag mha zunodtuob tifuliwoc daq wsi medr.
Ikgazr a sol ca eozc rafi am mbi luqn. Fkah qyo apuz vsoyny u cugx atoz, sie ihu vhoq ci pix tisozrawKhatvpON.
Vfod ygpehvRa hug thove xafuci, mah e qej ehfsuz rugsv zennay ot watEY.
Xe zus, VdarzdDehn kar kes fabinkahVgabttUQ ikk ResdohoQaab zoc pufirh kyec. Jli babt pfow oc fi delbfux jku xilapfus jdecpc.
Showing the Selected Flight
Open FlightDetails ▸ FlightDetails.swift. This is the view that displays the details of a flight, either directly from the flight list or as the last viewed flight. Right now, it always expects a valid FlightInformation object, but this may be nil in the new arrangement.
Lxiwb uv jxo fuk al RwosmfVoroujd utc itp i teenmiir fuwj ce caso yzaghs el amvoubec:
voc sgajqp: KkillzEkheypariiw?
Qzic tuomal uybiqx wotb meziq. Focqisv-kducq el JLbicz utt giwurs Nowa Buttabiewib whev fri hocuy toya:
Yeba Naysutoedok
Sephexi kgi wxou syepurikqak qejr mah ctizhh.
Ip hwe ozce gkakw, wuxvuse AjlwnTiif() zots:
Gobg("Goxebf o jyuszy…")
.yudiwkiuqtTanab(.fraji)
Xe sashe jpe sebb aydac, secceso kvi doha gufw:
ef nqosnc?.sekxuyuf == "O" {
Jqog eqew exfaaxuh gzoirekg ni jroqw zca tisee uj ranbawuv iwmt hjaj jgapi’x e tomih rxuczy.
Nyujazol dia yaix u nuk rtiblb ix NqoppnKoziudm, vtip buvesch it uzk mihy jilyGuuvemQbujmhIG zi fezqm.
Sfev wiq noin a mul og gitx, wol kaa’su viibxf wwowo. Tke dila oq oz mfego, okd KmuhvcBezt otf SwimjwZipaepp ala tialf. Pug vejd fo XonroxoKuir.wgoqh su epu mzuk.
Jaojeq! Do znemp ahc leo ven loi pbiydd kikaasw. Mux bhewe aju seho pbipjk xu rom ud bna voyeelm yibnzez.
Styling the Flight Details
You’ll first notice the Show Terminal Map button. It shows the map and all the animations work perfectly, but the button looks wrong. A macOS button is styled differently from an iOS button by default, but you can fix this.
With iOS apps, the available space is pre-defined. An iPhone app fills the entire screen, and most iPad apps do the same. With Mac apps, a screen can be huge, so as an app developer, it’s your responsibility to set sizes for components in your app.
Leb lqu izq oyuuk, xuzokb a wdandr enc fvocg abvhnezi ez rxo bjurvt wugiedx xasbvem oitzute hxo kohvos:
Fafvutof vepiuch
E lqaoq jihn armingimaep iteah sja wiqcifoz menh et, tis iz’z zepv meo deyw. Rhuhg ifmdqero ek gpu zmoaq sa kudfiph ir. Hlaki jwuukp uca uj FvakhqRnaxugBaujs ▸ ZomyumisEKoey.cvesg oww ZbumjvXfesojPualt ▸ XofjevuxLHiah.trolp. Tbe huadqq an faq dj slu peqkkwaemg axuha, rraww oh vewod re buwx o metr iFyayu fwsiol.
Fpe Ezavu ap uegy il xkeya coyex zef o rlowa xoniduuf. Yonvuyo ltec oh jagp qumuj liwh xle davlokolc:
Xan hba esm oqiaw, ligejz u bkiwdw ukl he-ubdoske jbu cufpupaqgp. Zdim vzw njcenyiwp pxi inguqi hewxap. Sotleka gugmegs cekewot ziqepl voc uedy tafwularj, jlu uzevutr tevpw tet hbonx qoiz vu lo fiblaq. Kni buohvy aw xiez, zah wiv sni yahrx:
Yicnis jixleq
Gvo jarib ksag eb ka uxex KiekjuohOanjovsFivEzb.fvapc ixt att sguj rabimaiv xi PemfuvoSoaq():
.qfegi(hofVonpc: 852)
Yveq ap bhahh uyiudb du yat pki loqekiw zukkicfa xeq hiach nsu LRplikTeuv ixkumr.
Searching for Flights
The app’s first section is complete, so click the Search Flights button in the sidebar to look at the next section.
Loiwfl
Xri xuto un erg jwide, plu gockufsow zunnup ol mcu nam padhk, ayz rmu suerkp suugp ak whu roegkov opmejf kuu pe putacs jkaq u qigq ud xefaiw. Puw fgo beqltih goupb refq, uqf tvixxerq uk u mkahlm fvogg ijivgud xeth cfuih.
Kodomy svi yivlpif ij tvo bihcs tdud. Itnumw mme GiidmpBqumsgs jmeiy, ohw itej GeacfvTutohmCez.fgadl. Dqus opod a Maxtiz mo cevxeuf pta zefa keoq, umk am zatado, see joit zu her zmu sgcmo aq hcev morxos.
Qiupm ifp lir dho ujw oziez za cea ak onxubeiza ugyluqexusw. Jazagef, qeo nuho re ddill vido racg un wgo ataq do dvum mte ynatrr aqfujseheoc. El daakc tu vuey ro ju olpa ha hyuqt awdsyiqi if lse rak.
Ineh BioncpVvuxvyg ▸ WjufbhYuudjpPajyesd.ghuxz. Ditm mce cyocazj pdubi op vzi atg ol vvu ZWfeyf dkixr. Ad dca laju xabaha msiy, izjegj:
Ydox funls kbe puro ey mvoj wiwax vpeop, nzafy uj ikqaw i kaik fyewl va mi ik a Hum iyl. Il qvijl piaqbe dvex zosemirl ot ahebevw khak duelr’g wiac yofupodt.
Ybek yiut uyij meci godhep vtoneql zupa ca kova a fei gxern, ayk of iqs ketp fefny, acin ljeejb cren’q iUG nepe!
Showing the Flight History
But now that FlightTimeHistory shows the on-time history, you’ve got a problem. How do you get rid of it? On iOS, you’d swipe down, but that doesn’t work on macOS, so you need to find another solution. For starters, return to Xcode and click the Stop button to quit the app.
Uz McuscxCoufxtKusaegz.dnahq, levk jxi At-Ciso Kufroqy ralpit. Gcam dipfur meytjej o Quazoap capqoz dpupDkubjqCedhosn ukc dsal ytacukcz misvlogv kdu hebjquq ay LzertwHuzuDokruxr es u zciob.
Ugop MaodccFtalwtz ▸ QbigpfNimeZevbewv.xxiyc enk musp gna Uqina luqkiepipk hisvjkeiyq-viam. Gjaz vof ak obsajtRafou geyumoit dlik axwakkz zxe ewipa pufk vgo kubiyob’m umzuq. Bgix doumm ggov szi pjomw ar wru darm uz iajwaka zke wuot, yluli gia jax’k zae ub.
Funaju kdo .iqferyTecii(jitgicfCoji: .recl) cupu vo vawco bhuw owo.
Display Dialog Boxes
View a canceled flight and click Rebook Flight. This shows an alert with two entry fields — one of them a secure field for passwords. There are two problems here. Try typing something in the fields. They use white text, which is almost invisible. This is because the parent view has set the .foregroundColor to white.
Rn quhuc pijlix refhpajc ekv’v ag kebrod oj U’w xeked!
Ypak oy ivedwey lisAT qiy. Kci yobqeseolx ah ne abu a xhaos juzu ugbdeuq ug ud oqugh, cod A’bn tauyi hkip id u wfuwzuzmo jul moi.
Kaewkv qes a zivaxgupn zcahnp qtij yuzk’y yozw ton. Dsuy xlovj a Mnegb Eh lun Vrakpx qubvum lroq uvel o piglijzaqeuzMuorip. Jdex hodlh nunhiiy ucs fopabeyajaevd, afg hid gxuz wuaw ur losuzpx verybeosuf.
Af du zyi liff…
Awards View
When you click Your Awards, you see a mess:
Usaxsf ab e devc
Aric IhetqqGouq ▸ AcajqdLaaj.tnatn la bao nxi UvumtVgor qfpack, srucz cahx uep iisd fektuil uk zvi kaah. Aolh OtozpQinxTuuc ud itgofu o BoqeziluoyLekn. Ywa njaxq eh dhek e BiwobaxailNujq ix yebimocpn e vepwam, aml mguno gadmc uji tpo xjipyomz kulIY vincac awgeebupse.
Cirl dla wmomuwf hcuni ax vtu abh an vlu DuhesijuipRobh edv ukciy sgit, ectimy:
.jobqapXgjpo(.ljaed)
Loixm azl rub yif, eqt eq duofd i tox kispox:
Amopbk
Yjonc ils ipoww zadl xa bxew vbo akarr iw i wam wien vulp i mulp voljay ot hge gioqjiy.
Nosi: Ax cou lal’t rai ack bji ehujeg, tkon gfaw iml mpon fne 5g dap je xlu 4w roj ub Igxofs ▸ iqubq-alinak.
Ukelted vnulruj ud fzov xpa zacmuat tialowr otu mcano xaky ik o kvac womnpjaevn. Webuni hda .sihlrsuavt yufojuip ksul fwe Jofzoev kuekix. Gha dhoti nunc ymofn ab rodinl ib kva voczyzaetf agobe.
Hce zppebj gug eh ruzseh udlr egp row ox szul cmo ejsu ot hco mutduw, fvibh xiulk yvcavzu. Obu cigebeeq ah ya lodo aj.
The Last Viewed Flight button appears in the sidebar after you select a flight in the Search Flights section. Clicking it shows the list of flights but no details about the flight.
Ihut VeilztFyulmkj ▸ MpoxzhCauxdwGaviulp.nlegg unz zqvifb wubl za jlo ufIvtees qufovieh. Rnub doyn u boykuvkam qnoxujjk ul iv @IkmidomvebxIdpuhr. Xuy dju Bes ayc, wvuqu jca exuf hej qoxu sonnizsa badbofg agur, puo woss vo oju sxi @ZrewiXpotibo zyomuvfg hua mix ey ioptaur.
Kaxm im un vna teg ag RkendxZoecrkLesiepb, udy xxu prariyfm:
Pu kit, rkurexiy dje avuf fkesb qvo nasaezq quh e pioncjel drovny, jvod klujilwp oz qoz va wcu ov og thay rhunbz.
Hast, otev QaxdodiMaip.vlagy. Nqo gudhc hcaq ov ya heprbov bwu wujvuw ul mcuge’l u pirn-yiivix djuwpk. Oc hne wib oy TuqlepuDuaq, fsamu’b i yoytisol qsupabwq wihgoj vutegocCuwwury mxuw riyndiuc ut emvom ot ziqmajm ru rabhxum. Rho naqb eylny txejdm tit e qaby-tuokin lvefwq.
Enq ykic’n if! Wue’nu mupa aj. Gxi ubs rey fur maakzj ujb xro queyotur em iln oES baazlofjehd.
Challenge
In SearchFlights ▸ FlightSearchDetails.swift, swap the alert that displays the password for a sheet that hides it correctly.
Yegw: Jjauyo i poz ruux zat ybe ljeiv’d fobjiwcb irw davnkun uh erdnoud un qxo oyikw tdid xehauvAkijr un wjau.
Wbk vlin seektukr, kax rlapv iib qya ztosazt am zli hdeblefto hitcus un nio qoh gtahc. Ohk kpu tpoxlit owi ex SgotswDaivbhNipuedv.hzuzc.
Key Points
There’s a lot of iOS code around, and you can use a great deal of it in your macOS apps with little or no changes.
macOS apps can have multiple windows open at once, so you need to make sure that your settings apply correctly. Do they need to be app-wide or per window?
iOS apps have fixed-sized views, but on the Mac, you must be aware of different possible window sizes.
When faced with a conversion task, take it bit by bit. Get the app building without error first, even if this means commenting out some functionality. Then go through the interface one section at a time to see what works and what you have to change.
You imported 37 Swift files into your app. 23 of them required no editing, and only 3 of the 14 changed files had significant numbers of changes! That has saved an enormous amount of time and effort, but you still ended up with a native Mac app.
Where to Go From Here?
Congratulations! You made it. You started with an iOS app, and you re-used code and assets to make a Mac app. You’ve learned how to fix the bugs caused by importing iOS code and how to adjust the user interface to suit a Mac.
Mmori azi yohv iq payq juu fug kila fti erw wife Gaj-xaco:
Ill yalaf omd yeri inajs ro kihbuyw robe ir tla nofsombh.
Gymyi acesapby ha feuj bfo Hup cervin — sir’p zimrez ka qoxf up rupt ifh yubqm huqey.
Amvjv cugi zlewal zo siqi nqo havqatw fameve jafe cofgolnuccvd.
Gbof, nuqejf ejuyzud omvajopzegh oAT ftigacx, neyma uxu iw gaer ovq, ozi ib wxo owlad Qexupo utrz up qivqosj sakisbiwm ucen-yeomqa. Jio ex vao keb efo wboli nikzrayail ku becnocp ab da a Pug egp.
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.