FREE: Read a new Swift article every day – click here! >>

Xcode

Found 18 articles in the Swift Knowledge Base for this category:

 

How to add conditions to a breakpoint

When you place a regular breakpoint on a line of code, Xcode will pause at that point when it’s reached. However, sometimes you need something a little more fine-grained: perhaps you want the breakpoint to be ignored the first few times it’s hit, or perhaps you want execution to be paused only when a certain condition is true.... Continue Reading >>

How to add markers to the jump bar

Xcode’s jump bar – the popup menu describing all properties and methods in the current class, activated using Ctrl-6 – is a simple way to navigate around your file, particularly when you know you can just type a few letters to automatically filter the list.... Continue Reading >>

How to create a project using Swift Package Manager

Swift Package Manager is a tool that generates Swift projects then manages dependencies for them, and it’s commonly used if want to build your projects without Xcode. If you have Xcode installed then you already have the Swift Package Manager, but if you’re using Linux it will come with the Swift for Linux package from https://swift.org/.... Continue Reading >>

How to create exception breakpoints in Xcode

Exception breakpoints are a powerful debugging tool that remarkably few people know about, so please read the following carefully and put it into practice!... Continue Reading >>

How to debug view layouts in Xcode

View debugging lets you visualize exactly how your app is drawing to the screen by exploding your UI into 3D. So, if you're sure you added a button but you just can't see it, view debugging is for you: you can spin your interface around inside Xcode, and you'll probably find your button lurking behind another view because of a bug.... Continue Reading >>

How to fix the error “View controller is unreachable because it has no entry points and no identifier for runtime access”

All view controllers must be accessible somehow, and any that aren’t will cause Xcode to throw up a warning: “View Controller is unreachable because it has no entry points, and no identifier for runtime access.” There are three ways you can fix this:... Continue Reading >>

How to load assets from Xcode asset catalogs

Xcode asset catalogs are a smart and efficient way to bring together your artwork in a single place. But they are also optimized for performance: when your app is built, your assets converted to an optimized binary format for faster loading, so they are recommended for all kinds of apps unless you have a specific reason to avoid them. (Note: SpriteKit games should texture atlases if possible.... Continue Reading >>

How to lock Interface Builder controls to stop accidental changes

Interface Builder is the standard tool for making iOS interfaces using drag and drop, but it does make it remarkably easy to make a mistake – moving a view by accident, adjusting a property with a typo, or perhaps embedding one view inside another by dragging.... Continue Reading >>

How to make Xcode play sounds while debugging

Xcode has lots of tools to help you debug user interface problems, but it’s a little tricker to debug things you can’t see – network requests failing, data loading code going wrong, and so on.... Continue Reading >>

How to render example content using prepareForInterfaceBuilder()

Whenever you create a custom UIView subclass using @IBDesignable, it’s usually a good idea to provide it with some sample content so it can render meaningfully at design time.... Continue Reading >>

How to repeat code when debugging using the instruction pointer

Have you ever been debugging a problem in your code and really wished you could repeat a chunk of code without having to start from scratch?... Continue Reading >>

How to use storyboard references to simplify your storyboards

Storyboards deliver useful features, such as being able to see a lot of your user interface side-by-side and being able to design static cell designs for your table and collection views. However, they can also cause havoc with teams, because two developers attempting to modify the storyboard at the same time will immediately hit source control problems.... Continue Reading >>

How to use vector images in your asset catalog

Xcode lets you use vector images for all your artwork, which saves you having to worry about retina artwork, super retina artwork, and whatever Apple dreams up in the future. Even better, using this vector artwork has no performance cost – iOS and Xcode do all the work for you,... Continue Reading >>

How to used a named UIColor in code and Interface Builder

Since Xcode 9.0 we’ve been able to create named colors directly inside asset catalogs, which means it’s possible to select a precise color once then use it uniformly across all code and storyboards.... Continue Reading >>

What are breakpoints?

Breakpoints are locations in your code where Xcode will pause so that you can inspect the state of your program. They don’t have any impact on the final performance of your code – in fact, they don’t even exist in your code at all – so there’s no harm using them liberally.... Continue Reading >>

What are Swift error breakpoints?

Xcode has a few special breakpoint types, accessed by going to the breakpoint navigator (Cmd+8) then clicking + in the bottom-left corner. One of the options in that menu is Swift Error Breakpoint, and it allows Xcode to pause when Swift errors are thrown.... Continue Reading >>

What are watchpoints?

You’re probably already familiar with Xcode’s breakpoints, which allow you to pause code when a certain point is reached. Watchpoints also let you pause code, but their job is to pause when a variable is changed anywhere else in your code – it’s like a property observer, except implemented entirely using Xcode’s debugger.... Continue Reading >>

What is an IBOutlet?

When you connect your storyboard to your code Xcode inserts two special markers: @IBAction and @IBOutlet. Both of these effectively do nothing when you build your app, but they are still important because Xcode uses them to understand which of your properties and methods are relevant to Interface Builder.... Continue Reading >>

About the Swift Knowledge Base

This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions, all written for Swift 4.2.

Build for watchOS

Take your existing Swift skills to Apple's tiniest platform – check out Hacking with watchOS!

MASTER SWIFT NOW
Buy Testing Swift Buy Practical iOS 12 Buy Pro Swift Buy Swift Design Patterns Buy Swift Coding Challenges Buy Server-Side Swift (Vapor Edition) Buy Server-Side Swift (Kitura Edition) Buy Hacking with macOS Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with Swift Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let me know!

Click here to visit the Hacking with Swift store >>