The Xth-Code Files: Xcode 10 Tips
Let's learn about what's new with XCode 10 for testing iOS applications.
Join the DZone community and get the full member experience.Join For Free
Dark Mode Interface and Mac App Support
- All-new dark appearance throughout Xcode and Instruments
- Asset catalogs add dark and light variants for custom colors and image assets
- Interface Builder switches between dark and light previews of your interface
- Debug your Mac apps in dark or light variants without changing OS settings
- Changes in the local repository or upstream on a shared server are highlighted directly within the editor...
- Support for cloud-hosted and self-hosted Git server offerings from Atlassian Bitbucket, as well as GitLab to go along with existing GitHub support.
- Xcode offers to rebase your changes when pulling the latest version of code from your repository.
- SSH keys are generated if needed, and uploaded to service providers for you.
Playgrounds Built for Machine Learning
- Place multiple cursors in your code editor to make many changes at once.
- Code folding ribbon can now hide any code block surrounded by braces.
- Over-scroll makes it easy to center the last lines of code in the middle of your screen.
Testing and Debugging
- New REPL-like model reruns your existing playground code instantly.
- Run your code up to any specific line, or type shift-return to run the code you just added.
- Import the Create ML framework to interactively train new models, and then write code to test the model right in the playground. When finished, drag the model into your app.
- Debugging symbols are downloaded from a new device five times faster than before.
- Xcode will spawn a collection of identical Simulators to take advantage of your multi-core Mac, and fan tests out to run in parallel, completing your test suite many times faster.
- Run tests in random or linear order.
- Instruments automatically show OSLog signposts you add into your code.
- Build and share your own custom instruments package to provide unique data visualization and analysis for your own code.
- Memory debugger uses a compact layout to make it easier to investigate your memory graph.
- Metal shader debugger lets you easily inspect the execution of your vertex, fragment, compute, and tile shader code.
- Metal dependency viewer provides a detailed graph of how resources are used in your Metal-based app.
- New build system enabled by default with improved performance throughout.
- Swift compiler builds each individual file significantly faster.
- Large Swift projects build for debugging dramatically faster when using the incremental build setting.
That's a pretty good selection of improvements, yes? And we have an admirably exhaustive collection of release notes to dig deeper:
So, we recommend you Read Them All! of course, but here let's call out the things that you definitely don't to overlook. #1 is your optimization flags:
If you've been around for a while, chances are you've set Whole Module Optimization for your project. This is now incorrect: it prevents incremental builds and those are faster. For the definitive word on that, see What's New in Swift from WWDC 2018, at 11:40:
Stop Using Debug with Whole Module Compilation
Doesn't get more explicit than that!
As well, there's a new Build with Timing Summary action (or the
-buildWithTimingSummary flag to
-xcodebuild) that will tell you exactly where all the time is going. There's a pair of articles here that go into more detail on those and other goodies:
#2, now that you've got the compilation flags settled, is how to parallelize your building as much as possible. There's a new Parallelize Build option in your scheme's build settings, and if it's not checked, go check it. With some luck, it'll all Just Work™, but if you have any code generating phases — we like R.swift, for instance — you're going to find that parallelization isn't going to work until you set the script file output filenames properly. This, and a good bit more, is explained in detail at Improving Your Build Time in Xcode 10.
#3 — speaking of parallelization — is that now your tests can be run in parallel, and randomized to boot, to make sure that you don't have any implicit dependencies in your tests! Those are another couple opt-in checkboxes — for full details watch WWDC 2018's What's New in Testing, or check the notes at WWDC 2018 What's New in Testing Recap.
That's about it for the major active actions you need take to make your project Xcode 10 savvy, but there are plenty more nuggets to dig up. For instance, exporting NSData easily:
Xcode 10 has a new QuickLook popover for (NS)Data. It now provides an "Export" feature that can be used to dump memory contents to a file. This is very convenient when you want to investigate data with external editors. (e.g. the fantastic HexFiend)
Also, you've no doubt noticed already that the Library is now its own window, and may have found its behavior somewhat opaque — to keep it open by holding down Option, and some more power tips, check out Xcode 10 Library Tips and Xcode 10 Storyboard Changes.
And let's not fail to not your annual reminder to clean your old Simulators:
$ xcrun simctl delete unavailable$ rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/
That should free up at least a few gigs for you.
Finally, if you're really interested in digging into Xcode trivia deeper than "delete it whenever things start acting squirrely," check out What's inside the Derived Data folder?
Published at DZone with permission of Alex Curylo, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.