About This Technology
Xcode is Apple’s integrated development environment (IDE) that you use to build apps for Apple products such as the iPad, iPhone, and Mac. Xcode provides tools to manage your entire development workflow—from creating your app, to testing, optimizing, and submitting it to the App Store.
At a Glance
Use the App Store app on your Mac to download Xcode. It’s free. After you download Xcode, it automatically appears in Launchpad, where you can click the icon for Xcode to launch it.
The Xcode interface integrates code editing, user interface design, asset management, testing, and debugging within a single workspace window. The window reconfigures its content as you work. For example, select a file in one area, and an appropriate editor opens in another area. Select a symbol or user interface object, and its documentation appears in a nearby pane.
You can focus on a task by displaying only what you need, such as only your source code or only your user interface layout. Or you can work with your code and UI layout side by side. You can further customize your environment by opening multiple windows and multiple tabs per window.
Assisted Source Code Editing
Whether you are using Objective-C, Swift, C, C++, or a mix, Xcode checks your source code as you type it. When Xcode notices a mistake, the source code editor highlights the error and when possible, offers to fix it. Xcode speeds up your typing with intelligent code completion. Reduce your typing further with ready-to-use code snippets and source file templates, either the ones provided or ones you add. With Swift, Playgrounds let you experiment with code without building and running your app.
You can easily configure the source editor to display multiple views of the same file or to view multiple related files at once. Search-and-replace and refactoring operations help you make extensive changes to your code quickly and safely. With these and other capabilities, Xcode makes it easier for you to write better code faster than you thought possible.
Graphical UI Design
Interface Builder is a visual design editor that’s integrated into Xcode. Use Interface Builder to create the user interfaces of your iOS or Mac apps by assembling windows, views, controls, menus, and other elements from a library of configurable objects, or from ones you create. Use Storyboards to specify the flow of your applications and the transitions between scenes. Then graphically connect the objects and transitions to your implementation code.
With the Auto Layout feature, define constraints for your objects so that they automatically adjust to screen size, window size, and localization. With Size Classes, tune your mobile UI for any combination of screen size and orientation: customizing Auto Layout constraints, adding or removing views, and even changing the font.
The asset catalog in Xcode helps you manage the many images you’ll use for your app’s user interface—items such as icons, custom artwork, and launch images for iOS devices. With the particle emitter editor in Xcode, you can enhance your iOS or Mac game by adding animation effects involving moving particles such as snow, sparks, and smoke. For Mac apps, the SceneKit editor helps you work with scenes created in 3D authoring tools and exported as digital asset exchange (DAE) files.
When Xcode launches your app in debug mode, it immediately starts a debugging session. If you are running an iOS app, Xcode launches it either in iOS Simulator or on an iOS device connected to your Mac. If you are running a Mac app, Xcode launches it directly on your Mac.
You can debug your app directly within the source editor. View the contents of an object by moving your mouse over a variable name, and then use Quick Look to inspect a particular value. The debug area and the debug navigator let you carefully control the execution of your app while you examine the code. For finer control, the console gives command line access to the debugger.
Debug gauges display your app’s resource consumption to help you identify problems before your users do.
Testing and Continuous Integrations
To help you build a better app, Xcode includes a testing framework for functional and performance testing. You write the tests and use the test navigator to run those tests and see the results. You test code functionality unit tests. Performance tests make sure important parts of your app don’t leave the user waiting. Set triggers for running tests on a regular basis so you catch regression bugs in code and in performance.
Run your tests in the test navigator, look at the results, and make any changes needed to pass the tests. You can use the Xcode service, available in OS X Server, to automate the execution of tests. From Xcode on your development Mac, you create bots that run on a separate server to execute your unit tests either periodically or on every source code commit.
In addition to running unit tests, bots automatically perform static analysis on your code, build your app, and archive it for distribution to testers or the App Store. While performing these continuous integrations of your app, bots report build errors and warnings, static analyzer problems, and unit test failures.
Automatic Saves, Project Snapshots, and Source Control Management
While you work, Xcode automatically saves changes to source and project files. This feature requires no configuration, because Xcode continuously tracks your changes and saves them. You can revert a file to a previous state with Undo and Revert Document commands.
You can revert an entire project to a previous snapshot of a known working version with the Restore Snapshot command. Snapshots make it easy to back up the current version of your project. You create a snapshot by choosing File > Create Snapshot. You can also set Xcode to automatically create snapshots before you perform any mass editing operations and as part of a workflow.
To keep track of changes at a fine-grained level, use the Xcode source control management features. Xcode supports two popular source control systems: Git and Subversion. You can access remote Git and Subversion source code repositories, and you can create local Git repositories. Using the Xcode service, available with OS X Server, you can host Git repositories on your own server.
While you’re coding, Xcode makes detailed technical information available at your fingertips. When you want it, Quick Help keeps concise API information always in view, and Xcode application help is always close at hand with step-by-step instructions for performing common Xcode tasks. Xcode includes extensive documentation for using Xcode, and it provides comprehensive SDK documentation, including programming guides, tutorials, sample code, detailed framework API references, and video presentations by Apple engineers. All of these resources are viewable from the Xcode documentation viewer. As updated documentation becomes available, it downloads automatically in the background.
App Distribution to Testers and the App Store
Most of your development time is spent on coding tasks, but to develop for the App Store, you need to perform a number of administrative tasks throughout the lifetime of your app. In addition to Xcode, you’ll use the Member Center web tool to manage developer program accounts and entitlements, and you’ll use the iTunes Connect web tool to check the status of your contracts, set up tax and banking information, obtain sales and finance reports, and manage metadata about the app.
Xcode project configurations help prepare your app for distribution to beta testers and for submission to the App Store. Submitting your app is a multistep process that begins when you sign into iTunes Connect and supply necessary product information. In Xcode, you create an archive of your project and submit it to the store. When your app is approved, you use iTunes Connect to release it by setting the date. (If you are distributing your Mac app outside the store, you follow a slightly different process.)
Many of the screenshots used to illustrate this document are taken from the Adventure Xcode project described in code:Explained Adventure. To explore the Xcode features described in this guide on your Mac, obtain Xcode from the App Store, then download the Adventure project by clicking either link in this paragraph.
This guide introduces you to the major features and capabilities of Xcode. For a hands-on introduction to using Xcode, read either Start Developing iOS Apps Today or Start Developing Mac Apps Today. In each document, you use Xcode to create a simple app, and you learn the basics of programming with Objective-C.