Overview
Expo Apple Targets leverages Continuous Native Generation (CNG) to keep your target source files outside the generated iOS project. This enables you to develop native Apple extensions and targets while maintaining all the benefits of Expo’s automated workflow.The Magic /targets Directory
The plugin uses a special directory structure where each subdirectory in /targets represents a separate Apple target:
npx expo prebuild, the plugin:
- Discovers targets - Scans for
expo-target.config.@(json|js)files in the targets directory - Evaluates configuration - Processes each config file (supports both objects and functions)
- Generates Xcode project - Creates native targets and links them to your source files
- Preserves your code - All changes you make inside the
expo:targetsfolder in Xcode are saved outside theiosdirectory
The
expo:targets folder in Xcode is a virtual folder that links to your actual source files in the /targets directory. Changes are bidirectionally synced.Config Plugin Architecture
The plugin is built using Expo’s Config Plugin system and consists of several key components:1. Target Discovery (withTargetsDir)
The main config plugin scans your project for target configurations:
2. Target Processing (withWidget)
For each target, the plugin:
- Sanitizes the target name for Xcode compatibility
- Generates bundle identifiers (supports
.prefix for relative IDs) - Processes entitlements with automatic defaults
- Creates asset catalogs for icons, colors, and images
- Applies target-specific Xcode configurations
3. Xcode Manipulation (withXcodeChanges)
The plugin uses @bacons/xcode to manipulate the project file:
- Creates
PBXNativeTargetinstances - Configures build settings and configurations
- Links frameworks and dependencies
- Sets up file system synchronized groups
- Manages entitlements and Info.plist files
The plugin uses PBXFileSystemSynchronizedRootGroup, a modern Xcode feature that automatically tracks file changes in a directory without requiring manual project file updates.
Continuous Native Generation
CNG is a workflow where native project files are treated as build artifacts rather than source code:Traditional Workflow
CNG Workflow
Key Benefits
- No merge conflicts - The
iosdirectory can be gitignored - Reproducible builds - Same config always generates the same project
- Easy upgrades - Update Expo SDK without manual native migration
- Version control - Only commit your source files and config
The Virtual expo:targets Folder
When you open Xcode, you’ll see an expo:targets group in the project navigator:
with-xcode-changes.ts:594-617:
File Synchronization
The plugin uses Xcode’s file system synchronization feature to automatically track changes:- Add a new
.swiftfile → Xcode automatically includes it - Delete a file → Xcode automatically removes it
- Rename a file → Xcode automatically updates references
Build Process
When you build your app:- Xcode compiles the main app target
- Each extension target is built independently
- Extension targets are embedded into the main app bundle
- Code signing is applied to each target
- The final
.ipacontains all targets
Next Steps
Target Config
Learn about expo-target.config.js structure and options
Entitlements
Understand entitlements and app groups