Introduction to Xcode

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

Lesson 01: Getting to Know Xcode

Basic Workflow Demo

Episode complete

Play next episode

Next
Transcript

This video will start with a new project, then create a Hello World app and run it on the simulator.

Start by choosing Create New Project… from the Welcome to Xcode window or using the File ▸ New ▸ Project… menu item. For this demo, you’ll select an App. Explore some other templates when you have time to see what kinds of apps you might build.

Now, you’ll choose a name for your app. Here’s Hello World and an organization identifier. Notice that the bundle ID keeps changing as you change the name and the organization identifier.

This will be a SwiftUI app with no extra storage and won’t include tests. Once you’ve set up the options, save your project to your hard disk. Remember to uncheck the option to set up a Git repo if you don’t have Git already configured on your machine.

Looking at the app interface, you’ll see the code and the preview. On the left, you see your source file and the main app source file. The Hello_WorldApp file is the very first code that runs when your app runs. Select the file, and you’ll see that for a simple app, all it does is start your ContentView code.

An asset catalog is a different file type. Open that and you’ll see two entries: one for the app icon and one for an Accent Color. If you create a 1024x1024 pixels sized graphic and drop it in for the app icon, your app will use it everywhere.

Don’t round the corners when creating an app icon because iOS will round the corners for you automatically. As you work on an app, you’ll add images, JSON files, and all sorts of files into the catalog. Then, your code can reference them by their names.

Now, click the project icon and see the General settings. The Supported Destinations is where you can add or remove device types you support. If you make an app that looks great on an iPhone but doesn’t work quite right on an iPad, you can remove the iPad from the list. Now, users with iPads won’t be able to install your app.

Scroll down, and you’ll see the supported orientations. You may have noticed some apps rotate when you turn your device, and some don’t. You set that behavior on this screen.

Next, you’ll see the Signing & Capabilities screen. Click the plus button on the top left to see all the capabilities your app can support. Choose one that looks interesting, like Maps or Game Center.

Now, see that some configuration options for that service appear on this screen. Behind the scenes, Xcode has added these capabilities or entitlements to your app’s primary security certificate, which is shared with Apple.

The list of capabilities will look different for you if you’re part of the Apple Developer Program or are just on your own. Notice what happens when you select a different team. Certain of Apple’s frameworks are not available unless the team is part of the program.

Head back to ContentView and the editor. Find the word globe in the code. If you downloaded the SF Symbols app earlier, you can open that and look for a symbol you like. Or you can change globe to hand.wave, and you’ll notice that the icon in the preview changes.

Next, change Hello, world! to Hi, World!. While the cursor is still on the text, open the Attributes inspector with either the button or the keyboard shortcut Command-Option-4.

Notice that the Hi, World text is at the top, and some other configuration options are below. Change some options like font color or padding and see how they make the preview change and modify your code. Pretty neat!

Now click the name of the device at the top of the window. Notice the list of phones and iPads. Either keep the one you have or select a new iOS simulator. Now click the play button and wait a bit.

Finally, your app appears! Hi World. On the simulator, click the house icon. This is the same as clicking the home button or swiping up on a real device.

You can see the other apps installed on the simulator or bring your app back to the foreground by clicking it. Notice at the top of your computer’s screen that you’re no longer in the Xcode application but are using the Simulator application. Using the menu, you can simulate things like shaking or rotating the device or even a successful Face ID challenge.

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