This repository contains a simple SwiftUI demo app based on Apple's SwiftUI tutorial. It is designed as a hands-on workshop to help you master GitHub Copilot for Xcode through practical exercises.
- Code Completion: Get intelligent inline suggestions as you type
- Copilot Chat: Ask questions about your codebase and get instant answers
- Agent Mode: Multi-file refactoring and complex code generation
- Plan Agent: Break down complex tasks into actionable steps
- MCP Servers: Extend Copilot with GitHub integration
- Copilot Vision (optional): UI-aware code generation
Before starting the workshop, ensure you have:
- Xcode 15 or later installed
- GitHub Copilot for Xcode extension (Download here)
- Signed in to GitHub Copilot in Xcode with your GitHub account
Download the latest .dmg from the releases page and drag the app into Applications.
A background item will be added to enable the GitHub Copilot for Xcode extension app to connect to the host app. This permission is usually automatically added when first launching the app.
Grant the required permissions: Background, Accessibility, and Xcode Source Editor Extension.
- Background: Done in the previous step.
- Accessibility: The first time the application runs, a permission prompt will appear.
- Xcode Source Editor Extension: This must be enabled manually. Click Extension Permission from the GitHub Copilot for Xcode application settings to open the System Preferences to the Extensions panel. Select Xcode Source Editor and enable GitHub Copilot.
Option A (menu bar)
- Click the Copilot icon in the macOS menu bar
- Choose Sign in to GitHub Account
- Authorize in the browser when prompted
Option B (app → chat panel)
- Run the GitHub Copilot for Xcode app
- In the Copilot Chat panel that appears, click Sign in
- Authorize in the browser when prompted
Clone this repository and open in Xcode:
git clone https://github.com/silenceJialuo/copilot-xcode-workshop.git
cd copilot-xcode-workshop
open Landmarks.xcodeprojThe Copilot Chat panel should already be open by default. If you don't see it, you can open it in two ways:
- Via Xcode menu: Xcode → Editor → GitHub Copilot → Open Chat
- Via GitHub Copilot app menu: Click the menu bar icon → Open Chat
Goal: Learn how to select a model and use Copilot Chat to explore codebases.
Steps:
- Open the Landmarks project in Xcode
- Navigate to ContentView.swift
Path:
Landmarks/Views/ContentView.swift - Open the Copilot Chat panel (see Installation & Setup step)
- Select a model: In the chat input area, look for the model selector (to the right of the wrench/settings icon), click it and choose the model you want. If GPT-5 mini is available, you can try that first.
- Different models may provide different response styles and capabilities
- You can experiment with different models to see which works best for you
- Select Ask mode using the mode toggle
- Try these prompts:
Explain what this file doesWhat SwiftUI components are used in this view?
Expected Result: Copilot provides clear explanations of the code structure and functionality.
Tips:
- You can ask follow-up questions to dive deeper
- Use
@workspaceto query across the entire project - Reference specific code by selecting it before asking
- Try switching between different models to compare their responses
Goal: Experience AI-powered code completion while writing Swift code.
Scenario: Add a description field to the landmark row display.
Steps:
- Open LandmarkRow.swift
Path:
Landmarks/Views/Landmarks/LandmarkRow.swift - Locate the
HStackcontaining the landmark name (around line 14) - Below the landmark name
Textview, add this comment:
// Display the landmark description in one line; show full description on hover- Press Enter and wait for Copilot to suggest code
- You should see a suggestion like:
Text(landmark.description)
.font(.caption)
.foregroundColor(.secondary)
.lineLimit(1)- Press Tab to accept the suggestion
Try More:
- Add a comment for a date formatter
- Write a comment to create a computed property for landmark categories
- Start typing a function name and let Copilot complete the implementation
Goal: Use Agent Mode to make changes across multiple files automatically.
Scenario: Update the favorite indicator throughout the app to use heart icons.
Steps:
- Open LandmarkList.swift
Path:
Landmarks/Views/Landmarks/LandmarkList.swift - Open the Preview Canvas to see the current UI (Cmd + Option + Enter)
- Switch to Agent mode in the Copilot Chat panel
- Enter this prompt:
Update all favorite buttons to use heart-shaped icons (filled heart for favorited,
outline heart for not favorited) across all views in the project.
- Copilot will analyze the codebase and propose changes to multiple files
- Review the proposed changes in the diff view
- Check the Preview Canvas to see the updated UI
What Happened?
- Agent Mode identified all files with favorite functionality
- It updated icons consistently across
LandmarkRow,LandmarkDetail, and other views - Changes were made simultaneously across multiple files
Try More Complex Tasks (Optional):
Add a rating system (1-5 stars) to landmarks with mock dataImplement a dark mode toggle in the settings viewAdd categories filter chips at the top of the landmark list
Goal: Use Plan Agent to decompose large features into manageable steps.
Scenario: Add user authentication to the app.
Steps:
- Open the Copilot Chat panel
- In the Copilot Chat panel, use the mode dropdown to select Plan
- Enter this prompt:
I want to add user authentication to this app. Users should be able to:
- Sign up with email and password
- Log in and log out
- See personalized favorite landmarks
Create a plan for implementing this feature.
-
Copilot will generate a step-by-step implementation plan:
- Create User model and authentication service
- Add login/signup views
- Implement session management
- Update data models to associate favorites with users
- Add authentication state to the app
-
Review the plan and ask for clarification if needed
-
Execute the plan step by step, or ask Copilot to implement specific steps
Benefits of Plan Agent:
- Breaks down complex features into actionable steps
- Helps you understand the architecture before coding
- Identifies dependencies and potential issues early
- Provides a roadmap you can follow incrementally
Goal: Extend Copilot with GitHub integration using MCP (Model Context Protocol).
What is MCP? MCP allows Copilot to interact with external tools and services. The GitHub MCP Server lets Copilot access your repositories, issues, pull requests, and more directly from the chat.
- Open the Copilot Chat panel
- Click the wrench icon to open Settings (it opens the Tools tab)
- In the MCP settings:
- Click Browse MCP Servers
- Find and select GitHub from the registry
- Click Install
- Authenticate with GitHub when prompted
- Select the GitHub account/organization you want to grant access to
- In the Tools tab, the Available MCP Tools list will update automatically—confirm the GitHub MCP Server appears there
Once the GitHub MCP Server is installed, try these prompts in Copilot Chat (Ask or Agent mode):
Query 1: List Your Repositories
List all repositories in my GitHub account
Query 2: Check Pull Requests
What are the open pull requests in this project?
More Things You Can Try (Optional):
Show me recent issues in the <repository-name> repositoryGenerate release notes from commits
Goal: Use Copilot Vision to generate code from UI designs and screenshots.
Note: Copilot Vision may require specific feature flags or preview access. Check if it's available in your Copilot for Xcode installation.
What is Copilot Vision? Copilot Vision enables the AI to "see" and understand visual content like UI mockups, screenshots, and design files. You can upload images directly in the chat, and Copilot will generate code that matches the design.
Scenario: Create a new custom landmark card component from a design mockup.
Steps:
-
Prepare your design: Take a screenshot or find a design mockup of a card UI you want to implement (e.g., a modern card with image, title, subtitle, and action buttons)
-
Create a new Swift file:
- In Xcode, right-click on
Landmarks/Viewsfolder - Select New File → SwiftUI View
- Name it
LandmarkCard.swift
- In Xcode, right-click on
-
Open Copilot Chat panel in Agent mode
-
Click the Attach Image button (📎 icon) and upload your design mockup
-
Enter a prompt like:
Create a new SwiftUI view called LandmarkCard based on this design mockup.
The card should:
- Display a landmark image at the top
- Show the landmark name and location
- Include a favorite button
- Use the app's existing color scheme and follow iOS design guidelines
- Be reusable with any Landmark model
Make it responsive for different screen sizes.
-
Copilot will analyze the image and generate SwiftUI code in the new file
-
Review the generated code and test it by:
- Adding a preview at the bottom of the file
- Using it in
LandmarkListto replace existing row views
Example Prompts with Vision:
Create this card component in SwiftUI with proper spacing, shadows, and rounded cornersBuild a settings panel based on this screenshot, matching the iOS native style
Tips for Better Results:
- Use clear, high-resolution images or screenshots
- Provide specific requirements (colors, fonts, spacing)
- Mention the data model to use (e.g., "use the Landmark model")
- Specify platform requirements (iOS version, device sizes)
- Request specific SwiftUI features if needed (LazyVGrid, GeometryReader, etc.)
Try More:
- Create a custom detail header based on a design mockup
- Implement a statistics dashboard view from an image
- Build a custom filter/sort menu UI from a screenshot
-
Write Clear Comments: Use descriptive comments before functions to guide Copilot
// Function to validate email format using regex, returns true if valid func validateEmail(_ email: String) -> Bool {
-
Use Descriptive Names: Well-named variables and functions help Copilot understand context
// Good: Copilot understands what you need let filteredLandmarksByCategory = // Less clear let filtered =
-
Provide Examples: Show Copilot what you want with an example
// Example: formatDate("2024-01-15") returns "Jan 15, 2024" func formatDate(_ dateString: String) -> String {
- Be Specific: Instead of "improve this code", say "add error handling and input validation"
- Break Down Tasks: Large features work better as multiple smaller prompts
- Review Changes: Always review multi-file changes before accepting
- Iterate: If the result isn't perfect, provide feedback and ask for adjustments
- Select Context: Select relevant code before asking questions
- Use Slash Commands (if available):
/explain- Explain selected code/fix- Fix issues in selected code/tests- Generate unit tests/doc- Generate documentation
- Ask Follow-ups: Treat it like a conversation with a senior developer
Please refer to the official guide:
- GitHub Copilot for Xcode Documentation
- GitHub Copilot Documentation
- Apple SwiftUI Tutorials
- Model Context Protocol (MCP) Specification
This app uses XCTestPlans for organizing and running tests.
Run tests in Xcode: Press Cmd + U
Run tests via command line:
xcodebuild test -scheme Landmarks -destination 'platform=iOS Simulator,name=iPhone 15'After completing this workshop, you should be able to:
- Use Copilot Chat to understand and explore codebases
- Accept and use inline code suggestions effectively
- Apply Agent Mode for multi-file refactoring
- Break down complex features with Plan Agent
- Set up and use MCP servers (GitHub integration)
- (Optional) Generate code from UI mockups with Copilot Vision
- Write better prompts for more accurate suggestions
- Generate unit tests with Copilot
- Debug issues using Copilot's help
Now that you've completed the workshop, try using Copilot in your own projects:
- Start Small: Use inline suggestions for routine coding tasks
- Ask Questions: Use chat to understand unfamiliar codebases
- Refactor Confidently: Use Agent Mode for large-scale changes
- Iterate: Don't expect perfection on the first try - refine your prompts
- Stay in Flow: Let Copilot handle boilerplate so you focus on architecture
Remember: Copilot is a tool to augment your skills, not replace them. Always review generated code for correctness, security, and adherence to your project's standards.
Found issues or have suggestions for improving this workshop?
- Open an issue in this repository
- Submit a pull request with improvements
- Share your experience and learnings with the community
For GitHub Copilot for Xcode feedback: Visit the official repository
Happy coding with GitHub Copilot for Xcode! 🚀