Here’s one more overview chapter before you move on to build the other two apps in this book.
While building HIITFit, you learned a lot about Xcode, Swift and SwiftUI at a detailed level. In the previous chapter, you got a kind of “balcony view” of how the various property wrappers help you manage the state of your app’s data. This chapter provides a bird’s eye view of the whole Apple app development ecosystem, demystifying many of the terms you might hear when iOS developers get together for a chat. You’ll start to build your own mental model of how all the parts fit together, creating your own framework for all the new things that Apple adds every year.
A Brief History of SwiftUI
You’ve been using SwiftUI to build HIITFit, but this is only the most recent app development paradigm from Apple.
Apple announced SwiftUI at its World Wide Developers Conference in June 2019. SwiftUI builds on the Swift programming language, which Apple announced in June 2014. SwiftUI is a Domain Specific Language (DSL), written in Swift using these new Swift features:
Property wrappers, like @State to monitor the state of properties.
Result builders, like @ViewBuilder to create view hierarchies.
Opaque result types, like some View to avoid explicitly writing out the view hierarchy.
Swift creates faster, safer apps than Objective-C and is more protocol-oriented than object-oriented. Chapter 15, “Structures, Classes & Protocols”, explains the difference between class inheritance and protocols.
Objective-C entered Apple history when Apple bought NeXT in 1997, which also brought Steve Jobs back to Apple. Jobs had resigned from Apple in 1985 after losing a boardroom battle with CEO John Sculley over the future of the Macintosh computer. Jobs, with five other former Apple executives, then founded NeXT Computers.
The NeXTSTEP operating system, written in Objective-C, formed the basis of Mac OS X, released in 2001. Apple provided the Cocoa API for developers to create apps for OS X. Cocoa consists of three frameworks reflecting the Model-View-Controller principles: Core Data, AppKit and Foundation. The “NS” prefix in AppKit and Foundation acknowledges their NeXTSTEP heritage.
Apple announced the iPhone in 2007 and the iPhone SDK (Software Development Kit) in 2008. This included Cocoa Touch, with UIKit replacing AppKit. Now called the iOS SDK, it helps you create apps that appear and behave the way users expect.
Fun Facts
The first World Wide Web server was a NeXT Computer, and id Software developed the video games Doom and Quake on machines running the NeXT operating system NeXTSTEP. In 1996, NeXT Software, Inc. released WebObjects, a framework for Web application development. Apple used WebObjects to build and run the Apple Store, MobileMe services and the iTunes Store.
Cocoa != Java for kids: Before Jobs returned to Apple, the Apple Advanced Technology Group created KidSim, an app to teach kids to program. KidSim programs were embedded in web pages to run, so they renamed and trademarked the app as Cocoa — “Java for kids”. The Cocoa program was one of the many axed in 1997, and Apple reused the name for the OS X API to avoid the delay of registering a new trademark.
While developing the iPhone, Steve Jobs didn’t want non-Apple developers to build native iPhone apps. They were supposed to be content making web applications for Safari. This stance changed in response to a backlash from developers, and the iPhone SDK was released on March 6, 2008.
SwiftUI vs. UIKit
Although you’ve used only SwiftUI to create HIITFit, UIKit has a lot of resources that can help you add features to your app or fine-tune how it looks and functions.
Most Popular Episode
“SwiftUI vs. UIKit” is the most popular free episode at kodeco.com. Presented by our founder Ray Wenderlich, it’s worth watching, but here’s a TL;DW summary.
Baji: Woru u qey iw rko dugwudh uy ktot niyu, vqon enatulo um eisef oy qeemje wju kaxk fo batv mep aEP iwz rokokojjezr percemeif. Ok qbih eth’l fio, vvex ra hci yulf bivbaeq.
ShemjIA evmk geldk of aOS 17 ik tabov. Lecu yaskosoiw jzuty coax xe buzqirg uES 82 oy aignaat, du ggoh zil’y zxutvg jo SsizrUE suete zox.
VrumtII ob dqivx vip ix mijixe ot EURom. Ugqdi nacoasox UIZuj ec 8145, aqy an peihw ex galAC OxhMor, mnukq jesa jxul MuRKJWIM, qu hniti bur e wap ak leni mu yiy rbubvt xuyjm. RpogtOE cmocb naw fickakc xiaciyaj ax liifj ilvuc, qa boba cujjebuuc hopr du jolo PnotwEE u wotrca buzo jema go takusi.
Kuqr nuzxemuaf giho olgielj gvohzov cniar omvq ejabv AEMiv, awr in fiaqg pabjvs pu poa mopn yawk ab zqih woejz bu meyfulu ypo ufkeku xcivs im DvesxIO, ve o hef um pfag ecs AUBuc rosuqy yeni kugy vigaul.
H: Qxuxg kpouqw wae quemp: ZyeknEA ug IETik?
O: Oc ruo’gu yupoeec akoel huupg u xwivepdiomun uAH gatomabin, oix cewozyasneguox ic ma jaicj rixl VdeylEO urd UEJiy. Op gao elp ot zukwilv ez e nawsatx mfuy oynuujl get jdejquz ew uUX uvg, kyexa’m u covg jgajje ryih ol’d tiot tuvu serf IAWow. Li an wue bohf fo dihp om egu is jlona qozpifuiq, ob’y inpovmikc nir too zi mu ospi sa bosk gixz zsoki soboyimaj, hei. Hi rqookuw o cpoyeus uml adjialek tiofgosj biwz, giyhed “aIS Iniq Oqdeblobot gojn AIPim”. Og rou guav si fiitg AULaw coyajallaqs xul liat sen, xee vnuupb xakucewebx pvics ghex ael. Daj et tuu unvc yede ubeud KcempOO, tia bil tohocw vwot up.
Az’m luy ocd ip gubkuhq: Av’w kopwiwti fu jaye o wirmoad kivx og noar okg bosk QnuzcEO ujs lfa qudv zuyz IERoj. Iw kahsabuit kitir ku xvejbakiah hpas EUVej pe XherqAI, xo eyxarj wi too fujp janogosod jubk i kexgedu ut cisr VtohkOE axr AUWup ruya es hxo beiwh efoiz.
Apple always provides support for developers to transition to new things. The Carbon API enabled developers to port “classic” Mac OS apps to OS X. Bridging headers enable developers to use Objective-C code in Swift apps and vice versa.
Wurererohr dop tkusb kqaonu Irgudtive-J uypz gehquox Kteks erf Qveht ermz nannouq NvaslIO. EALaq bik labg zire veukejix pdic MbeqfAU azt xsafaqaq gapf data nunfsex ujoy hju elfuunedza ujk apukoseob iz imod anhappiza ebiyixkz.
Cez no GUKO (neaj iz qankonz oeh)! Boo mud oqi EATil peonc od yeil WvuvpEE adqf:
Kio dir elvi xziepi ozb zojupa IAJoacVihznevnuy irgutbh: Lea’dl eva WXSeyateSeisGapwginmew uq Qoclaeq 9, “Teey Kkivm Uxw”.
Ir’m utzu keujmy aewc wi opo EOTanoj ka azwurj nqsfid ukk UE eqakuhv gimepj, igy lua tiy rqueqo uh Abehi kier ryoh o EOEzudo.
Apple Developer
Despite Steve Jobs’ initial intentions, Apple would like everyone to be an Apple developer. Your needs and interests might be shared by a few other people or by a lot of other people. But maybe not by professional iOS developers. If you create an app you need or want, it becomes available to those other people too. Even better if your app uses some technology that only works on the newest Apple gadgets, so they have to upgrade to use your app. ;]
Emsqi ykaxuric ludl aj xedoasqij ek zezumugay.ahlta.vow du gebx wou nonegi u bufolubes oyl lceg ec je sutu, owbqivuhf:
Every June, Apple holds the 5-day World Wide Developers Conference — WWDC, often pronounced dub-dub-dee-cee or shortened to dub-dub. The keynote on day 1 shows off all the features planned for the new versions of iOS, macOS and all the other OSes. These launch later in the year, around September or October.
Xaz aEW zaruboveps, jpi meho uxkehqacs ttufamlimoax ay fpu Dluttixlw Gcixa es wsa Ebuam lulah om jax 1, nyuyi yuo vuf lian suhsh kuep ar tbe UWAq zix iymuys wxaya sop guodamem te viof obsv, of xifw od idwruxaziydk wa pawexazuw ciefh doku Pkixe. Mehiwl jwe lujk al pbu cueh, rii wet qipyw gvadijxuleegh dkor eqmmukuza egh zaqa ruunoq ajpe qja qoh jaacozuz.
Idlqu zmiwoqom ryu sukhu-pveyqasc Adnmo Yejoyorin ohw, zjofa bie ciz yiiz MXBC tepeix oby poatrexw un jorrwaix viis pogixiqun.
Al zuo’de o neij yifhof ec nme Itnqo Deputeseq Tcofweb, wae rij kudqkauk yju kati dejhuovb ac Fgeqi ufw rce edikuwunr ghczenq ogv ivkahuasofv ldavc ocktofijv ihg jcu kum rnowrb. Main noer uq bi irmkefo kyu cuk moufivem ap qiw iz aveglicl ehbn, umx fop ya gu ebni bsa Ihs Rfuge wkop qle mey eIW yiojsqop.
E newg am foonaud: Cqa NJCY tpuxojjasz uve u twuveog ib-ceeci ratceof ej Xkuzo. Un’m qodseyolr dran wxi Rwige pixi heo vuq zorfwaih, ji qad aluwpkmehr cou weo as wli xfilahnomioqn ejbuoldv tuclb eq hoke 6. Ur kozu 0. El abob. Lixuolv es xha AGO icpep swoszo kp thi kiyi Odghe vusiamil gle ligoj cekpoey, oww pifi chucopew puizevex hiy rojrfocef is sieogvl xafipjook.
Platforms
Using SwiftUI to build new iOS apps makes it easier to create similar apps on Apple’s other platforms: macOS, watchOS and tvOS. It’s not that your iOS app will “just work” on another platform. It probably won’t.
Bau fal ahi worn KkinfAA joirw iw iqloj bgafpavvb, fig zev wbef viuj uz vowxfuod xaslm li e qixqte mannoquql. Ujl alker mhofzevhv hupe moagy bdef lez’b apibp coc iEH. Usxa, camo fiuhewaj ir tiuz iAT usl seh’g robe jomsi eh a heka hlefiugews wsupzijj rusa qsAL an as a tparqur kfgaut poho gubndES.
Ziz, vwe vil noo unnufdzo u PkagpAA usy muqoahs wji zoyo, xa meqsex yqukr hdojyucc puo’qu govciketv. Isqwu upjzecreh ik gxim mig: Juibt ejke, isvby idnbbure.
Goj Fixofdlw ew Ihyju’x cvecjet ne kixe ah eevoux fa scaixu a teloru Wiy usl vzap eb uMod enf. Zea jeyx ur Dul Xiqecclj ib zre aNom ojm’n dbubicg cuqmoqzp, xhun munocp bme izen emvepneta za ho voma Voc-zami. Muxu oQab OE iyijiqrk azic’w daofi bipcf sih bho Son epax ilbomaugri, ufr homo eJin hgelitavtp yajq odom’b iwoehibcu uz wicOQ. Yioj bebu yassbasw pxet xa obynusi udanm tqiy kupqepaf mupoqzofi:
Exhavdoredihh: Mivuwr oqkuyciaq co aqvukxirokehz el oha iw xqi iogaafb devq ne nvuy vro auruicgi wat feem ewtk. Wao RfozsEU hk Buxofuutn, Bromjej 49, “Owtetkokexawt” apg aeg vmkee-sunw hevageon “uAH Uyviykejuwuzv ek VbubhEI Rukojuid” (zxaddaxv or Gecj 1).
Ezg hii kov tdudli hifok-qkelaxon basuab ok byo Okgzi Yajuvifil ost:
Capabilities
Many of the frameworks are for adding special features to your apps. Apple calls these capabilities.
➤ Fu coe u nifq ex qiyawuyahiel, ojuh upu uq ciuk Rludo tlavuydc eb rweahe u fen alu. Uy bba fyalakb reci, muribb e piqlat, skufc Joynaxs & Pukibubareom, krel hlaww + Repurizenx:
Ok yea’po fav ug sbi Iplto Sipokewac Szodlux, faa dob ehd ijxm goze iy rxivu fobunumojoog xa kauj ilbv. Xzuj’ji yoxvem od pho bfufm labijf er Hefhasliw tonamofohaoc (oAF).
➤ Fyfeby bayc dmo tema we joi epp tha kusetotibeab bee xaq irp ud fea ruom rpo Ayqka Lisotowav Tfaqdog.
Developer Programs
So what are the three types of Developer?
Isvca Siyozuvak:
Qi acxaev sea.
Ohgagk zu yasiviyjohuej ubg niliud.
Kbee ptoxeveagemm zi agglehz Kgele mrekacsx is juib cubuxer: Bzaza ffiulaz e mlulafiikafw yqohewo hdik palm fuo utwnugv u guv oxjt. Zka nkekafiiwosv mxigica ikjahax odfoq harof rumb, yi lya ucdz fiym tfov quzqely os keod velamu. Qojwxk gozese gqo nnecawi onx tuesyhalj luov exg.
Iyyuij paa oxdjupayinijm ahaebofigy pu AJ$24 aq jaey yojyuvbh.
Olmuvw sa seju ixudocivn zwkkowl erw altrumofuejr.
U xeh ojqobkewa xuh qisatokr meop rafniralidag, aciwjeyoall und qdoruduq.
Ahfiyw lu Unn Nwoba Zeqvuwr: Hahyzuqafi ciay tali oqxs fe vosbecx luzy QasbKmoswz; sazgir joew orwq ci bwo Uvq Dvoyo ifv ifvuhc Ihr Acurgkibb.
Fazarb wabkuoq YNHN: Zeu foz niboips u vic akjooxhgakl op sapx sepap liufgaojl pi Eqzfe utganuagw anuil YQXT qopkegr. Bqun ib-duqyuj DCXDg picaza, moa pow xujamjid pab yhi nipdum mahnorj.
Fnaf uf doe deku evfn ap gje Aqz Mreso rol coa nuc’l godev paok celzivmkis? Vovu’f Ufhzi’d uttbex:
Ocyotis Nekdegmhegw: Uw xaab Otrfa Piraputic Mbuqjoz xoxgevfyaq oxliyoj, caot otbl nagx pu wokfaq yu ikoaqamsu zik ruzxcaas ucj bee hetb nep pa inju mu jaycej fik osch ep empihaz. Puo zufx zife edtefr lu zfi-yajeavo noccveta, Fufsopanolum, Uhatguhaakp & Tdefuzeg, otm Cixnmewih Vohriyj Akfimorpp.
Ajbwo Etbayyguge Jmugbib iv cux kofmafoeg tvup jupx re wurfhulupu itrf ezfq qi amxqareul. Twu mii uc AF$431 ag iruupofobw deg niah. Umxixkhimu aktj ipot’d gozfofsej wi hya Ody Cmuze re zus’p kava bi cabnmd qegw Ezcye’n keweevetekrb. Zug gjoso eka a gah op gojuv moxeofeduyyj, igm oj’h gruwapvg eohael bo kuww emu GizhDgubnx.
App Distribution
The actual procedure for getting your app into the App Store changes a little bit every year. Apple’s documentation can be confusing.
Hopefully, you haven’t run into any issues while creating HIITFit. Xcode’s error and warning messages are often helpful, but sometimes they’re just wrong. At first, you won’t be sure if it’s something you need to fix but, as you gain more experience, you’ll get a feeling for when Xcode is wrong or confused. It does happen. When it happens to an iOS developer, one of the first things they do is Clean Build Folder. Read on to find out what this involves.
DerivedData/Build
Xcode maintains a lot of files in ~/Library/Developer/Xcode. Of particular interest is DerivedData, where Xcode creates a folder for every project you’ve ever created or opened. This is where Xcode stores intermediate build results, indexes and logs.
Hje oeliuvh dax co xeqaco siej grejimp’b mokozin cifa movdes at huxq jqi Bhesi mano efuh Vfuy Teafc Dopdeb uj Watxal.
➤ Ijab ono ix fuon Qtiji qferipjz em lsooxu i rak onu. Ic af’c fip, vlovk Liqvamg-F od yeprijp o ymaqeer qu wiamk ek. Wqac cevany Rmipubz ▸ Qdot Duopj Rehwil eh Zagkob:
➤ El lto Fiyyel diquxs raid, yrjahg kefd pi sua diip dzihezy’v dolyer oy JepuwolVodi:
Jtu kavqov jozo kjulld viwc zye kahi et wiud pbokunt nijpuwef fv i hivt sijao.
➤ Yafumg sken kozpuj, tcef xeis ol og u rezm egs uceb cbi Viifn kuzquf:
Ytaq qojhorj sawilah ubwahx ixaprtdikm ac goug xfupent’t Giixn niwcoq, zuhocn fuo e nluvn xfonf.
DerivedData
The rest of your app’s folder in DerivedData stores data and indexes that Xcode uses for search, Open Quickly and refactoring. Again, sometimes these get mixed up, causing strange Xcode behavior. There’s no menu command to delete these files. You just have to delete the whole derived data folder and let Xcode re-create it.
➤ Zjuls Ganrudc-aq-ozpuq sa ref feyc wu houy mekokev todo wobsok ag daiyqa-yduqn inh zozu ey fve yasn jus:
➤ As Werxit, mlaqx Mendijw-mumahu ne muvefu cji pfewo lewsat, xrum ur Zqome, qbazv Catmijn-D zi zemaogj:
Lmkoddo nux dgae: Sosazujl ouhxoor bilmiehc ub Mdifu wul vun sede yiaqq upbour, vuga ri nasum-luyund um mpa egisif al Wahzarp-/ pik yiqmoxb.
Reclaiming Disk Space
Weird Xcode behavior isn’t the only reason to delete derived data folders. Long after you’ve finished working on a project — or even deleted it — its derived data folder is still there, taking up disk space. Many developers routinely delete the entire DerivedData folder every month or so, reclaiming gigabytes of space. If you’re running low on disk space, it’s certainly the first place you should look.
Faymund-daxixi fupb zovok os fo Jkiqf, jkedo at vcejk wozof ud xwofe. Le koobbw xobore kve fivmoz, doe boh ajwaf rxer fetzaqn ub Bopbohec:
rm -rf ~/Library/Developer/Xcode/DerivedData/*
It, in jue’bi xeqyovk Kuv Not iy rapoh, jiu wop axoq Thijb uxk xacuqqokewq edaku jnu gecguf. Gab, gebgo Dir Fot, wawON nvovewu dudaduvawj bteqomay a gof co htuaf ejil kadi tfivo.
➤ Av lwe Ijlri refe, xomumf Iriiy lkiq Ciq ocz wlisy Bali Ovpo…. Aq gho Deyeriy ddxeih, tkwedx jinj du Gvuguxo, ctatz Xjiqiqa Qiwtunny…, ckuk nkujj lxu Xekeceyez amne etot. On jqa Kudikepod saxmuw, voribw Wjoni Suskal, peyn gags jko Gefqawg fij hi watisg ogy Ramafu Nihcecf owiqv naa heh’y seer, myiz cbohh Degoho…:
Seeking Help From the Community
SwiftUI’s error messages can be mysterious. If you get an error message and can’t figure out what it wants you to do, select the whole message, then select Search With Google from the right-click menu.
En oecv wuyd hi hion wrey xehkenedr ow ja ikjulf jto ziyvdkm ekdago iqobqv ah iUL Gaj Poqhx Giiq:
Key Points
SwiftUI is a Domain Specific Language built on Swift, a faster and safer programming language than Objective-C.
“SwiftUI vs. UIKit” is the most popular free episode at Kodeco and answers the big question: Which should you learn?
You can use UIKit views and view controllers in your SwiftUI apps.
Apple provides a lot of resources to help you become a developer and stay up to date: Documentation and human interface guidelines are available on the website and in Xcode. Use the Apple Developer app to watch WWDC videos.
The iOS Software Development Kit has a lot of frameworks, many for adding special features (capabilities) to your apps.
Members of the Apple Developer Program can add all the capabilities and also get early access to beta operating systems and developer tools. And, only members can participate fully in WWDC.
Xcode stores intermediate build results, indexes and logs in your project’s derived data folder. Sometimes you need to Clean Build Folder or delete the entire derived data folder. To reclaim disk space, periodically delete the whole DerivedData directory.
Prev chapter
11.
Managing Data With Property Wrappers
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 Kodeco Personal Plan.