Skip to content

[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
feat/spm4kmp-phase0-toolchainfrom
feat/spm4kmp-phase1-migration
Open

[2/4] ref(build)!: Migrate internal Apple build to spm4Kmp and rename the cinterop prefix to cocoa#557
buenaflor wants to merge 9 commits into
feat/spm4kmp-phase0-toolchainfrom
feat/spm4kmp-phase1-migration

Conversation

@buenaflor

@buenaflor buenaflor commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Replaces the Kotlin CocoaPods plugin with spm4Kmp (io.github.frankois944.spmForKmp 1.9.3) for the SDK's internal Apple build, and renames the bundled Sentry Cocoa cinterop package prefix from cocoapods to cocoa.

Stacked on #556. Review/merge that first; this PR's base will be retargeted to main once it lands.

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 to cocoa (naming the platform SDK instead) 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

  • Consumers importing cocoapods.Sentry.* directly in Apple source sets must switch to cocoa.Sentry.* (mechanical find-and-replace). Code using public SDK types such as SentryPlatformOptions is unaffected — the typealiases are transparent.
  • A public GitHub code search found one affected consumer (UbiqueInnovation/sentry-defaults-kmp); the other repos importing cocoapods.Sentry declare their own pod("Sentry") cinterop, which keeps its name and is unaffected.

What

  • Swap the cocoapods {} block for spm4Kmp swiftPackageConfig {} across the Apple targets; consume the remote Sentry Cocoa Swift package (getsentry/sentry-cocoa, product Sentry, exportToKotlin = true).
  • Set packageDependencyPrefix = "cocoa" and rename all cocoapods.Sentry imports/references in the SDK sources to cocoa.Sentry.
  • Port the KT-41709 -D...Unavailable macro workaround via swiftPackageConfig { extraOpts = ... } (forwarded directly to cinterop; compilerOpts only sets the generated def's clang flags and doesn't reach the modular cinterop).
  • Keep the private Sentry.Internal cinterop unchanged — its headers are self-contained (Foundation-only redeclarations), so it's independent of how the Sentry framework is delivered.
  • Declare the Apple targets once (appleTargets) and reuse them for swiftPackageConfig.
  • Keep the cocoapods plugin in root for the CocoaPods sample; gitignore spm4Kmp-generated dirs (exportedSentryCocoa/, src/swift/).
  • Changelog entry under Breaking Changes with the one-line migration.

Part 2/2 of the spm4Kmp migration stack.

Made with Cursor

@buenaflor buenaflor changed the title feat(apple): Migrate internal Apple build from CocoaPods to spm4Kmp [PR 2] refactor: migrate from cocoapods plugin to spm4Kmp Jun 9, 2026
@buenaflor buenaflor changed the title [PR 2] refactor: migrate from cocoapods plugin to spm4Kmp [2/4] ref(build): Migrate internal Apple build from the CocoaPods plugin to spm4Kmp Jun 9, 2026
@buenaflor buenaflor force-pushed the feat/spm4kmp-phase1-migration branch from 4b08e33 to b654bf8 Compare June 10, 2026 10:59
@buenaflor buenaflor force-pushed the feat/spm4kmp-phase0-toolchain branch from a2f0ed5 to 4eb72e2 Compare June 10, 2026 11:14
@buenaflor buenaflor force-pushed the feat/spm4kmp-phase1-migration branch from b654bf8 to f5cef29 Compare June 10, 2026 11:14
@buenaflor buenaflor closed this Jun 10, 2026
@buenaflor buenaflor force-pushed the feat/spm4kmp-phase1-migration branch from f5cef29 to 50ba5fb Compare June 10, 2026 11:18
@buenaflor buenaflor reopened this Jun 10, 2026
buenaflor and others added 2 commits June 10, 2026 13:27
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>
…-migration

# Conflicts:
#	sentry-kotlin-multiplatform/build.gradle.kts
buenaflor and others added 4 commits June 10, 2026 15:03
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>
@buenaflor buenaflor marked this pull request as ready for review June 10, 2026 14:36
@buenaflor buenaflor requested a review from romtsn as a code owner June 10, 2026 14:36
Copilot AI review requested due to automatic review settings June 10, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-target swiftPackageConfig {} using the remote getsentry/sentry-cocoa Swift package and a legacy packageDependencyPrefix = "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, .gitignore for 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.

Comment thread sentry-kotlin-multiplatform/build.gradle.kts
Comment thread buildSrc/src/main/java/Config.kt
buenaflor and others added 2 commits June 11, 2026 14:16
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>
@buenaflor buenaflor changed the title [2/4] ref(build): Migrate internal Apple build from the CocoaPods plugin to spm4Kmp [2/4] ref(build)!: Migrate internal Apple build to spm4Kmp and rename the cinterop prefix to cocoa Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants