A Glimpse Of Xcode



  1. A Glimpse Of Xcode Ide
  2. A Glimpse Of Xcode Development
  3. A Glimpse Of Xcode Download
  4. Glimpse Core
  5. A Glimpse Of Xcode Tutorial

We all know that Xcode has struggled with being a little on the portly side for some years, and even Apple acknowledged this back at WWDC 2012. Here’s what Matthew Firlik (Director of Development Technologies at Apple) had to say at the time:

Last year [at WWDC 2011] when we shipped Xcode 4.1 our download size was a little bit over 4 gigabytes, and I don't think there's anything more to be said about that. When we shipped Xcode 4.2 we were able to shrink that package size down to about 1.5 gigabytes by making some of the legacy content – like the older iOS simulators – downloadable on demand.

At the time that was a big and welcome improvement, but sadly it wasn’t to last: after going on its crash diet in 2012, Xcode has since been busy at the dessert aisle and has grown far beyond the “no more to be said about that” size of Xcode 4.1.

A Mac, running Xcode 11+ (Xcode 12+ for some features). Add view properties & a glimpse at previews. Sam, we’ve got all these departure views, but no data! Where’s the data! Getting started with Codemagic CI/CD for React Native apps. After signing up, you can use React Native workflows by creating a new project in Codemagic and simply selecting the React Native App from the options. A glimpse of iOS Memory Deep Dive. Post ime: 2020-05-03 category: iOS read: This is an pretty good session about iOS memory. We can use the start memory address of the last region and search it in the memory graph in XCode. Or use leak to get the trace tree.

Interface Builder is part of Xcode and allows the creation of user interfaces for iOS apps via a WYSIWYG editor. User interfaces are usually defined in so called storyboards. A single storyboard can contain multiple scenes, each corresponding to a specific screen of your application. A Glimpse of Xcode. The left pane shows the list of errors and warnings and some hints are provided inside the code. Code Presentation. Syntax colouring, line.

A Glimpse Of Xcode Ide

Let’s take a look at some figures:

VersionDownloadInstalled
Xcode 5.02.05 GB4.37 GB
Xcode 6.02.62 GB5.18 GB
Xcode 7.03.85 GB7.79 GB
Xcode 8.04.41 GB9.97 GB
Xcode 9.05.37 GB10.41 GB

Now, some amount of natural fluctuation is to be expected – as Firlik said back in 2012, Apple can adjust its selection of simulators in order to reduce the initial download at the expense of possible later downloads.

It’s also important to note that Xcode has added features over those years, such as Swift in Xcode 6 or App Thinning in Xcode 7, so some amount of natural growth is inevitable. Many developers – myself included! – have a long wish list of features we want to see in Xcode 10, so there’s a never-ending trade-off between cutting size and adding features.

SPONSORED Would you describe yourself as knowledgeable, but struggling when you have to come up with your own code? Fernando Olivares has a new book containing iOS rules you can immediately apply to your coding habits to see dramatic improvements, while also teaching applied programming fundamentals seen in refactored code from published apps.

But wait – there’s more!

All this extra growth means that Xcode 9 is more than twice the size of Xcode 5, but even that’s not the whole story. You see, Xcode is a bit sneaky: the 10.41GB that Xcode 9 takes up is actually only its starting size.

Each time you connect a device to your computer, you might have noticed Xcode likes to spend some time “Processing symbol files” or “Preparing debugger support” for that device. This happens once per iOS version, although it’s extremely fine-grained – even going from iOS 11 beta 9 to iOS 11 beta 10 will cause this process to repeat.

What Xcode is doing is configuring its device support system so that it understands all the frameworks that ship inside the iOS version you connected, which in turn means it can symbolicate crash logs. This is no small amount of data – you can expect Xcode to chew up 2-3GB for each iOS version you connect.

A Glimpse Of Xcode Development

The problem is, Xcode doesn’t ever seem to want to remove device support once it’s installed, so if you’re an active iOS developer who doesn’t actively prune this yourself there’s a good chance you’ll find around 40GB or more of device support data – most of which is for iOS versions that you don’t even think about any more.

