iOS Project Setup
iOS Project Setup
Create a new SwiftUI app in Xcode, configure signing and capabilities, and set your deployment targets.
Create a New Project in Xcode
Use the App template, choose Swift and SwiftUI, set your organization identifier (e.g.
com.example), and pick a bundle identifier like com.example.MyApp.
Checklist
- Product Name, Team, Organization Identifier
- Interface: SwiftUI; Language: Swift; Use Core Data (optional)
- Minimum iOS version (e.g. iOS 15+)
Use this checklist to ensure your project is created with the right templates, identifiers, and minimum OS version.
Run Examples in Xcode
Standard workflow (used in this tutorial)
Each example is organized into three files so you can run it as a small app:
- Demo.swift: The example's main code (view and/or supporting types).
- ContentView.swift: Shows the demo (uses types from
Demo.swift). - App.swift: Stable entry point with
WindowGroup { ContentView() }.
Tip: In your own Xcode project, avoid duplicate ContentView declarations.
Reuse a single ContentView and update its body per example, or create a simple chooser that navigates to uniquely named demo views.
Optional: Canvas Preview
You can also run any example via Xcode's Canvas Preview without changing your app entry point.
- Create a SwiftUI View: File → New → File... → SwiftUI View. Paste the example view code.
- Add a Preview: Use a
PreviewProvideror the#Previewmacro.
Example
import SwiftUI
struct Demo_Previews: PreviewProvider {
static var previews: some View { Demo() }
}
import SwiftUI
#Preview { Demo() }
- Open Canvas: Editor → Canvas. Build once if the preview is unavailable.
- Run & Interact: Click Resume/Play; use the device selector to switch models.
Troubleshooting: If the preview fails to load, Build, then Clean Build Folder.
Ensure the target is iOS and the file imports SwiftUI.
Project Settings
In the project navigator, select the app target and configure:
- Signing & Capabilities: Select your team and enable automatic signing.
- Deployment Info: Minimum iOS version, supported orientations.
- Bundle Identifier: Matches the one you will register in App Store Connect.
Tip: Use Assets.xcassets for your app icon and images.
Add capabilities (e.g., Push Notifications) here when needed.