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: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:| Folder | Contents |
|---|---|
| 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
- Navigate to the file
- Click to open
- Make changes
- Save (Cmd+S)
- App rebuilds automatically
Example: Changing a Color
Example: Adjusting Padding
Example: Fixing Text
Understanding Swift Code
Views (SwiftUI)
Most UI is in SwiftUI views:struct HomeView: View— Defines a viewvar body: some View— What it displaysVStack,HStack,ZStack— Layout containers- Modifiers like
.font(),.padding()— Styling
Models (Data)
Data structures:State Management
Using@Observable:
Reading Logs
Accessing Logs
- Open Code Editor
- Find the Logs panel/tab
- Run your app
- Watch output appear
Adding Log Statements
Ask the AI:Log Types
| Log | Meaning |
|---|---|
| Build output | Compilation status |
| Errors | What went wrong |
| Print statements | Your debug output |
| Runtime warnings | iOS system messages |
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:- Check the error in the Logs or chat
- Undo (Cmd+Z) if you can’t fix it
- Ask the AI: “Fix this error: [paste error]”
- Rebuild after fixing
Common Swift Errors
| Error | Cause | Fix |
|---|---|---|
Missing } | Unbalanced braces | Add missing brace |
| Type mismatch | Wrong data type | Check types |
| Unknown identifier | Typo or missing import | Check spelling |
Missing return | Function needs return | Add return statement |
Code Editor vs AI Chat
| Use Code Editor | Use AI Chat |
|---|---|
| Fixing typos | Creating new features |
| Changing values | Adding screens |
| Adjusting colors | Complex logic |
| Learning the code | Major refactoring |
| Quick tweaks | Design changes |
Combining Both
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
| Cmd+S | Save file |
| Cmd+Z | Undo |
| Cmd+Shift+Z | Redo |
| Cmd+F | Find in file |
| Cmd+G | Find next |
| Cmd+/ | Toggle comment |