In my case, I recently finished writing a book teaching all the new iOS APIs in iOS 11, which meant I had installed iOS 11 betas 1 through 10 on my devices. If I hadn’t been cleaning Xcode’s device support directory, each of those combined would have been taking up a whopping 20GB of space, even though each beta version was effectively rendered obsolete as soon as its successor came out.

Save 20GB with this one weird trick

Xcode’s initial install size is beyond our control, but its extended post-install growth is something you can reduce. First, install the awesome tool GrandPerspective, then point it at your ~/Library/Developer directory.

This is where Xcode stores three chunky parts of its ecosystem:

  1. The iOS Device Support directory stores debugging data for individual iOS versions.
  2. The Derived Data directory is the storage area Xcode uses while building your apps.
  3. The CoreSimulator directory is where Xcode’s simulator data lives, including all apps you’ve installed into simulators.

Keep in mind that each of those simulators is feature complete, right down to those sample photos you see in the Photos app. If you’re curious, try searching ~/Library/Developer for “IMG_0005.JPG” – I found 90 copies of the same photo. Nice!

When GrandPerspective finishes – and it might take some time – you’ll see something like the image below:

GrandPerspective shows you the total space taken up by the scanned directory in the bottom-left corner (20.7GB for me), but you can also hover over individual files to see what they are and how much they take up.

A Glimpse Of Xcode Download

To make things easier to read I’ve added some annotations to mine so you can get an idea of where all the space goes:

OK, so maybe I’ve been a touch facetious, but the point is that the majority of the files you can see in my developer directory aren’t needed. You can literally just delete them outright and Xcode will recreate the bits it actually needs when you next plug an iOS device in.

If you want to clear out individual simulator directories you can, but honestly the easiest thing to do is zap the device support directories – they will usually be well over half the used space.

Here’s how to do it:

  1. Right-click one of the big files GrandPerspective found – it will be called dyld_shared_cache_arm64 – and choose Reveal In Finder.
  2. In Finder, hold down the Cmd key and press the Up cursor key a few times until you finally have a folder called “iOS DeviceSupport” selected.
  3. Go back into that folder and you’ll see it has directories for iOS version numbers, e.g. 9.3.5 (13G36), 10.3.2 (14F89), and 10.3.3 (14G60).
  4. Select all of them, delete them, then empty the trash.
  5. Plug in your iOS devices then launch Xcode so it can download the symbols you actually need.
  6. Feel smug.

Isn’t there a better way?

It’s understandable that Xcode needs some device support in order to function correctly. However, its insistence on keeping all device support is unhelpful, and it would be great to see some work being done to have this trimmed automatically.

A Glimpse Of Xcode

For example, would it be so bad for Xcode to scan its device support every time it launches, and say “well, they haven’t connected one of these in three months; let’s scrap it”? It could even be an option that’s disabled by default if Apple think so many want old device support around – but at least give the rest of us the chance to have Xcode use up less than 50GB.

Xcode: I love you, but I hope you’ll consider this an intervention and stay off the carbs in the run up to Xcode 10.

And finally, in case you were curious…

As difficult as it is to weigh one version of Xcode against another because their contents differ, it’s deeply unfair to weigh one IDE against another – what Apple chooses to bundle and what Google chooses to bundle bear little to no relation.

Still, admit it: you’re a teensy bit curious how Xcode stacks up against Android Studio, which is the tool our Android counterparts rely on for building apps.

Well, to satisfy your curiosity if nothing else, let me re-make that table…

VersionDownloadInstalled
Xcode 5.02.05 GB4.37 GB
Xcode 6.02.62 GB5.18 GB
Xcode 7.03.85 GB7.79 GB
Xcode 8.04.41 GB9.97 GB
Xcode 9.05.37 GB10.41 GB
Android Studio 2.3486MB861MB

Glimpse Core

In the words of Matthew Firlik, I don't think there's anything more to be said about that.

