[2/4] ref(build)!: Migrate internal Apple build to spm4Kmp and rename the cinterop prefix to cocoa#557
Open
buenaflor wants to merge 9 commits into
Open
Conversation
4b08e33 to
b654bf8
Compare
a2f0ed5 to
4eb72e2
Compare
b654bf8 to
f5cef29
Compare
f5cef29 to
50ba5fb
Compare
Replace the Kotlin CocoaPods plugin with spm4Kmp (io.github.frankois944.spmForKmp
1.9.2) for the SDK's internal Apple build, with no public API/ABI change.
- Swap cocoapods{} for swiftPackageConfig{} on all Apple targets; consume the
remote Sentry Cocoa Swift package (product "Sentry", exportToKotlin) and restore
the cocoapods.Sentry.* import prefix via packageDependencyPrefix = "cocoapods"
- Port the KT-41709 -D...Unavailable macro workaround via swiftPackageConfig
extraOpts (forwarded to cinterop; compilerOpts does not reach the modular cinterop)
- Keep the private Sentry.Internal cinterop unchanged (self-contained headers)
- Declare Apple targets once (appleTargets) and reuse for swiftPackageConfig
- Keep the cocoapods plugin in root for the CocoaPods sample; gitignore spm4Kmp
generated dirs (exportedSentryCocoa/, src/swift/)
Verified: 11/12 Apple targets compile, appleTest runs (macos/iosSimulator),
CocoaPods sample xcodebuild SUCCEEDS (klib/ABI parity), apiCheck/detekt/spotless green.
watchosArm32 (armv7k) temporarily disabled: spm4Kmp 1.9.2 has no armv7k entry in
its AppleCompileTarget enum, so it cannot generate the exported Sentry cinterop for
that target (reported upstream). Must be re-enabled before release.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
spm4Kmp 1.9.3 adds armv7k (watchosArm32) support to its AppleCompileTarget enum, so it now generates the exported cocoapods.Sentry cinterop for that target. Bump Config.spmForKmpVersion to 1.9.3 and re-add watchosArm32() to the appleTargets list (the swiftPackageConfig forEach iterates that list). This restores the published target, so validateDistributions (expects watchosarm32, 20 artifacts) and scripts/build-apple.sh stay consistent. apiCheck is unaffected (android/jvm dumps only). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
50ba5fb to
e676b2c
Compare
517d333 to
f7815e2
Compare
…-migration # Conflicts: # sentry-kotlin-multiplatform/build.gradle.kts
spm4Kmp 1.9.3 compiles watchosSimulatorArm64 with --triple aarch64-apple-watchos-simulator (1.9.2 used arm64). SwiftPM does not treat aarch64 as arm64 when matching binary xcframework slices, so Sentry.framework never reaches the build products directory and the cinterop definition task fails with 'Module map file not found for module: Sentry'. Copy the watchOS simulator slice there manually until spm4Kmp maps this target back to arm64. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The event polling loop only fetches every 20s, so the previous 30s runTest timeout allowed a single fetch attempt before failing with UncompletedCoroutinesError. Align with the sibling message test, which already uses 60s. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Gradle resolves a Copy task's sources while computing task dependencies, before the SwiftPM compile task has fetched the xcframework, so listing the slice directory eagerly failed on clean CI machines with 'watchOS simulator slice not found'. Select the slice with an include pattern and strip its path segment instead, which defers all file access to execution time. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Migrates the SDK’s internal Apple build integration from the Kotlin CocoaPods plugin to spm4Kmp, aiming to keep published klib symbols/imports stable for existing consumers while removing the CocoaPods toolchain dependency from internal build machinery.
Changes:
- Replace the module’s
cocoapods {}configuration with per-targetswiftPackageConfig {}using the remotegetsentry/sentry-cocoaSwift package and a legacypackageDependencyPrefix = "cocoapods". - Introduce spm4Kmp plugin configuration (plugin id + version) and wire it into the root + module Gradle builds; add a watchOS simulator slice-copy workaround for spm4Kmp 1.9.3 behavior.
- Update ancillary files: changelog entry,
.gitignorefor spm4Kmp-generated outputs, and increase one E2E test timeout for consistency with the other E2E test.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryE2ETest.kt |
Increase E2E test timeout to match the other test’s timeout. |
sentry-kotlin-multiplatform/build.gradle.kts |
Swap CocoaPods plugin usage for spm4Kmp swiftPackageConfig, centralize Apple target declarations, and add a watchOS-simulator workaround task. |
CHANGELOG.md |
Document the internal Apple build migration to SwiftPM/spm4Kmp and note import-prefix stability. |
buildSrc/src/main/java/Config.kt |
Add spm4Kmp plugin id and version constant. |
build.gradle.kts |
Register the spm4Kmp plugin in the root build (apply false). |
.gitignore |
Ignore spm4Kmp generated directories (exportedSentryCocoa/, src/swift/). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Drop comments that narrate the code, PR-relative phrasing, and redundant justification; keep the constraints (klib prefix compatibility, KT-41709 extraOpts requirement, watchosSimulatorArm64 slice workaround). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The bundled Sentry Cocoa cinterop package was named after the delivery
mechanism, which became a misnomer once the Apple build moved from the
Kotlin CocoaPods plugin to SwiftPM. Rename the prefix to cocoa, naming
the platform SDK instead. This also disambiguates the bundled binding
from a consumer's own pod("Sentry") cinterop, which always generates
cocoapods.Sentry and previously collided with ours.
BREAKING CHANGE: Code importing cocoapods.Sentry.* directly in Apple
source sets must import cocoa.Sentry.* instead. Code using public SDK
types such as SentryPlatformOptions is unaffected.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
cocoa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the Kotlin CocoaPods plugin with spm4Kmp (
io.github.frankois944.spmForKmp1.9.3) for the SDK's internal Apple build, and renames the bundled Sentry Cocoa cinterop package prefix fromcocoapodstococoa.Why
The committed SDK podspec/CocoaPods tooling is internal build machinery (the SDK is distributed as Maven klibs, not via CocoaPods). Moving the internal Apple build to SwiftPM via spm4Kmp removes the CocoaPods toolchain dependency.
With the build no longer CocoaPods-based, the
cocoapods.Sentry.*package prefix becomes a misnomer named after a delivery mechanism we no longer use. Renaming it tococoa(naming the platform SDK instead) also disambiguates the bundled binding from a consumer's ownpod("Sentry")cinterop, which always generatescocoapods.Sentryand previously collided with ours.Breaking change
cocoapods.Sentry.*directly in Apple source sets must switch tococoa.Sentry.*(mechanical find-and-replace). Code using public SDK types such asSentryPlatformOptionsis unaffected — the typealiases are transparent.UbiqueInnovation/sentry-defaults-kmp); the other repos importingcocoapods.Sentrydeclare their ownpod("Sentry")cinterop, which keeps its name and is unaffected.What
cocoapods {}block for spm4KmpswiftPackageConfig {}across the Apple targets; consume the remote Sentry Cocoa Swift package (getsentry/sentry-cocoa, productSentry,exportToKotlin = true).packageDependencyPrefix = "cocoa"and rename allcocoapods.Sentryimports/references in the SDK sources tococoa.Sentry.-D...Unavailablemacro workaround viaswiftPackageConfig { extraOpts = ... }(forwarded directly to cinterop;compilerOptsonly sets the generated def's clang flags and doesn't reach the modular cinterop).Sentry.Internalcinterop unchanged — its headers are self-contained (Foundation-only redeclarations), so it's independent of how the Sentry framework is delivered.appleTargets) and reuse them forswiftPackageConfig.cocoapodsplugin in root for the CocoaPods sample; gitignore spm4Kmp-generated dirs (exportedSentryCocoa/,src/swift/).Part 2/2 of the spm4Kmp migration stack.
Made with Cursor