The Xcode and SwiftPM tracks
Build the app bundle with the cef command plugin (Command Line Tools only) or with Xcode's build phase: one tool, equal tracks.
swift package --allow-writing-to-package-directory --allow-network-connections all \
cef bundle --product MyApp
| Track | Needs | Build |
|---|---|---|
| SwiftPM package | The Command Line Tools | swift build, then swift package cef bundle |
| Hand-written SwiftUI app, plain SwiftPM | The Command Line Tools | Your own @main CefSwiftApp in Sources/, the same two commands |
| Xcode project | Xcode 16 or later | Xcode’s build, with CefSwift’s Run Script phase |
The Command Line Tools are enough for both SwiftPM tracks; Xcode is needed only for an Xcode project.
Chromium does not run from a bare executable. It needs an app bundle with
its framework and five helper apps, laid out as it expects, each part
signed. CefSwift builds that bundle in either of two ways, and both run one
implementation, the package’s cefswift tool (Sources/CefBundling):
| SwiftPM | Xcode | |
|---|---|---|
| Who builds the app | swift package cef bundle, the cef command plugin, with SwiftPM |
Xcode, as for any app target |
| Who adds the framework and helpers | The plugin, through cefswift bundle |
A Run Script phase, through cefswift embed (Xcode) |
| Who signs the app | cefswift, last |
Xcode, last; cefswift signs the parts inside first, with the build’s identity |
| Settings | cefapp.json and options |
Xcode’s build settings, and CEF_… ones (Settings) |
| CEF download and cache | .cef/ in the package |
.cef/ beside the project (CEF_CACHE_DIR) |
| Checks | swift package cef doctor |
The phase runs cef doctor’s checks on every build, as Xcode errors and warnings |
What goes in the bundle, how it is signed and what each feature needs is the same either way, and the rest of this page applies to both.
The cef command
Run it from the root of the package that defines your app:
swift package --allow-writing-to-package-directory --allow-network-connections all \
cef bundle --product MyApp
The two --allow-… options pre-approve the plugin’s permissions: it writes
.cef/ and the bundle into the package directory and downloads CEF from
cef-builds.spotifycdn.com. Every subcommand needs them.
| Subcommand | Does |
|---|---|
new <Name> |
Creates a package for a new app from a template. See Starting from a template. |
download |
Downloads the pinned CEF distribution into .cef/, verifies its size and SHA-1, extracts it and converts the framework to the versioned layout. Does nothing if it is already prepared. |
bundle |
Builds the product, compiles the helper, then assembles and signs <Name>.app. Downloads CEF first if needed. See What bundle puts in the app. |
doctor <App.app> |
Inspects a built bundle and reports, per feature, whether it works and what is missing. See cef doctor. |
package <App.app> |
Wraps the app in a zip (ditto) or a disk image (hdiutil). |
notarize <App.app> |
Packages the app, submits it with xcrun notarytool submit --wait, and staples the ticket. |
info |
Prints the pinned CEF and Chromium versions and the state of the .cef/ cache. |
clean |
Removes .cef/. |
doctor, package and notarize take the app’s path, or --product <Name> for dist/<Name>.app. swift package cef help prints the usage.
Options of bundle:
| Option | Default | Effect |
|---|---|---|
--product <Name> |
Required | The executable product to bundle, from the invoking package or a dependency. |
--configuration debug|release |
release |
Build configuration. |
--output <dir> |
dist |
Output directory, relative to the package. |
--config <file> |
cefapp.json beside the sources of the product’s executable target |
The settings file. See Per-product settings. |
--bundle-id <id> |
bundleIdentifier, else com.cefswift.<name> |
The app’s bundle identifier. |
--name <Name> |
The product name | The app, executable and display name. |
--version <version> |
version, else 1.0 |
CFBundleShortVersionString, the version users see. |
--build <number> |
build, else 1 |
CFBundleVersion, the build number. |
--sign <identity|-> |
signingIdentity, else detected |
Code-signing identity: a name, part of one, or a SHA-1 hash; - signs ad hoc. See Code signing. |
--team-id <ID> |
teamIdentifier, else the certificate’s |
The team identifier for $(TeamIdentifierPrefix). |
--keychain <file> |
signingKeychain, else the search list |
A keychain to find the identity in. |
--capability <name> |
Adds to capabilities |
A feature to enable; repeatable. |
--info-plist <file> |
None | A property list merged into the app’s Info.plist, after infoPlist; repeatable. |
--entitlements <file> |
entitlements |
The app’s entitlements file. |
--provisioning-profile <file> |
provisioningProfile |
Embedded as Contents/embedded.provisionprofile. |
--[no-]hardened-runtime |
hardenedRuntime, else on for Apple team identities |
Signs executables with --options runtime. |
--[no-]timestamp |
timestamp, else on for Developer ID and App Store identities |
A secure timestamp from Apple’s server. |
--package zip|dmg |
None | Packages the result, as cef package does. |
--notarize |
Off | Packages and notarizes the result; needs --keychain-profile <name> or notarization.keychainProfile. |
--flavor minimal|standard |
minimal |
Which CEF distribution to download. See Flavors. |
--architectures arm64|x86_64|universal |
architectures, else the build machine’s |
What to build the app and helper for, and which CEF framework to bundle. See Architectures. |
--manifest <path> |
CEF_VERSION.json |
A different CEF manifest. |
--open |
Off | Opens the app once it is bundled. |
download takes --platform (or --architectures), --flavor and
--manifest as well, and info takes --manifest.
The plugin finds CEF_VERSION.json in the invoking package or in any of its
dependencies, so an app that depends on CefSwift uses the CEF version that
CefSwift pins. To bundle a different CEF version, pass --manifest with a
CEF_VERSION.json pinned to it. That CEF build must still provide the
CEF_API_VERSION the vendored headers pin, with the same API hash, or the
app fails to start with CefError.apiHashMismatch or CefError.loadFailed.
The cache lives in the invoking package’s .cef/. Add .cef/ and dist/
to .gitignore.
The plugin finds the product in the package graph, builds it, the helper
and the helper’s startup library with SwiftPM, and runs cefswift for the
rest: it checks the settings before building, downloads CEF, then
assembles and signs the bundle.
Starting from a template
cef new writes a package for a new app, ready to bundle: Package.swift,
its sources, cefapp.json, a README.md and a .gitignore that leaves out
.cef/ and dist/. Without a CefSwift checkout, a script fetches
CefSwift, builds its cefswift tool and runs cefswift new in the current
directory; then one command builds and opens the app:
curl -fsSL https://raw.githubusercontent.com/Rajaniraiyn/CefSwift/main/Scripts/new-app.sh \
| sh -s -- MyBrowser --template browser
cd MyBrowser && swift package --allow-writing-to-package-directory --allow-network-connections all \
cef bundle --product MyBrowser --open
In a package that already depends on CefSwift, or in a checkout of it,
swift package cef new <Name> does the same, writing <Name>/ inside the
package (--output elsewhere, with --allow-writing-to-directory <dir>
before cef).
| Template | What it is |
|---|---|
browser (the default) |
A tabbed browser: the Browser example’s core (Chromium’s tabbed windows under a SwiftUI tab rail and toolbar, menus, settings, restoring windows) and its address bar with suggestions, bookmarks, history, start page, find bar, downloads, extensions and Memory Saver features, each a folder of Features/, with their unit tests. Needs macOS 15. |
app |
An app shell: native sections that are web pages, the app’s own content served from its resources at app://content/, and a JavaScript bridge to Swift. |
minimal |
One window with one web page, on the .embedded configuration. |
The browser template copies those files from Examples/Sources/Browser
when it runs, so it is the example’s code at the version it comes from;
Templates/browser/template.json lists what it copies. Each template’s
app takes -smoke YES (the browser: -screenshot <file.png>) to check that
it starts and loads a page.
| Option | Default | Effect |
|---|---|---|
--template browser|app|minimal |
browser |
Which template. |
--output <dir> |
<Name> (cefswift: in the current directory; the plugin: in the package) |
Where the package goes. It must not exist, or be empty. |
--display-name <name> |
The name, split into words (My Browser) |
displayName in cefapp.json. |
--bundle-id <id> |
com.example.<name> |
bundleIdentifier in cefapp.json. |
--xcode |
Off | Also writes <Name>.xcodeproj and CefSwift.xcconfig: an app target on the same sources, set up as in Xcode. |
--cefswift-version <1.2.3> |
The release the templates come from, when they come from a release tag | Depends on that release, up to the next minor version. |
--cefswift-branch <name> |
Depends on a branch of CefSwift’s repository. | |
--cefswift-path <dir> |
The checkout the templates come from, when it is not at a release tag | Depends on a local checkout. |
<Name> is the package, target and module name, so it must be a Swift
identifier.
Without Xcode
The cef command needs only the Command Line Tools
(xcode-select --install): swift build, swift test and swift package cef bundle build, test and assemble an app with them alone, and CI checks
that on every pull request. Two SwiftUI features are macros whose plugin
(SwiftUIMacros) Apple ships only with Xcode, so code built with the tools
alone avoids them:
-
@Entry,#Previewand@Previewable, in every SDK: write anEnvironmentKeyout instead of@Entry, and leave previews to Xcode. -
@State, with the macOS 27 SDK of the Command Line Tools 27.2: that SDK declares aStatemacro beside the property wrapper, and@Stateresolves to the macro (external macro implementation type 'SwiftUIMacros.StateMacro' could not be found for macro 'State()').@StateObject,@Binding,@Environmentand@FocusStateare unaffected. Either build against the tools’ macOS 26 SDK,export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdkor name the property wrapper through an alias, which is what CefSwift and its examples do; it is the same
Statetype at run time:// Anywhere in the target: the property wrapper under another name. typealias ViewState = SwiftUI.State struct ContentView: View { @ViewState private var page = CefPage(url: URL(string: "https://example.com")!) var body: some View { CefWebView(page) } }No release of the Command Line Tools ships the plugin yet (27.2 does not); once one does,
@Stateworks again and the alias can go.
Xcode
An Xcode app target builds, embeds and signs the app as it always does. A Run Script phase at the end of its build phases adds what Chromium needs, before Xcode signs the app:
-
Add the package (File › Add Package Dependencies…, or Add Local… for a local copy) and its
CefSwiftUIproduct (orCefKit) to the app target. Xcode builds CefSwift and copies its resource bundles (CefSwift_CefKit.bundle) into the app, whereBundle.modulefinds them. -
Remove App Sandbox in Signing & Capabilities (see App Sandbox). Keep the hardened runtime.
-
Give the target CefSwift’s settings: copy
Examples/Xcode/CefSwift.xcconfiginto the project and choose it as the target’s configuration file (Project › Info › Configurations), or set them yourself:Setting Value Why ENABLE_USER_SCRIPT_SANDBOXINGNOThe phase runs SwiftPM on the package and writes the helper apps into the app; a sandboxed script can do neither. ARCHS$(NATIVE_ARCH_ACTUAL), or Xcode’s default for a universal appThe phase fetches CEF for each architecture the build targets: this one Mac’s keeps Release builds and archives to one download. See Architectures. CEFSWIFT_PACKAGE_DIR$(BUILD_DIR)/../../SourcePackages/checkouts/CefSwiftWhere Xcode put the package, to find the phase’s script. For a local package, its path. RUNTIME_EXCEPTION_DISABLE_LIBRARY_VALIDATIONYES, only while the target signs ad hocSee Signing in Xcode. A setting in the target’s Build Settings wins over the file, so remove the target’s own
ENABLE_APP_SANDBOX(step 2 does) if it is there. -
In Build Phases, add a Run Script phase after all the others, turn off “Based on dependency analysis” (the phase decides for itself what is out of date), and set it to run:
"$CEFSWIFT_PACKAGE_DIR/Scripts/xcode-embed.sh" -
Make the app’s
@maintype aCefSwiftAppinstead of anApp, and Run.
Examples/Xcode is a project set up this way; see
Examples.
The phase (Scripts/xcode-embed.sh, then cefswift embed):
- builds
cefswift,cefswift-helperand its startup library with SwiftPM, in release, into$(OBJROOT)/CefSwift(about a minute, the first time; later, only when their sources change), with a clean environment so that Xcode’s settings do not reach that build; - downloads the pinned CEF distribution into
CEF_CACHE_DIRon first use; - adds
LSEnvironment(MallocNanoZone = 0) andNSPrincipalClassto the app’s Info.plist and, fromCEF_CAPABILITIES, the capabilities’ keys; Xcode’s own keys win; - copies the framework, trimmed (locale packs,
SwiftShader), the startup library and the five
helper apps into
Contents/Frameworks, and signs them inside out with the build’s identity (EXPANDED_CODE_SIGN_IDENTITY), hardened runtime (ENABLE_HARDENED_RUNTIME) and keychain (OTHER_CODE_SIGN_FLAGS), giving each helper what it needs of the app’s entitlements: get-task-allow (so a debugger can attach), camera and microphone access for the base helper, andallow-jitfor the renderer and GPU helpers; - runs
cef doctor’s checks of the helpers, the framework, linking and features on the app as Xcode is about to sign it, as Xcode errors and warnings in the Issue navigator (CEF_DOCTOR = NOturns them off).
When nothing that decides these parts has changed, an incremental build
leaves them as they are and does not run SwiftPM. What decides them: the
CEF version and framework, the architectures, the app’s Info.plist and
localizations, every entitlement and its value, the signing identity,
keychain and flags, the trimming settings, cefapp.json’s contents, and the
helper and cefswift as built. The phase then takes about 2 seconds, most
of it cef doctor’s checks (measured with the Xcode example on an M3; the
whole incremental build took 3.7 s). Xcode then signs the app, sealing
everything inside.
The app’s own entitlements stay Xcode’s (CODE_SIGN_ENTITLEMENTS and the
entitlement build settings). When a capability or the signature needs one
the app lacks, the phase stops the build and names the setting, such as
ENABLE_RESOURCE_ACCESS_CAMERA = YES.
The app executable is not linked to the framework, as cef bundle links
it (the helpers are): CefKit loads the framework with dlopen, so the app
process holds the framework’s 12 MB of fixed-up pointers privately (see
architecture). Linking
the app needs the framework before the target links, which only a binary
framework product would give Xcode.
Signing in Xcode
Xcode signs with “Sign to Run Locally” (ad hoc) until the target has a
team. Library validation, part of the hardened runtime, loads a library
only when it carries the process’s team identifier, and an ad hoc
signature has none, so an ad hoc, hardened app cannot load CEF’s framework
(nor Xcode’s own .debug.dylib: “mapping process and mapped file
(non-platform) have different Team IDs”). Xcode 27 turns the hardened
runtime off for Debug builds signed ad hoc, so they run; Release builds
keep it, and need RUNTIME_EXCEPTION_DISABLE_LIBRARY_VALIDATION = YES
until the target signs with a team. The phase stops a build that would
fail this way. With a team (Apple Development, Developer ID), every part
carries the team, and no exception is needed.
Xcode turns RUNTIME_EXCEPTION_* build settings into entitlements from
version 26. With an older Xcode, add the
com.apple.security.cs.disable-library-validation entitlement to the
target’s .entitlements file instead, for as long as it signs ad hoc.
Debugging and previews
Run in Xcode starts the app, Chromium’s browser process, under the
debugger. Renderers, the GPU process and utilities are the helper
processes; to debug one, use Debug › Attach to Process by PID or Name with
<App> Helper (Renderer) (or another helper) and “Wait for the next
launch”, then do what starts it, such as opening a page. The helpers have
get-task-allow whenever the app does, as in Debug builds. Chromium’s
switches go in the scheme’s arguments: --renderer-startup-dialog pauses
each renderer until a debugger attaches, and --no-sandbox runs without
Chromium’s sandbox once.
SwiftUI previews run the app’s code inside a process of Xcode’s, where
Chromium cannot start its helpers. CefSwiftApp does not start Chromium in
previews (XCODE_RUNNING_FOR_PREVIEWS), and a CefWebView shows a
placeholder until Chromium runs, so a #Preview of a view that contains
one renders the rest of the view. Run the app to see the page. An AppKit
host view (CefWindowedPageView) needs a running runtime; keep it out
of previews.
Architectures
Each track builds the helper and fetches CEF for exactly the architectures the app is built for:
| Build | Architectures | Downloads, first time | Cache afterwards |
|---|---|---|---|
cef bundle (default), or an Xcode Debug build (ONLY_ACTIVE_ARCH) |
The build machine’s | One distribution: 141 MB for arm64, 149 MB for x86_64 | 486 MiB: the archive and the distribution |
cef bundle --architectures x86_64 on Apple silicon |
x86_64 | 149 MB | 506 MiB |
cef bundle --architectures universal, or an Xcode Release build or archive with ARCHS for both |
arm64 and x86_64 | Both distributions, 290 MB; only the one not in the cache yet | Both, and the universal framework merged from them: 1.6 GiB (both archives 277 MiB, both distributions 716 MiB, the universal framework 606 MiB) |
CEF publishes one distribution per architecture. A universal build merges
the two frameworks: each Mach-O file is lipo -create of the two official
files, the resources CEF names by architecture
(v8_context_snapshot.arm64.bin, webui_code_cache.x86_64.pak) come from
their own distribution, and every other file must be identical in both,
or the merge stops. The merged framework is cached beside the two, so
switching between arm64, x86_64 and universal downloads nothing twice.
Merging takes about 3 seconds. A universal Minimal.app is 592,916 KiB,
against 306,136 KiB for arm64 and 322,212 KiB for x86_64.
swift package cef bundle builds for the machine it runs on unless
--architectures (or cefapp.json’s architectures) asks for another;
it builds the app, the helper and its startup library for those with
swift build --arch, so an Apple silicon Mac makes an Intel or universal
app without Rosetta. In Xcode the architectures are Xcode’s own,
ARCHS and ONLY_ACTIVE_ARCH: a Debug build on Apple silicon is arm64
only, and an archive for both is universal. cefapp.json’s
architectures read through CEF_APP_CONFIG does not change them; the
phase warns when it disagrees.
Settings
Each setting has one place in each track: Xcode’s own build setting where
Xcode has one, a CEF_… build setting where only CefSwift does, and a key
of cefapp.json (or an option of cef bundle) for
SwiftPM. CEF_APP_CONFIG names a cefapp.json for an Xcode build to read
as well, so a project built both ways keeps CefSwift’s settings in one
file: a CEF_… setting wins over it, and for the keys Xcode owns, the
phase warns, at the key’s line, when the file disagrees with Xcode.
| Setting | Xcode | cefapp.json (option) |
|---|---|---|
Bundle identifier (helpers: <id>.helper…) |
PRODUCT_BUNDLE_IDENTIFIER |
bundleIdentifier (--bundle-id) |
App and executable name (helpers: <name> Helper…) |
PRODUCT_NAME |
The product name (--name) |
| Display name | INFOPLIST_KEY_CFBundleDisplayName |
displayName |
| Version, build | MARKETING_VERSION, CURRENT_PROJECT_VERSION |
version, build |
| Minimum macOS | MACOSX_DEPLOYMENT_TARGET |
minimumSystemVersion |
| Info.plist keys | INFOPLIST_KEY_…, INFOPLIST_FILE |
infoPlist (--info-plist) |
| Usage descriptions | INFOPLIST_KEY_NSCameraUsageDescription, … |
usageDescriptions |
| Capabilities (features) | CEF_CAPABILITIES; camera and microphone also follow from ENABLE_RESOURCE_ACCESS_CAMERA and …_AUDIO_INPUT |
capabilities (--capability) |
| App entitlements | CODE_SIGN_ENTITLEMENTS, ENABLE_RESOURCE_ACCESS_…, RUNTIME_EXCEPTION_… |
entitlements (--entitlements) |
| Helper entitlements | CEF_HELPER_ENTITLEMENTS_HELPER, …_ALERTS, …_GPU, …_PLUGIN, …_RENDERER |
helperEntitlements |
| Signing identity, team | CODE_SIGN_IDENTITY, DEVELOPMENT_TEAM |
signingIdentity, teamIdentifier (--sign, --team-id) |
| Keychain | OTHER_CODE_SIGN_FLAGS = --keychain <file> |
signingKeychain (--keychain) |
| Hardened runtime | ENABLE_HARDENED_RUNTIME |
hardenedRuntime (--[no-]hardened-runtime) |
| Secure timestamp | OTHER_CODE_SIGN_FLAGS = --timestamp; Xcode’s Developer ID export adds one |
timestamp (--[no-]timestamp) |
| Provisioning profile | Signing & Capabilities (PROVISIONING_PROFILE_SPECIFIER) |
provisioningProfile |
| Locale packs kept | CEF_LOCALIZATIONS (application, all, or a list: en fr) |
cef.localizations (--localizations) |
| SwiftShader | CEF_SOFTWARE_GPU_FALLBACK (include, exclude) |
cef.softwareGPUFallback (--software-gpu-fallback) |
| Chrome extensions the app ships | CEF_EXTENSIONS (paths from the project’s directory, separated by spaces) |
extensions |
| CEF version | CEF_MANIFEST (a CEF_VERSION.json) |
--manifest |
| CEF flavor | CEF_FLAVOR |
--flavor |
| CEF cache | CEF_CACHE_DIR, default $(PROJECT_DIR)/.cef |
.cef/ in the package |
| Notarization | The Organizer, or xcrun notarytool (Distribution) |
notarization (--notarize) |
cef doctor |
Every build (CEF_DOCTOR = NO turns it off), and cefswift doctor <App.app> |
swift package cef doctor |
Helper names and bundle identifiers derive from the app’s, because Chromium finds the helpers by name; neither is a setting.
For CI and offline builds, keep the cache between runs: .cef/downloads
holds the archive (about 135 MB) and .cef/dist the prepared framework.
With the archive there, nothing is downloaded; a clone of another .cef
(cp -Rc) works as well.
Where CEF comes from
Both tracks download the official CEF distributions that CEF_VERSION.json
pins (the minimal flavor, for each architecture the build targets) from
cef-builds.spotifycdn.com, check their size and SHA-1, convert the
framework to the versioned layout, merge a universal one when the build is
for both (Architectures), and keep them in the cache:
.cef/ in the package for SwiftPM, CEF_CACHE_DIR for Xcode.
CefSwift hosts no copy of CEF. A SwiftPM binary target was measured and not used: it cannot be conditioned on architecture, so it would make every dependent download both architectures (design notes, The framework as a binary target).
Building with SwiftPM and with Xcode: one tool, two front ends
Measured and decided on 2026-11-14 with Xcode 27.2 and Swift 6.4, by
setting up a new app each way from scratch (an swift package init app,
and a SwiftUI app project as Xcode 27’s template makes it, both depending
on a local CefSwift).
What each track needed before. SwiftPM: seven steps (init, platforms
and dependency in Package.swift, the app, cef bundle with its two
--allow-… options, open, .gitignore), one surprise (swift run cannot
start Chromium) and one wrong hint (the bundle’s “check it with” line left
out the options cef doctor needs). Xcode: the build succeeded and the app
stopped at launch with CefError.frameworkNotFound, whose fix named
swift package cef bundle. Nothing described the Xcode track beyond “build
the same two products with the same link order”; making it work by hand
meant downloading and converting CEF, linking the helper as the plugin
does, writing five helper apps and their Info.plists, signing inside out,
and finding out, one launch at a time, that:
- Xcode’s template turns on App Sandbox, in which Chromium stops at launch
(
bootstrap_check_in …MachPortRendezvousServer…: Permission denied; bundling); - the template’s User Script Sandboxing keeps a Run Script phase from reading anything it did not declare or writing into the app;
- Release builds are universal by default, and a CEF distribution has one architecture;
- Xcode turns the hardened runtime off for ad hoc Debug builds but keeps
it for Release, where library validation refuses an ad hoc framework (and
Xcode’s own
.debug.dylib, had the Debug build kept it); - Xcode signs the app last, so the parts inside must be signed before, in
a phase after Xcode’s own; and Xcode’s resource bundles
(
CefSwift_CefKit.bundle, with an Info.plist and no code) are sealed by the app’s signature, not signed on their own.
What worked without help: Xcode builds the package, copies its resource
bundles to Contents/Resources, where Bundle.module finds them, and the
Debug build’s .debug.dylib and __preview.dylib do not disturb the
helpers, whose names derive from EXECUTABLE_NAME.
Where the shared logic lives. It was Swift in the command plugin, which only SwiftPM can run. The options:
| Option | For | Against | Chosen |
|---|---|---|---|
| An executable tool target that the plugin and an Xcode Run Script phase both run | One implementation; the convention of SwiftLint, swift-format and DocC (a plugin over a tool); testable as a library target | The Xcode phase builds the tool with SwiftPM once per derived-data folder (about a minute) | Yes: CefBundling (library) and cefswift (tool) |
| A SwiftPM build tool plugin on the app target | Xcode runs it with no script | A build tool plugin writes only into its own work directory; its outputs become sources or resources (Contents/Resources), never Contents/Frameworks, and it runs before the app is linked and signed. It cannot add helper apps to the app or sign them, in Xcode 27 as before |
No |
| An Xcode command plugin (XcodeProjectPlugin) | Runs from Xcode’s menu | Manual, not part of a build | No |
| Helper apps as Xcode targets | Xcode signs and embeds them | Five targets, Info.plists and Copy Files phases in every app project; helper names follow the app’s, so they cannot come with the package | No |
| Prebuilt helpers shipped in a framework or XCFramework | Xcode embeds them | Chromium finds helpers as <executable> Helper (…) in the app’s Contents/Frameworks, their bundle identifiers follow the app’s, and they must carry the app’s signature for library validation, while Embed & Sign signs the framework, not the apps inside it |
No |
| CEF as an XCFramework binary target (proposed separately) | Xcode embeds, signs and links the framework itself; universal builds | Needs a release asset per CEF version; does not cover the helpers | The seam: CEF_EMBED_FRAMEWORK = NO |
The phase’s script builds the tool and runs cefswift embed, which reads
Xcode’s build settings from its environment, as Xcode’s own tools do; the
plugin runs cefswift bundle with the facts only it has (the product’s
build products, from the package graph). Both then use CefEmbedder for
the framework, startup library and helpers, DistributionPlan for
Info.plists and entitlements, the same signer, and cef doctor’s checks;
the phase reports those as error: and warning: lines, with
file:line: for a cefapp.json key, which Xcode puts in its Issue
navigator.
Settings: each track’s own place. Xcode has a build setting for most of
what cefapp.json holds (bundle identifier, version, signing, hardened
runtime, entitlements, usage descriptions); the phase reads those, and adds
CEF_… settings, each named after the cefapp.json key it matches, for
what only CefSwift has (locale packs, SwiftShader, capabilities, helper
entitlements, the CEF cache). The app’s entitlements stay Xcode’s: the
phase derives the helpers’ from them (get-task-allow, camera, microphone)
rather than asking for them twice, and stops the build, naming the
setting, when one the plan needs is missing. A project built both ways
points CEF_APP_CONFIG at its cefapp.json.
Conventions followed. Apple’s guidance for nested code: sign inside out,
each item before what contains it, never with --deep; nested helpers in
Contents/Frameworks (as Chrome’s are) with their own bundle identifiers
and LSUIElement; the app’s signature last, by Xcode in Xcode. Sparkle
ships its helpers (Autoupdate, its XPC services) generic and signed inside
its framework; Chromium’s cannot be generic, since their names, identifiers
and entitlements follow the app’s. Electron’s and
swift-bundler’s packagers assemble the bundle outside Xcode, as cef bundle does for SwiftPM. Helpers of an App Sandbox app would take
com.apple.security.inherit; the App Sandbox is not supported with
official CEF builds, so both tracks refuse it instead.
Previews. Xcode’s previews run the app’s code in a process of Xcode’s;
Chromium cannot start its helpers there. CefSwiftApp skips Chromium when
XCODE_RUNNING_FOR_PREVIEWS is 1, and CefWebView shows a placeholder
while the runtime has not started, so a view with a web view previews
without crashing. Checked by launching the Debug build of the Xcode example
with that variable set: it stays up with its window and no helper
processes. Xcode’s preview canvas itself was not exercised: it has no
command-line entry point.
Cost. The Xcode example (Scripts/check-xcode-example.sh: Debug and
Release builds, archive, export, three smoke launches, cef doctor) took
156 to 159 s in three runs from clean derived data on an M3, including Xcode’s own
build of CefSwift twice (build and archive); an incremental build of the
example takes 3.7 s, of which the phase is 2.0 s, most of it cef doctor’s
checks: it skips SwiftPM when the tool and helper are newer than their
sources, since SwiftPM’s own checks (three builds, each with its own linker flags,
and their --show-bin-path) took 15.7 s to find nothing to do.