Xcode 27 System Prompts and Documentation

repository·main·Indexed 19 days ago

https://github.com/artemnovichkov/xcode-27-system-prompts

A collection of system prompts, agent skills, and technical documentation extracted from Xcode 27. It includes .idechatprompttemplate files for coding and reasoning, specialized Agent Skills for security audits and SwiftUI, and reference guides for iOS 26/27 features such as on-device LLMs, Liquid Glass Design, and AppIntents integration with Visual Intelligence.

Tokens
47.8K
Snippets
123
Records
151
Agent score
67%

What's inside xcode-27-system-prompts

  1. What is Liquid Glass design in AppKit?

    main
    Liquid Glass is a dynamic material design that creates an immersive UI by blurring content behind it, reflecting surrounding colors/light, and reacting to user interactions in real time. In AppKit, this is implemented using two primary classes: NSGlassEffectView for individual glass elements and NSGlassEffectContainerView for managing groups of glass elements that can merge together.
  2. Overview of SwiftUI WebKit Integration

    main

    SwiftUI integrates with WebKit via the WebView struct and the WebPage class. This allows embedding web content (HTML, CSS, JS) into native SwiftUI apps with support for navigation, JavaScript execution, and deep customization.

    Core Components:

    • WebView: The SwiftUI view used to display web content.
    • WebPage: An observable class used to control and manage web content behavior, navigation, and state.
    • JavaScript Interaction: Capabilities to execute scripts and pass data between Swift and JS.
    • Navigation Management: Tools for loading URLs, HTML, or data, and managing history.
  3. Overview of Visual Intelligence in iOS

    main

    Visual Intelligence is a framework that allows iOS apps to integrate with system-wide visual search capabilities (via camera or screenshots). When a user performs a visual search, your app can provide relevant content that matches what they are looking at.

    Core Workflow:

    1. The Visual Intelligence framework detects objects in the camera or screenshots.
    2. The App Intents framework facilitates the exchange of this information with your app.
    3. Your app searches its own content for matches.
    4. Your app returns matches as app entities, which appear directly in the system's visual search interface.
  4. Configure Intent Modes with supportedModes

    main

    Use the supportedModes property on an AppIntent to control how and when the app is foregrounded during execution.

    Available IntentModes:

    • .background: Intent performs entirely in the background.
    • .foreground(.immediate): App is foregrounded immediately before perform() runs.
    • .foreground(.dynamic): App can be foregrounded during execution based on runtime conditions.
    • .foreground(.deferred): App performs in background initially but will be foregrounded before completion.

    You can combine modes (e.g., [.background, .foreground(.dynamic)]) to provide a background fallback with the ability to request the foreground.

    struct GetCrowdStatusIntent: AppIntent {
        static let supportedModes: IntentModes = [.background, .foreground(.dynamic)]
    
        func perform() async throws -> some ReturnsValue<Int> & ProvidesDialog {
            // ... implementation
        }
    }
  5. Handle accented rendering and background removal

    main

    visionOS supports Full Color (default) and Accented rendering modes. In Accented mode, the background is removed and replaced with a solid color matching the user's theme.

    To support this correctly:

    1. Use .containerBackground(for: .widget) to mark your background view. This allows the system to remove it when necessary.
    2. Use the @Environment(\.showsWidgetContainerBackground) property wrapper to detect if the widget is currently being rendered with or without its background.
    3. Ensure your widget design remains legible even when the background is removed.
    // Use containerBackground to mark removable backgrounds
    var body: some View {
        VStack {
            // Widget content
        }
        .containerBackground(for: .widget) {
            Color.gameBackground
        }
    }
    
    // Detect background presence
    @Environment(\.showsWidgetContainerBackground) var showsBackground
  6. Use SemanticContentDescriptor to access visual data

    main

    The SemanticContentDescriptor is the primary object used to describe what the user is looking at. It provides two main ways to identify content:

    • labels: [String]: A list of labels used by Visual Intelligence to classify items.
    • pixelBuffer: CVReadOnlyPixelBuffer?: The raw visual data from the camera or screenshot.

    You can implement your search logic to use either the labels, the pixel buffer, or both.

  7. Use SupportingPlaceRepresentation for service-specific IDs

    main

    To link a PlaceDescriptor to specific proprietary IDs from third-party mapping services (like Google Maps or Apple Maps), use SupportingPlaceRepresentation with the .serviceIdentifiers case. This takes a dictionary mapping service provider strings to their respective place IDs.

    You can retrieve a specific ID using descriptor.serviceIdentifier(for: "service_name").

    // Create with service identifiers
    let landmark = PlaceDescriptor(
        representations: [.address("1 Infinite Loop, Cupertino, CA 95014")],
        commonName: "Apple Park",
        supportingRepresentations: [
            .serviceIdentifiers(["com.apple.maps": "ABC123XYZ", 
                                "com.google.maps": "ChIJq6qq6jK1j4ARzl-WRHNx9CI"])
        ]
    )
    
    // Retrieve a specific ID
    let appleID = landmark.serviceIdentifier(for: "com.apple.maps")
  8. Combine multiple glass elements with UIGlassContainerEffect

    main

    Use UIGlassContainerEffect to group multiple UIGlassEffect elements. This allows them to blend and morph into one another when they are positioned close to each other. The spacing property determines the distance at which elements begin to merge.

    // Create a glass container effect
    let containerEffect = UIGlassContainerEffect()
    containerEffect.spacing = 40.0 // Distance at which elements begin to merge
    
    // Create the main container visual effect view
    let containerView = UIVisualEffectView(effect: containerEffect)
    containerView.frame = CGRect(x: 50, y: 400, width: 300, height: 200)
    
    // Create the first glass element
    let firstGlassEffect = UIGlassEffect()
    let firstGlassView = UIVisualEffectView(effect: firstGlassEffect)
    firstGlassView.frame = CGRect(x: 20, y: 20, width: 100, height: 100)
    firstGlassView.layer.cornerRadius = 20
    firstGlassView.clipsToBounds = true
    
    // Create the second glass element
    let secondGlassEffect = UIGlassEffect()
    secondGlassEffect.tintColor = UIColor.systemPink.withAlphaComponent(0.3)
    let secondGlassView = UIVisualEffectView(effect: secondGlassEffect)
    secondGlassView.frame = CGRect(x: 80, y: 60, width: 100, height: 100)
    secondGlassView.layer.cornerRadius = 20
    secondGlassView.clipsToBounds = true
    
    // Add the glass elements to the container's contentView
    containerView.contentView.addSubview(firstGlassView)
    containerView.contentView.addSubview(secondGlassView)
    
    // Add the container to your view hierarchy
    view.addSubview(containerView)
  9. Create and manage LanguageModelSession

    main

    A LanguageModelSession is used to interact with the model.

    • Single-turn interactions: Create a new session for each request.
    • Multi-turn interactions: Reuse the same session instance to maintain conversation context.
    • Concurrency: A session can only handle one request at a time. Check the isResponding property before sending a new request to ensure the session is available.
    // Basic session
    let session = LanguageModelSession()
    
    // Session with system instructions to steer behavior
    let instructions = """
        You are a helpful assistant that provides concise answers.
        Keep responses under 100 words and focus on clarity.
        """
    let sessionWithInstructions = LanguageModelSession(instructions: instructions)
  10. Manage multiple glass effects with GlassEffectContainer

    main

    When applying Liquid Glass to multiple views, wrap them in a GlassEffectContainer to improve rendering performance and enable blending and morphing effects between the glass elements.

    The spacing parameter determines how the effects interact:

    • Smaller spacing: Views must be closer to merge effects.
    • Larger spacing: Effects merge at greater distances.
    GlassEffectContainer(spacing: 40.0) {
        HStack(spacing: 40.0) {
            Image(systemName: "scribble.variable")
                .glassEffect()
    
            Image(systemName: "eraser.fill")
                .glassEffect()
        }
    }
  11. Understand the System Prompt Template structure

    main

    Xcode uses .idechatprompttemplate files to power its AI coding assistant. These templates are categorized by their role in the development workflow:

    Basic Coding & Reasoning

    • BasicSystemPrompt.idechatprompttemplate: Foundation for code analysis.
    • ReasoningSystemPrompt.idechatprompttemplate: Enhanced reasoning for complex tasks.
    • VariantASystemPrompt.idechatprompttemplate / VariantBSystemPrompt.idechatprompttemplate: Alternative prompt variants.

    Specialized Workflows

    • IntegratorSystemPrompt.idechatprompttemplate: Precise code editing.
    • NewCodeIntegratorSystemPrompt.idechatprompttemplate: Integrating entirely new code blocks.
    • FastApplyIntegratorSystemPrompt.idechatprompttemplate: Rapid modifications.
    • PlannerExecutorStylePlannerSystemPrompt.idechatprompttemplate: Planning-based coding.

    Context Providers

    These templates define how the AI perceives the current state of your project:

    • CurrentFile.idechatprompttemplate: Full current file context.
    • CurrentSelection.idechatprompttemplate: Only the selected code.
    • OriginalFile.idechatprompttemplate: The original state of the file before edits.

    Tool-Assisted & Agent Modes

    • ToolAssistedBasicSystemPrompt.idechatprompttemplate: Enables search and editing tools.
    • AgentSystemPromptAddition.idechatprompttemplate: Adds MCP tools, documentation search, and code style guidelines to the agent mode.
    • AgentAdditionalContext.idechatprompttemplate: Provides project structure and file context for the agent.