Skip to content
Install

Add targets

Add widgets, extensions, watch apps and frameworks from Xcode's own target templates, or of any product type.

sochi add target runs the same template Xcode runs for File › New › Target. You get the same files, Info.plist and build settings Xcode would create, except that the Swift version, deployment target, version numbers, signing style and team are set to match your app.

Terminal window
sochi templates

This lists every target template in the selected Xcode, grouped by category. Under each one it shows the options the template accepts:

widget-extension Widget Extension
--option includeConfigurationIntent=true|false --option includeLiveActivity=true|false --option includeControl=true|false

Templates you’ve installed in ~/Library/Developer/Xcode/Templates are included. Templates for other platforms are listed with a prefix, such as watchos-app.

Terminal window
sochi add target widget-extension Forecast
sochi add target widget-extension Forecast --option includeLiveActivity=false
sochi add target "Notification Service Extension" RichAlerts

Pass the template, then the new target’s name. Name the template by its short name from the list, its full display name, or any part of its name that only it has. The target name must start with a letter and contain only letters and digits, because it becomes a Swift type name.

Repeat --option key=value to set template options. Anything you don’t set uses the template’s default.

Extensions are embedded in the app target. If the project has more than one app, choose the host with --host:

Terminal window
sochi add target widget-extension Forecast --host WeatherPro

If the host is a watch app, sochi uses the watchOS version of the template. A watch app added to an iOS app is linked to it as its companion. Test targets are wired to the target they test.

sochi follows your IDETemplateMacros.plist, so new files get the same header comment Xcode would give them.

A few templates can’t be run outside Xcode yet. These include templates that create several targets at once, use Objective-C or storyboard code, or need Xcode to generate an asset. sochi says which one and why, and writes nothing.

Without a template, --type creates a target of any product type the selected Xcode knows about, with a minimal source file:

Terminal window
sochi add target Kit --type framework --no-embed
sochi add target Shortcuts --type extensionkit-extension --point com.apple.appintents-extension
Option Effect
--type <type> The product type, short (app-extension) or full (com.apple.product-type.app-extension).
--point <id> The extension point identifier. Extensions need one; other types don’t accept it.
--no-embed Don’t embed the product in the app. Needed for products Xcode doesn’t embed.
--host <app> The app target to embed into. Defaults to the app target.

The bundle ID is the host’s bundle ID followed by the target name.

Run sochi run. Automatic signing registers the new target’s bundle ID with Apple during the build.

Like every edit, add target shows a diff, checks that xcodebuild lists the new target, and puts everything back if it doesn’t. Add --dry-run to preview it first.