Why does my iOS build fail with unresolved Realm SPM targets (s2geometry, RealmDatabase) on Xcode 16?
Last updated: June 26, 2026
Context
When building an iOS project on Codemagic using Xcode 16 (reported as Xcode 26.x in the build environment) with Realm added via Swift Package Manager, the archive step may fail with exit code 65 and a ComputeTargetDependencyGraph error listing unresolved targets such as:
s2geometry (RealmDatabase)Bid (RealmDatabase)RealmDatabase_RealmCoreResourcesRealm_RealmRealm_RealmSwift
This typically occurs when using -disableAutomaticPackageResolution and -clonedSourcePackagesDirPath in the build configuration.
Answer
There are two distinct issues that can cause this failure. Follow the steps below to resolve both.
Issue 1: Xcode cannot attach the SPM dependency graph during the archive step
When building directly from an .xcodeproj file in CI, Xcode may fail to fully load the Swift Package Manager dependency graph into the archive build session, causing the ComputeTargetDependencyGraph error. To fix this, ensure your workflow:
Builds using the
.xcworkspaceinstead of.xcodeproj.Uses the same
SourcePackagesdirectory for both the resolve and archive steps.
Here is a working codemagic.yaml example:
workflows:
ios-workflow:
name: iOS Build
environment:
xcode: 26.4
cache:
cache_paths:
- $CM_BUILD_DIR/SourcePackages
- ~/Library/Caches/org.swift.swiftpm
scripts:
- name: Resolve Swift Packages
script: |
mkdir -p "$CM_BUILD_DIR/SourcePackages"
xcodebuild \
-resolvePackageDependencies \
-workspace "YourApp.xcworkspace" \
-scheme "YourScheme" \
-clonedSourcePackagesDirPath "$CM_BUILD_DIR/SourcePackages"
- name: Build IPA
script: |
xcode-project build-ipa \
--workspace "YourApp.xcworkspace" \
--scheme "YourScheme" \
--archive-xcargs "-clonedSourcePackagesDirPath $CM_BUILD_DIR/SourcePackages -disableAutomaticPackageResolution"
artifacts:
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
Issue 2: Realm Core's s2geometry C++ compatibility error with Xcode 16
If the build still fails after switching to .xcworkspace, the root cause is a C++ compatibility issue in older versions of Realm Core. The s2geometry dependency bundled with older Realm versions attempts to specialize std::is_pod, which is explicitly forbidden by the newer C++ standard library used in Xcode 16's toolchain.
To fix this, upgrade your realm-swift Swift Package dependency to version 20.0.4 or higher, which contains the official fix. You can do this either through the Xcode UI or by updating the version constraint in your project.pbxproj file:
/* Begin XCRemoteSwiftPackageReference section */
XXXXXXXXXXXXXXXXXXXXXXXX /* realm-swift */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/realm/realm-swift.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 20.0.4;
};
};
For more details, refer to the official GitHub issues tracking this problem: