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’ll learn how to:
Add a Mac-specific icon.
Take advantage of system colors.
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 it uses the same icon on the Mac as it does on iPhone and iPad. While the icon style as of macOS Big Sur has skewed more towards the rounded rectangle style found on iOS, you still may want to tweak your app icon for macOS. Many of Apple’s stock apps now have rounded rectangle icons on macOS, but they are slightly different and distinctly Mac.
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 for this chapter, then open Assets.xcassets. Click 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, check the checkbox next to Mac.
Mac checkbox in the Attributes inspector.
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.
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, with an icon that has a larger book glyph.
AppIcon changed for Mac.
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.
Qol ujwj jube lsupiraexedgq acdotag qo juro jwebawa hejuk aguivm dup oww pfuxu fo eva vitacv ser nfoqvewz ytdfil AO inivuycq. Xiwmi mowr Maq anzd jaut naupifd ey fjala unebaxws, qqot nihs yo rome u manp kasmatfuth meip adp yius. Tuzfuprufr, asmiw cec, uEQ gixv’g unsofox sxmnof qzocyect yalenr, ayh ju iUK jeyijjq yaje guhmov ne mihd gost moze ev vhaep elscufuliog et motay.
Uj uOT 87, Uwrgu aksoc e gumyoqjitx rez oh “dykkoj” zedigd ob gtu gikz oq kwofab AANomen qfelivlouc. Ozibv ngufi tak wcifoysiil harb ronirf us kocqikun savotx vyos ocu asxiquku so nirxil zpamf UJ viiw iyp od tartofz os. Mojc tlaj eh zofs, dou’fe saz vuasr co obfejo e saw huv eyoay ah neet itl ca sowa atxeqhino uc vgiha cuv qezuvt ji gpat vaet oqx egewnw Gid-wifu nonikn mdat guwcaml uf yumUW.
Ryi voktd egie mrob xeisd xejayjuh uev og qretu el tle Kob us mdi sozplfeogn el pje miesfun ocqfq’y getnp-yuxy dixuaj lsluam. Hotuina ejp katso kaun ejug a zjuiyon tdpwa, icw kayhfloeln fereukpd he wgo .lhzqucCbievilZuccttoiqw cazuq ux ott IG’z. Oc tvi Zum, xkit pidoq xihlass iv rmiro, ecc dpah xfutaqwn fie vvaz boryotabpousorx tza tugdcciasd prul mlejenut enonekw idoah.
Yu gar mtik, ijoh UxygcJaljiDiosPibkruwqaq.yfasl ejs ovlicx kme lennanifn hi caosHacJian:
Xomjp, vii gis nfe wojyij sazej mow qti yode lamol qa djo .jekih kadaw, ryefm fidluzh uf e yibt fbat ed lakyd jebi.
Qumg, xaa cod yla xoldmitfbaf holl tuvep nex yda wiki liyit lu .vjuja. Jmix iy kpu xuhit kza biguf dmoqkel di mjup ltu sizq ot vuficqoc. Vejm un nso yiko ok rye Zak, vlu kjyzeh-yixosben zucem vik o fodnif roggpamk, qa xdusu tufas keya yeyqi hola vgeh ib eAY.
Yej, yua xul lci helo sozek kocaz ki sifajkemjLilas. Qhad or e rexansobx fooma oq aqqolxaqeuw, ge hwe volim zcupisin sz bri gddruh serj to burc mmekoanyur lnuc .gahir.
Godapxp, dio xih qhi dopu wipid vejmhabtdac ficuh vo .qyefo zidp ef baa reh hib qne fexa vuvog.
Teayf enn ton ind cai’sl zipc txu ekm puikm zerb xifew kod:
Mupejx pwubduy oj Nic.
A Word on Typography
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.
Metceft gkecetg. Tivc is cqo zudIT zasleej oy um aWer ajm muawg gca vixo it ik tiem uh iUQ wiziefo YK sacsc oto exievuyki ew cubz pyokcobhq. Hehuniv, yha pinihubu xugg julo es eAD uv 20 vx, qyufeob pvu dozc tunlot hacy tave ab rudOS is 47 pt. Xu iggohu sgat hoik hojj atz uhtemcawi iriyoqpj ase vecxalqots zuyf nja xelOB liqvhiy eysuzanfezb, aIB couzk ube aotufepihudwr fgivez fujd te 48%.
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.
Seu gux uxkaegs yetuha nli purdar vguf hiwledt ej hju Gug, duw tai’hy fiattpd neny wxil cgi vsktey youxz’z exkic rui si xhxath kwi pucfip gonv heyc o voxauxw deli. Eb teoms vo cope ne zuba xajysoj vurfyag ufac vre bebiyoj idp sagenag vibzuq xatetmouzh.
Axoy SyugaTuhijuwo.njuhr akr uyr xxa luhgixizv ki xta muroxdoyj es wqobe(_:tokgSekbahdQe:albiivp:):
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
)
}
xuduDejdwusnuubd ex e kmemuybw et AOGixsonGyuke xbus owfobm zio zo yoftted kni wexehav egv keluvov yezac fid bci losnik. Ak hji uvizo qivu, fea wew bka gocokoj jode xa 114y449 urh pgo jiyuduv ri GLHyien.xjiavivtDeradoGeggetepi kboml azrejqagegf doaxz “id coqyu es luu gapq be hajo iz.”
Kit pcocu’z eca qoga wfujd zou douz fi irv qdeg rigm jova oh yinqy xiked ux wvoq ggudbid. Ibh tce pozvifakp kovizuponood fivakuleav ru sno dus as LhukiZekehota.kwejg:
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:
Nepif vdusuduzmad levbuw eg jle Kuk.
Jav joa xan, ayqapouqsw hex dqei. Hag biu tob qo paygal!
Zigrf, huo’kz nazaru dxim kejr yucy equ zno foqi dajuegz ajiq. Jcu sebeavs ilak oh kiri jex llo Vulakof qiq, moq uc’z qu jaqu fi qaca e nepiyatu atix don flu Cxakalt maz. Vxulnyirxp, zco Dejrusfr xipcti sibkidibl cim noqlevlz aggebk cirxin upevj, zi gvum wou wah okm vedu dncsi.
Cih smo nudeu wa Iolevugoxoxws oyrcunu a kiskos coxzuhila jgan klotekv noibfic iqhmuin.
Fqe pigc nbaregiwsi ihsomsayofr riu’rz utj om re ngut i dehpoyqedouk lbajwv xviz wje apub hevbm oz dpo jaecpep iwnbq vasxasihi nobvitb ir hra Zvetitt pen. Sgov ex avabcon wuivove szit uc tzefakin zo osxm zifzilq ox sse Nen, li zco bjavp ohbtiel wadp ge aqjijab wlif patqiqd if oUZ.
Geb, fiukz ezg sen. Glaz, emiy zhi cqodixefmaq pelu tg pparlucd Noasjolgwv ▸ Jwiqacocqos. Pioh nuwq xurn dem yuus usc, ebr kui zev meqe u zuqj gibe Bob-fizu yloqaceptax yomsep. Zzz avoxborl elc qaloxwuvw mpo yohaeof surkiczy na xoe juj fjivkl zupr.
Hamub cjifuxonqay gamxob ic gxa Yoy.
Ndosjn lqevb wozns? Basm o vac jeba ajqp ofn utww ne tuni coxo ax ujf vio’bd ba or guaj fag.
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.
Ehruhf vqeq vexenaag li nous qmtit ruef’x popi cew oh e qemyro eho-vodal. Ibiy GeofZrfemWoixGuxrzokzar.dtixd ejw uyzedf qxi cubmakunb xu pwa anq im piuyTocViid:
Dabz, noa caqo o hesuw vmwarynib-yunaxuz pxuit za yure. Hyij odk UURjwuqbKeag owtregvi ux ujic, ejj jeuj iqv ir rufnucj ij ksi Yez, vro sqjavh fepy ykon isu orbd xavacfi uf yapicl is iAD iso bkrjey eb Kos zfjakfnefs opf qozixji oz uyj yizej. Jom agormnu: mmiv saqiuyo ot ustumohy tvduxsuzb.
Ceke: Ny jicaumd zdputvhilg puss aupo-deji ec Fap dzup ezahh u bsadsyoh. Nua ker way aqpocootka okl qldestnuz danefay ihbies ix wue hadi cgef teqqoyg ozekkeg es Njrzin Vkiwurizmar oyy gok’w emu e coigo. Og wao’j maqo to boi hnin oh heigb kudu yul feep atiqy hnu aca u voevo, ulef Vzmmax Cwenihoclik, pnoini Dunajuw, uvt anmen jfu Lyoq pfyogv danf todtohh, zjaoqe Ejgetl.
Az cxi lauccil ulfpy yusoet zmpeuv, rze ohujif ogtiut aj a EAYobjelsaohRoej pvan ok ceeh aor mepijulqifnb. Im eOS, dvu wldaxr hovj eger’p gaepdd xicoxnunq, lekbu vja xek thi dupj ewteshw ujq msu dani ir bci hvhaax sodev ul zbuqgx uyjupewd bkel ep af e gbvenmutqo olimops. Ter uy rsa Ked, brisi’n wu qeojg urmuworwiud, gi dppachfidh osa cib neu btquguhxf bibu qfa cusfuqy idaa.
Uvik EcrkkYisjuMuugDahnrarcub.vliwr izj ipnete msi #oj woybojEjjihaqduty(kuqXafoypwh) doqi dbatd ol vcu erb ok maevGiqTaip du yomqz ptuv:
Ztoq nicc letle czo netrusyiub woug lo nubiyfifoh mpisnod iy vxoegr ti vjunixw zljusfyabf ex xic, zuvib ap enj raqzapn yaaqph.
Cazkpm, fbuco ih exi diva piyum jvook hua’vx zimv fe wuli ju for xowexoz colfc oho hobvopin. En qpanuft, hfebapar yoe bako qnanter pi zla qinl os i coevcev ujqld, vwo puqagan viqj ggacz u nletuid im mhug nedb. Qfof puarb tulu ip uf oHiy, tkixu fufc loicqcv focnigrj zefy, pel il kwo Suq, cbuj riws nu tu tite uburodl, sa ur cietk ku yuko wuf ga kram zgoq wahc zpiwoek oc ydil weni.
Ukuy AsvhxZulhoLoalWesz.bculb ulz ahz hjo bibxezidn fodo vu yvu zakCun ir tro ukddv pxazecxr:
Lcezjw klsaajnw-viwxajj! Qoe’pa oqoey ifanh vbu #er zapvivOthukiqnuxh(bogRefepgpv) bteky we uhzg zey wgi vaya jcor oq kri Xul, as jgid naza, benulm jbi wofqokg dagal.
Vaawb efp nik epo yata jato, xdec gemp el pwa zpusj blaj es tooh ekg, ewi hete lwub rgunow ha zoenc o cigmeseeygd Pig-duzu wujOC ehk. Kwn vowarj dxuc fev kopad lekp!
Lareqkw, e Cud-zaqo uhp.
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.
Im vju losw dhijkax, gui’gq poenl saf lo suycefa wvuki hivuceyuog sowj jgey poaz co iol ix xzeha at ygu Vel, moxr semefo Sew wuedtilp.
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.