SPONSORED Would you describe yourself as knowledgeable, but struggling when you have to come up with your own code? Fernando Olivares has a new book containing iOS rules you can immediately apply to your coding habits to see dramatic improvements, while also teaching applied programming fundamentals seen in refactored code from published apps.

00:06 Today we'll have a look at the cool new refactoring features ofXcode 9. Back in the Objective-C days, we actually used AppCode's refactoring alot. It changed the way we wrote our code: instead of copying and pasting lines,we used the refactoring system to extract expressions and methods and to createvariables and properties.

00:52 Now with Xcode 9, we're getting a glimpse of what this way ofworking can look like. But the refactoring features are still in beta, so theydon't always work perfectly. Therefore, it's good to have your project underversion control.

Renaming

01:19 The most important shortcut to remember is Cmd+Shift+A, whichbrings up the new Actions menu at the current cursor position:

01:38 When we choose the Rename option, Xcode shows all the places whereViewController is used or mentioned, including the file name and thestoryboard reference. It even shows that the file header's comment blockmentions ViewController. This mention of the name in the comment block isinitially greyed out, but when we click it, it'll also be replaced.

02:07 Now we can type a new name, like PlayerViewController. When webuild, we find out something went wrong: Xcode updated the file reference in theproject, but it failed to rename the actual file. This shows that the systemisn't completely stable yet.

Extracting Expressions

03:04 Another thing Xcode can do is extract expressions. Let's say wehave the following statement:

03:26 Later we might decide we need to use the subview count in morethan one place, so it'd be good to extract it to a separate expression.Unfortunately, the shortcut Cmd+Shift+A works only for the current identifier,view, and not the whole expression. Instead, we have to select the entireexpression, view.subviews.count, and choose the menu option Editor > Refactor> Extract Expression. This results in the following:

03:58 And of course, we can then quickly rename the expression toviewCount using the Actions menu again:

04:19 If we prefer to only use the keyboard to extract the expression,we could select the expression and press Cmd+Shift+?. This opens the Help menusearch, in which we can simply start typing 'extract' and then navigate to thecorrect menu button using the arrow keys. This Help menu shortcut worksuniversally on macOS.

A Glimpse Of Xcode Tutorial

05:01 As an even quicker alternative to using the Help menu, we canassign a custom shortcut. In Xcode's preferences, under Key Bindings, we cansearch for 'extract expression' and assign a unique shortcut, sayCmd+Option+Ctrl+E. This is handy if we use the menu option a lot.

Various Useful Actions

06:17 By pressing Cmd+Shift+A on an if-statement, we can quickly addelse or else if statements:

06:55 There's also more support for working with enums. When we write aswitch statement for an enum, we can wait for the compiler error saying that theswitch must be exhaustive:

07:20 The compiler error now comes with a fix-it to add the missingcases. It sometimes even adds the variable binding — for title in this case:

08:00 If we add a new case to the enum, we can use the fix-it again.

08:21 You can also use the Cmd+Shift+A shortcut on the switch statementitself. This gives you more naive options to add a blank case or a default,without any knowledge of your enum.

09:07 Another useful bit is that you can press the Cmd key and hoverover your code with the mouse. This highlights the scope, which makes thestructure of your code visible. When clicking with the Cmd key pressed, you getthe same Actions menu as with the shortcut Cmd+Shift+A.

Extracting Methods

09:44 If we select our entire switch statement, we can extract a methodusing the Refactor menu:

10:11 Xcode moved the switch statement into a new method,extractedFunc, and added a call to this method at the line where the statementused to be. Of course, we can easily rename the method to printState viarefactoring.

10:46 It's interesting how method extraction deals with local variables.Let's say that instead of printing the state, we want to work with a variable.We undo the last changes and add a result variable:

11:16 If we extract the switch statement into a method, Xcode creates aninout parameter:

11:22 It makes sense that Xcode uses an inout parameter, since we'rewriting to the result variable. Xcode doesn't make unnecessary copies; it justwrites to the variable in place.

11:57 In the future, maybe we'll have a way to let the compiler refactorthe code to result = extractedFunc(). We can also try to add this customrefactoring ourselves in a future episode.