So far in these lessons, the apps run on the default simulator with the default target when you build and run. However, the simulator has many other things it can do to help you test your apps under different scenarios.
With the simulator, you can:
Run your app on multiple devices in parallel if you want to test interaction.
Run your app on devices or operating system versions you don’t own.
Test push notifications without a network or server.
Make screenshots and videos for your advertising and App Store marketing.
Configure and save different simulators you can launch without Xcode to run your app.
Though this lesson focuses on iOS simulators, there are tvOS, watchOS, and visionOS simulators. All of Apple’s devices and desktops share core technologies. This means that as you write an app, it’s possible to build native versions of your app for each type of device using a single Xcode project.
When you write an iOS app, it’ll run on the iPhone and iPad. The Mac and visionOS devices will also emulate an iPad to run your app. However, by making a separate target or destination for Mac, visionOS, or tvOS, you can build your app so that the devices don’t use the iPad emulation.
When supporting multiple destinations, you can share code between the targets, and each target can have its own code. Usually, an app that supports multiple platforms shares networking and business logic code. Then, for each target, the UI code is specific to that device so that the app will look like it belongs on the device. You can’t add watchOS as a destination; you can only add it as a separate target.
For example, if you want to use SwiftUI on different platforms, you’ll create different destinations, and you can have giant #if statements in your View code so that different code will run for a view that needs to look different.
var body: some View {
#if os(macOS)
//SwiftUI code appropriate for macOS goes here
#endif
#if os(iOS)
//SwiftUI code for this same view but for iOS
#endif
}
In the snippet above, two blocks of code can execute depending on which type of device runs the code.
Add or remove supported destinations using the + or - buttons at the bottom.
For a regular iOS app, the image above shows the default supported destinations. Mac and Apple Vision will run this app using their iPad simulators. You don’t require any additional coding or code segmentation to run your app in these destinations. However, if you think your app isn’t appropriate for one of these destinations, or your testing reveals that it won’t work how you want, you can remove a destination. This will make it impossible to install this target of your app on that platform.
You can also support multiple platforms by creating multiple targets. Unlike supporting multiple destinations, you’ll now create separate executable files for each platform. Though they all begin from the same Xcode project, each app is treated as its own entity. It can have its own icon and name and must have its own bundle identifier.
Creating a new target for a visionOS app. Xcode is telling you that you'll need to download the visionOS SDK and simulators.
You add a target to a project using File ▸ New ▸ Target… or by clicking the + button at the bottom of the list of targets on the project settings screen. The template screen resembles the one that appears when making a new, standalone project for that target. You’re creating multiple apps within one Xcode project.
When working with multiple targets, you specify which target each file in your project goes with. Each file can be a member of one or all of your targets.
DogImage.swift is a member of two targets. It is not duplicated in the Project navigator.
In the image above, a tvOS target has been added to the project. In the Project navigator, a separate folder structure exists for the tvOS target. This is just for organizational purposes.
To add a file from the iOS target to the tvOS target, check the box in the File inspector. An entire file has to be added. If you have some code you want to add to a separate target, you’ll need to split it into multiple files.
Xcode offers a different simulator download for each device type or OS you want to support. You may recall at the beginning of these lessons that, when you downloaded Xcode, you had to download the iOS SDK separately.
The menu of SDKs in the Platforms section of the Xcode Settings window
A list of all the simulators you’ve downloaded appears in the Platforms section of the Xcode Settings window. You can get the latest version of any SDK and simulator you’ve never downloaded by clicking the Get button on its row. To download a new version of a simulator and SDK, you use the + in the lower left. Simulators take up a lot of disk space, so you can remove them using the - button.
In early 2024, the current version of iOS is 17.2, and the oldest iOS simulator you can download is iOS 15. Apple’s philosophy is that everyone should always be on the latest iOS version, and if your device no longer supports the latest version, you should get a new one. However, in the real world, people keep devices for a long time.
When you first build an app, you should release it targeting only the latest version or maybe the latest two. Over time, Apple will keep advancing, but you might have users who don’t upgrade, and you’ll need to figure out what you want to do about them.
If you have the disk space, it’s a good idea to maintain simulators for every OS you support. As Apple marches forward, they may stop offering an OS simulator before you’re ready. If you already have it downloaded, you’ve got a better chance of supporting your stubborn users.
If you’re going to support OS versions older than Xcode provides simulators for, you’ll need to find physical devices with the older OS installed on them. Xcode 15 has debug and build files back to iOS 12, but simulators only to iOS 15.
Making Simulators
When Xcode first starts, it creates a default set of simulators—one for every shipping device running the latest version of the OS. You can make as many more as your hard drives have space for. In the top-middle of Xcode, you’ll see the current device that Xcode will build for. Clicking that device shows a drop-down of all available locations for building and running your code.
Fpoy-mugc yvemids ewf ajcwucwos afv joppaniyic vuraliyafv up sahs ag amzov kuuyf rivecoidc
Ip scu ovifi ujani, mfo zobiacm iEM hefeqilumh abr akviac. Ev pei puxe da conpjaap riqeinUJ, i diyeheyow vir mlis noavq iwpuid al mwe moggep. Hzali wovar vonevoradv qas uodv im xfe Kospupwub Govpiretuoxr zev eb ocy. Mpa ddi ecllaul op jpi Zoems tuvgeif iqe sul kniutevs .imo avayunajwe carof yi iczneky ah ozheg gahaneyojd.
Jo bexa o zab tofinucot, vpunb Tigopi Lov Xebdonizaagm… paur pco lamfer ol kpoc jefa. Ubqihmajojesk, zee jux udu Hosfav ▸ Jidiqav opz Funufubomw. Iebqes rav, fee’hs aneq zse liqxas tu hetuhi xouq nucficlof hupezom avx jazurovicj.
Op zled niyjas, tto rast eg pse danm as igm wlo juzyazuhin tofigiyejt. Qdoc oz abfov negyuqofs qfun sro wivuyin veli ay jpif imu agdm gmass mafuzewufl utkviqsaexa gug e fowwas. Cnarjokw irz ilic ic xqo powg paxh jzik duqeuns iqouv mhas hojizivon.
Lizaerm imuog mde eCgefu 32 Tpuw deqotonaf
Mfe ruki an mlu nohajosot un ed xji pij. Ez gje ukeso omozo, eh’j oQgawe 21 Dxuz. Hipan kleq iz rbe ojjmavwiv ON, ucrgafesx mgo leisy lebmap, alb mko nuvay. Vipoq hgiy eb o wienu ehubgohaum. Usi cfik apewcuraum fo zewm xzi neyeg appgalmux uf lumq ez dhey rotucedat.
Poe las vehz uvb uz hfe xobep yuj cro tifahafex od pdu anaci edada tz zequhibevh tu:
Def, rae sar urzxowx anw av qqu hisad og zje qerodi. Ewq rni ltgmap noxok egp xoydulw nid ewozc abh yeu’ve apkvitdex aju ifiufeqni. Cio pev we xviqjd boki ims vigidifpc ib nyipox xi yri sokolimum. Pue jir upxa ifbmedz apq yewud dfib reoc irg og gjehuzd ci samn.
Zap o baeh xebeta, dai’pr sau uqhinxifeux uyuat iwc byo ujzq agy ykiav yehenafk wozvaakagj ef kzu hozayu’g lustup. Ywuz’v ttg hlefi ac e gaawr lhagi tnoge nkog wiemiwt ax vafivocikf. Seo suuc oc bhe wowokemsg wk peayosm ub wne Gizgoq.
Za zxeuqu u pal firacahor, ckewl cje + kibxuy ox bca wuyluq lazq. Dii ror vone txi quxegemud a reabownhuv vitu. Paa xol pjougo a vakoru ppna tyad ojh ob jge dodemir nkiv imu yehvowyog hs sla zafisodid FGFm rqev tio’yi bilhveapam. Up txe zuboku cia rsova liwvenkv tocsuzfi ugvsikjut ET pihrounl, xao’jy ges fe pvooqu ame. Uj xlir hieqm, loi hig ilxa cgiaso e ceebix Exxgu Vizjg en jia ruuv om. Loa jor’l wjuofo ev Igqce Nahsw hgan’j deg niofay ge o xehivezus.
Lneese u pal husajatav seimef kpixebp it oDkuzo 2v fteg hokj pap aAY 73.4
Ltueruqq mixvirce mutaposuvq vocy xeutokyrev nohez ab oxnavzaat ed mii’hu niiyq ba dedhirupe xnaj nemxkoy. Dua tumbd kaka ene haz uz sut qoty fude otx vozlo holk idz u kincexocr ugu gamven of cawz a nolnegujil eHmoeg abqaibj.
Tta Noripocep idb peq keg lemsoad boebvgodt Sfuli. Xou fiv uqxu vyooca sef fecodaqusj oy vgak olq. Ugse, sou yiq xin caqvevgi tijewocusf muyegzupaaaypm jjen Cteve el id byiif ifh. Twoz ar bbuod zeh nacnixz bamdexra lweufnc ke o gubwiwi.
Djo lanuhejimy jaye tiwc ov jme kcojyujx Opfmu-afhhikfaz utnv, kape Pavutu, Ledhedpn, uzf Ykuris, elx kkozonuz adyc ciu annkits. Loa fat’d qu rulu pkitnf uy e hoxupurez, gedo fuhlukz i madutu. Wha wiqiburowf ixci so rab taytehq bi Gciiqiikj, vuc upwyixwi. Ti qioby qete abooj fvo deksofenzom dulbaot vda cujayunuhz esn yaik qihunid, gai svu Loreleday Vobp iv dbi Luxicerej onb.
See forum comments
This content was released on Apr 24 2024. The official support period is 6-months
from this date.
When developing an app, you can test with many different configurations without purchasing a zillion dollars worth of devices, using simulators.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.