Skip to main content

Code Editor

The Code Editor lets you see and edit the actual Swift code of your app. It’s perfect for learning, making quick tweaks, and understanding what the AI creates.
The Code Editor is available on Pro and Scale plans. Upgrade your plan to access this feature.

When to Use the Code Editor

Learning Swift

Watch the AI generate code, then explore it in the editor. You’ll learn:
  • Swift syntax and patterns
  • SwiftUI view structure
  • How professional apps are organized
  • iOS development best practices

Quick Tweaks

Sometimes it’s faster to edit directly:
  • Changing a color value
  • Adjusting spacing
  • Fixing a typo in text
  • Modifying a simple condition

Debugging

When something isn’t working:
  • Read the code to understand what’s happening
  • Add print statements
  • Check for obvious issues
  • See exactly what the AI generated

Reading Logs

View runtime output:
  • Print statements
  • Error messages
  • App behavior traces

The Code Editor Interface

File Browser

On the left, your project’s file structure:
YourApp/
├── Views/
│   ├── ContentView.swift
│   ├── HomeView.swift
│   └── SettingsView.swift
├── Models/
│   ├── Task.swift
│   └── User.swift
├── Services/
│   └── DatabaseService.swift
└── App.swift
Click any file to open it.

Editor Panel

The main area shows code with:
  • Syntax highlighting — Colors for keywords, strings, types
  • Line numbers — For navigation and reference
  • Search — Find text (Cmd+F)
  • Auto-indentation — Code stays formatted

Logs Panel

At the bottom (toggle to show):
  • Build output and errors
  • Print statements from your code
  • Runtime logs

File Organization

Nativeline organizes code into standard Swift structure:
FolderContents
Views/SwiftUI views (screens and components)
Models/Data structures and types
Services/API calls, database access, utilities
Resources/Images, fonts, assets

Making Edits

Editing Workflow

  1. Navigate to the file
  2. Click to open
  3. Make changes
  4. Save (Cmd+S)
  5. App rebuilds automatically

Example: Changing a Color

// Before
Text("Hello")
    .foregroundColor(.blue)

// After
Text("Hello")
    .foregroundColor(.orange)

Example: Adjusting Padding

// Before
VStack {
    // content
}
.padding(16)

// After
VStack {
    // content
}
.padding(24)

Example: Fixing Text

// Before
Button("Sumbit")

// After
Button("Submit")

Understanding Swift Code

Views (SwiftUI)

Most UI is in SwiftUI views:
struct HomeView: View {
    var body: some View {
        VStack {
            Text("Welcome!")
                .font(.title)

            Button("Get Started") {
                // action here
            }
        }
    }
}
Key concepts:
  • struct HomeView: View — Defines a view
  • var body: some View — What it displays
  • VStack, HStack, ZStack — Layout containers
  • Modifiers like .font(), .padding() — Styling

Models (Data)

Data structures:
struct Task: Identifiable {
    let id: UUID
    var title: String
    var isCompleted: Bool
    var dueDate: Date?
}

State Management

Using @Observable:
@Observable
class TaskManager {
    var tasks: [Task] = []

    func addTask(_ title: String) {
        tasks.append(Task(title: title))
    }
}

Reading Logs

Accessing Logs

  1. Open Code Editor
  2. Find the Logs panel/tab
  3. Run your app
  4. Watch output appear

Adding Log Statements

Ask the AI:
Add print statements to the save function to trace what's happening
Or add manually:
print("Save button tapped")
print("Saving data: \(userData)")

Log Types

LogMeaning
Build outputCompilation status
ErrorsWhat went wrong
Print statementsYour debug output
Runtime warningsiOS system messages
See Reading App Logs for more details.

Best Practices

Do

  • ✅ Save frequently (Cmd+S)
  • ✅ Make small, incremental changes
  • ✅ Test after each change
  • ✅ Use AI for complex changes
  • ✅ Learn from the generated code

Don’t

  • ❌ Make massive changes without testing
  • ❌ Delete code you don’t understand
  • ❌ Ignore compiler errors
  • ❌ Forget to save before rebuilding

When Code Changes Don’t Work

If your edits cause build errors:
  1. Check the error in the Logs or chat
  2. Undo (Cmd+Z) if you can’t fix it
  3. Ask the AI: “Fix this error: [paste error]”
  4. Rebuild after fixing

Common Swift Errors

ErrorCauseFix
Missing }Unbalanced bracesAdd missing brace
Type mismatchWrong data typeCheck types
Unknown identifierTypo or missing importCheck spelling
Missing returnFunction needs returnAdd return statement

Code Editor vs AI Chat

Use Code EditorUse AI Chat
Fixing typosCreating new features
Changing valuesAdding screens
Adjusting colorsComplex logic
Learning the codeMajor refactoring
Quick tweaksDesign changes

Combining Both

1

Use AI for the big picture

“Create a settings screen with toggle options”
2

Review the generated code

Open in Code Editor to understand what was created
3

Make small tweaks yourself

Adjust colors, padding, or text directly
4

Use AI for complex changes

“Add an animation when toggles change”

Keyboard Shortcuts

ShortcutAction
Cmd+SSave file
Cmd+ZUndo
Cmd+Shift+ZRedo
Cmd+FFind in file
Cmd+GFind next
Cmd+/Toggle comment