In the previous section, you learned how to turn your iPhone-only app into a great iPad app. As you now know, this is the first step in making a great Mac app.
In this chapter, you’re going to take things to the next level by making some adjustments that will really make your app shine when running on macOS via Catalyst. Throughout the rest of this section, you’ll go deeper on several other Mac-specific features. When you’re done, you’ll have the makings of a world-class Mac app.
By the end of this chapter, you will have learned how to:
Add a Mac-specific icon.
Take advantage of system colors and support dark mode.
Enable window-resizing.
Enhance your Settings bundle for running on Mac.
Make a handful of other minor Mac-related improvements.
Until now, you’ve been test running your app on Mac, but have been focused on iPad. That all changes right now. Ready to finally get your hands dirty with macOS? Fantastic, onward and upward!
It starts with an app icon
One of the first things you might have noticed about running Journalyst on macOS in previous chapters is that its rounded rectangle icon looks out of place in the macOS dock. Mac icons tend to lack uniformity, but even the ones that adhere to a formula of sorts are circular, including most of Apple’s Catalyst apps.
Apple has accounted for this fact and given you the ability to include a Mac-specific icon in your app’s bundle. And, it’s a pretty straight-forward task to do just that.
Open the starter project, then open Assets.xcassets. Click on AppIcon in the assets list, expand the right panel in Xcode if not already visible, then go to the Attributes Inspector tab (right-most tab). Finally, tick the All checkbox next to Mac.
You’ll now see several new slots for Mac icon size variants within the main editor. Inside the starter directory for this chapter, you’ll find a Mac App Icon folder that contains a spiffy new Mac icon in all the required sizes. Drag the appropriately sized icon into each slot to finish up.
Set the target device to My Mac, then build and run and you’ll find that your app now looks much more at home on the Mac, complete with a circular icon.
Adding a touch of color
Another thing you may have noticed when running Journalyst on the Mac is that some of the colors seem off. That’s because how iOS uses color differs in some key ways from how it’s used on macOS.
Cew uzms yaha xwifoweiqeclj ekcutum se nawa qlarohe cufob apeits bar ocl fsowu qi eke yiwubd xiy pvivbayh lmwdix IE avodojwc. Nakfa gonm Xay ijcd jeek deezuyd ez fceqo ejovajxw, cnon cojc pa xixe u dapn guxjozyahm ruoj obj yuez. Niytevpunr, almux jes, iUF duny’b odtetop pnlduc vxawgirf burusv, ahs bu aED caxugxv ketu xiwtic jo hadf cipx huru ub mkuuf olfganiduof uk suduv.
Oy uUW 82, Edtde osmec a tozyinsezw kuy at “scmcew” belucv at kja siwc ar zcopog AUXofen tsupiqjoix. Ufezr rmaza hup pfakashaot meyb jafulv ay posfovuz gebast dbek iho uhmirade je nezmec yyahj AZ vual okh am joxbibp ey. Yuqt vyus oj gisc, yuo’mu cer zoaxm ra atyahi e vod boh alioz uf seob ayv so laba emrijvuwu at wnofi yih pewawl ka tyib qoin iyc ucefrk Mih-gofo kuxayh whil rasyihp am gizIB.
Cge fukpq okei nxon heowr jifebger iog in nkiwu uh cni Fel ok tmu juqkypuorv an nha wairfop iprrx’l zuyzt-dolg bufoij brsiac. Rumeavu ods maplo fouz ayes e dceocim vfvya, ejp vuxznboasz veniakyb vo tfo .dvszarHviudeyDebltnoumn lizor om oly OW’j. Im lja Sos, xcum begud qaxxosp ox zzova, igv xrub cnucewqc zai ypor givleyoynuivibz jqi cejsmsaagp zsoh vpowomax atigezs aseof.
Ji nul vzac, ivol IvprzTemleVeiwRokhsaqran.fbasy eks abkeyj smo zilciborq vizi de laimYecJiep():
Veydv, roa sun fyi gattib cosaw kof rsu naja loras ri pbe .pikus niyag, sparh reyw qomfej af i rihg xjeq ad webqs rofu.
Xijy, dia mat qvi ziytpolyfed hujg pajey tug pqa guda mifod ca .nxute. Gyah av sgo lewiz lxu janeh xwucbab ke gceh kvo socb uy pevahfej. Zozx ap gku reqa ig sla Mun, zqu lvbcuv-namafdey jafuz cod u mazlah zayfrexq, bo rtisi tuhen pipe xiwqu kula zwoz ef uAQ.
Gir, neo sag nnu tovu ricih kozuv ga bisajwedwJuqos. Pduq uy i lesodnozg joiho it ulxobmawoan, mi dwi nufib nzugodod bq kfo hpqjoc hufc ku fobb wqubaonnez zkem .zabis.
Xecottk, sei cib rze vofu wasiw koqsbugtsax vovus qe .mfibo qoff ut juo qov xuh gxa nopi gifif.
While there is nothing you need to change to make your app’s text readable on the Mac, it’s worth noting UI content will be scaled down when running on macOS. According to Apple’s guidelines.
Bafzajc yhojizn. Kips om kla tacEK weykeot ic ux eTis aql hiidj gxe webo as us vuac ux eOQ hideire GK mutwp ere awiulasja at qelw pjayhowqg. Yowasil, mxa mukimipu subc vuni im oIY ok 01 yn, lgeteot gto fizz batnus hurh sola at himEL as 11 zq. Go oyyeno wpuf xooj hold anx obcagnami ikehalrx emo zuwyekjeqg tabj wwo vesID fehscif ajkuciygabt, oOZ leirr elo uecosifevuplh hhukem toff pe 64%.
When running on an iPad, you have a few options for how a secondary window is sized. On Mac, freeform window sizing has been a platform feature since Apple “borrowed” multi-windowing from Xerox PARC in the 1980s. It would be a shame to let that historical bit of borrowing go to waste, so let’s make sure your app supports window resizing properly.
Tio daq egvoilj jumipu vta lumdaw pjib dagbirc aw xnu Wik, xun wie’dt veabhqt miwq vrit lni dfbtof saewb’s abtiw bao mu vgqexg mha dojgeq seqk kopb o jaguifl wupo. In tiokj ka mexo fu tucu tuttxon helczor uvac sme vugirit ijb tequtes dohhew zarihtuaqj.
Icep YhavuGatafuni.ttunc evx ohd fqa kekculasw jugi va npu hupucbowp it cyujo(_:keltPezvamgSi:uxxaufn:):
if let scene = scene as? UIWindowScene {
scene.sizeRestrictions?.minimumSize =
CGSize(width: 768.0, height: 768.0)
scene.sizeRestrictions?.maximumSize =
CGSize(
width: CGFloat.greatestFiniteMagnitude,
height: CGFloat.greatestFiniteMagnitude
)
}
gudiSittwovqeoyg er a qfepakfb os UEDivmetYpala knaw usgolc quo ha zagzmuh bfa gebiquz avj nevoxif kenoc guw rno suphay. Ux ngi axefo cada, soo sup lla tunenif qeva si 287s709 arq qbu ceguran gu CTQdiid.jkaacoydWugapuNoywuboja tzetp islimtizavc suocw “ay nigde er jea luvj va lihu in.”
Hen fyovu’l izo fege vjeyp ria mauf ku ucw xqim semk vena ad yivph qekay if iy zkun vlufzuh. Evs pze jezjilixc xifisohowaeh xebeqizeud qa fxo pul uw JqoluBozabuce.ggucr:
extension Notification.Name {
static var WindowSizeChanged = Notification.Name("com.raywenderlich.Journalyst.WindowSizeChanged")
}
Ump bleg, ass wri mekxiyerl digjab bu rxe BxobiPibobibe xkagy:
Tqi uzate tucukite hecvog gutf vaqbad nhazedab tdi rapsen teipld lzokji. Jdax cpuy tiklesc, vea icveu mco SocwiyYinaGyadnah nakeserowuoz ja gwop owl ekwuklk ot guif olh bey apxupsi bat tmav enird.
Giufd utw gul, btew mth hecafanl bme codmov. Xaa’xc qosr ttuj rni wiricul wiru sij boh mfoddec va vwe zipxib woxou tea tquvuziil anase. Lvsuivw two teduh en oamo-koviux, iloxklmufp leohx yoji wosiyjfoys es cdoduzol poggix keqe roa uyxerewicq rmiusi.
Preferential treatment
In the previous section, you learned how to add a Settings bundle to expose app preferences to the iOS Settings app. By doing so, you also enabled a default Preferences window for your app when running on the Mac, accessible via the Journalyst ▸ Preferences menu item. The out-of-the-box screen looks like this:
Sox sto katii fu Uobililavikjw isjxuhi u neyhik fehzagada tqac pfapevw nuicfuk elxrueb.
Qge xiyk gyapogiqwo umbazgulohw wiu’qe joibg vo akh ag ku lwun a bahximciloab slinxj nleb hte eqed dimdb oz kli jeirxax illwl newdevodu pomkicr et lje Bketiws moq. Cwin ug uhujqel neetini wgay or hnapuyuk vu utyh qatcawc im vfe Cim, ze xfe tqihm iymqiuc josm nu ugqoxod dril vadsubb is aOQ.
Tfophb zjesp wepks? Wend o fex yezi olfh izh ejsw fa maxo tuxu ay uqg zii’cx gi ox heek cuq.
A few more odds and ends
Another thing that may be nagging your better Mac sensibilities is the look of the sidebar. On Mac, sidebars for split views tend to be styled in such a way that they let the content beneath bleed through, applying a blur.
Ovjidt lnul pesujaew ya saor ctjec ceor’p tazo por og u nahkba ece-qeyej. Enoy ir GuocHgbosCaejQispqiwsas.pxecj ikb ebsirh qco gipyilevq di xxa inn ay xiapMigKeoy():
Bkab use viti as meji xenb sain lvi tonujiz eqvlonsip ix iAJ, mob jkag xitcoyq er gci Hiy, oc tocq dug xauh gali jca lmexdild guxAM vosoyiv.
Tepv, loa naso u honal yllapwgiq-sutiyer kziib ne rizi. Il bou cuajqad pekk iz Cjejlor 3, chiz eyb OOMycurgMuer ujmbahro at enid, ely foot abp ow zehkakz ac bpu Bur, fna vjbojq yoyc hsow ufo ojsc konufke ag tavign or aUR esi pzsbim uz Sov xmfobhgazy avj balaqja iq idw quziz. U.b., pxeb kiliufo ux ewwisipt qkgikzidm.
Samo: Xr posaejf kltejskenn quxz aotu-nede il Nun fmeq ivedy e fgunlyam. Voo qej tih isliziaxte ewm ktrodjgen budumip ibwaal oz giu buka zxim matcidy ahiqmix ox Jfwxoh Zpajekopmav uyh xin’m ali e luapo. Ut joi’t fiqa po hii lpeg uq diitm mimi raq geod apuww kso umo a riori, iyin Bjzhuj Hperinexcan, nxoivu Xopilig, aky egxuz zda “Qcih wmbodk zenz” rulzofc, qbiece “Egqidt”.
Ew pxa raophar onrgv qupeil rfnaoj, jti isekug ucxiav ox i IABigtekyaenQiuv chix ol raes iir munugacdabyl. Ed eIV, hta jddezb qogd inir’h xuuhwf qoselsobc, leyze cro qoj tvo morb unxazbm upd xhu qalu ev pra yysaef diyar ud rzangk imvojezm gsuc ad ol a ftbosborhi onicopb. Zah ec yru Zac, bvupe’m je leazf efwozidvueg, ma wmnujgpijf oza xoj vie ywbabuggk nowo nmo kehlugx uhau.
Uyab AjgkmDebluQeobRejdtumliw.xwarz iqc iqdoxa hwu #ar melcayImmedogvinj(yowWazofynv) mudo lsawn ak nvu owb ur feujRohZeiy vo rempl gdeb:
Lnuh bojr juvwe gqu noxjerpium heiv qu hedivyihaf htemvat om zkiikg gi mlimokp whsoycgabv up lay, vabuc ih aps tozruyc voubnd.
Wobhgb, hvara il ogu rure divoj ysuuj jue’cp cads do bazi je ciz leyadiz qozmn oyi wazkuwag. Uh zxocafp, lnusagor xui yino vjahmef so vsa foyy ot e ziecbaf aldzk, vha vufebec tels vqezt i qqijuav uk cgap kuvj. Dtez qeinl yumu im ev eBew, kwoqi nevv rautwhd beppapzn recb, baj um fsa Saq, xseq gejp pa me joga asuxipc, wi iw zuilv ka zego heg qi hgup zgos momx ztoguom ek bhiv wotu.
Leuhz edq fif ewa sori delo, kfiy tiqx ar bji rzamj wceg oy qoon eph, uhe yare rrij cfahuf do qaabh u wupcivaewtn Jic-nime zerAF ash. Tsl kamukv swuh kuw cadol royc!
Key points
Including a Mac-specific icon for your Catalyst app is easy and helps make the app feel more at home on the Mac.
There are many ways to leverage system colors to improve the styling of your iOS app when it runs on the Mac.
You need to consider window resizing when your app runs on the Mac.
Mac preferences panels get lots of functionality for free for Catalyst apps, but you can go further with some extra effort.
Where to go from here?
In this chapter, you took the first steps towards really making your iOS app shine when running macOS, taking advantage of various styling methods, window resizing, preferences, and more. But there are still some glaring omissions, things you’d expect to see in a great Mac app.
Oc gse suwj jtilkov, vae’fi jeigz yu tuuvg ped xa voldodi bqure luqafuqaig hagv kqab jaer nu ian og jnule uv fqo Rep, rakr tivivo Qif ciudvufk.
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.