Introduction to Xcode

Apr 24 2024 · Swift 5.10, iOS 17, Xcode 15

Lesson 01: Getting to Know Xcode

Xcode Tour Demo

Episode complete

Play next episode

Next
Transcript

This tour begins at the Welcome to Xcode screen with shortcuts to start projects on the left and shortcuts to your recent projects on the right. Click the close button and select the File menu and New File.

Xcode offers several templates for the various files that make up an app. If you scroll down, there’s even an empty text file. For now, select a Swift File template and click Next.

The standard Save dialog appears. Name your file and click Create.

Now that you’re looking at the editor for your file, you can see some panes using the keyboard shortcuts or open the View menu. Open the View menu now and select Navigators. You’ll see a list of the navigators, and you’ll also see their keyboard shortcuts. Open the Find navigator.

Type Foundation into the search bar and press Enter. You’ll see a list of the one matching file and also the line in that file that matches your search. Click the line, and Xcode will bring the focus to the search result in the editor.

There are controls around the text search box for the scope of the search. You can change how it matches words or case. You can also limit the scope of the search. Click In Workspace to see the scopes.

When you have a large project, you might want to limit the search to only the files you work on. You can save search scopes once you’ve made them to make your searching easier.

Now, go to the Bookmarks navigator. Click the button in the lower left to add a bookmark for the current file or the current line. You can also use bookmarks as a TODO list when writing code.

If you make a bookmark in the current file, you can select the bookmark in the Navigator area and then hover the mouse just to its left, and you’ll see a circle. Click that circle, and a little completed check appears. You can also mark an item complete by right-clicking the bookmark and choosing from the context menu. When using bookmarks for your TODOs, you can quickly get rid of them when you’re done by using the context menu in the lower left corner and selecting Delete All Completed Items.

Bookmarks aren’t just for code. Go back to the Find menu and right-click the search results. Add a bookmark for the search. Now, go back to the Bookmarks navigator, and you’ll see your search results. You can rerun this search at any time by hovering over the search name and then clicking the refresh button that appears.

Open the Inspector area by pressing Command-Option-0 or using the View menu to select the File inspector. If the inspector is blank, click anywhere in your source code file. You can rename the file from here. You can also see the path to the file on disk. If you click the button that’s a circle with an arrow, Finder will open, highlighting your file.

Now, looking at the Editor window, use the context menu on the top right to show the minimap if it isn’t already visible. When you click the minimap, Xcode will jump to that line of your source file. Also, when you have more code in the file, hovering over lines in the minimap will show you the names of properties and structures to help you find your way around.

Throughout this section, you’ve heard how important keyboard shortcuts are to work efficiently in Xcode. There’s one little trick you might try to make using them even easier.

For some people, getting your fingers to press Control and Shift or Command and Option and another key simultaneously is impossible. Think about the last time you used the Caps Lock key on your keyboard. Wouldn’t it be great if you could map one of the modifier keys to that? Then your fingers wouldn’t become tangled.

Go to the Apple menu and choose System Settings. Now scroll the list down until you find Keyboard. Click the Keyboard Shortcuts button.

Now, choose the Modifier Keys from the list. Here’s where you can remap the Caps Lock key to be Option or Control, or whichever you’re having trouble reaching. The original key works the same, but now you have a second way. If you make a change, click the Done button to save it. You can always go back later and restore the defaults.

That’s a quick tour of the Xcode interface. In the next section, you’ll start at the Welcome to Xcode window and end with an app running on an iOS simulator. You’ll also learn about some more parts of the interface that appear when you’re working on an entire app project and not a single file.

See forum comments
Cinema mode Download course materials from Github
Previous: Tour of Xcode Next: Building an App