Skip to content

fix(cli): Compile out profiling in the Apple wizard snippet on watchOS, tvOS, and visionOS - #2791

Merged
antonis merged 2 commits into
mainfrom
fix/apple-wizard-profiling-platform-check
Dec 2, 2026
Merged

antonis merged 2 commits into
mainfrom
fix/apple-wizard-profiling-platform-check

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Found while testing sentry wizard ios on a fresh tvOS app. The SentrySDK.start snippet the wizard writes doesn't build:

error: value of type 'Options' has no member 'configureProfiling'

In sentry-cocoa 9.x, Options.swift defines configureProfiling only under #if !(os(watchOS) || os(tvOS) || os(visionOS)). So tvOS, watchOS, and visionOS apps fail, and so does a multiplatform target that includes any of them.

This wraps the profiling block (with its comment line) in each template in a compile-time check that matches the SDK's guard, instead of detecting the platform from the Xcode project. That way a multiplatform target keeps profiling on iOS and macOS:

  • Swift: #if !(os(watchOS) || os(tvOS) || os(visionOS)) … #endif
  • Objective-C: #if !(TARGET_OS_WATCH || TARGET_OS_TV || TARGET_OS_VISION) … #endif

The directives use the same indentation as the statements around them, so the injected snippet stays aligned. The existing-init detection in code-tools.ts (SentrySDK.start / [SentrySDK start) is unaffected.

via Antonis Lilis.

--

View Session [Sentry]

…S, tvOS, and visionOS

sentry-cocoa defines Options.configureProfiling only outside watchOS, tvOS,
and visionOS, so the SentrySDK.start snippet that sentry wizard ios writes
failed to compile on those platforms. Wrap the profiling block in the same
compile-time platform check the SDK uses, which also covers multiplatform
targets.

Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Dec 2, 2026 2:11pm UTC
sentry-local Ready Ready Preview Dec 2, 2026 2:11pm UTC

Request Review

@antonis

antonis commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Tested end to end with the packed npm build of a local branch: main (9116f43) plus #2790, #2791, #2792 and #2789, merged in that order (216f4fb2f). Xcode 27.2, sentry-cocoa 9.36.0. The projects are fresh Xcode 16+ "App" template projects in their pre-wizard state, against sentry-sdks/sentry-cocoa, with default answers (Logs = Yes) unless noted. Release builds.

Project Release build Profiling in the app's object file (nm) Event
tvOS SwiftUI (Apple TV simulator) ✅ 0 configureProfiling references: compiled out ✅ WizTVApp.swift:35, symbolicated
iOS SwiftUI ✅ 1 reference: compiled in ✅
macOS SwiftUI ✅ 1 reference: compiled in, not greyed out ✅
iOS UIKit (Objective-C) ✅ SentryProfileLifecycleTrace inside #if !(TARGET_OS_WATCH || TARGET_OS_TV || TARGET_OS_VISION) ✅

Before this PR, tvOS failed with value of type 'Options' has no member 'configureProfiling'.

Merge note: this PR conflicts with #2790 in packages/cli/test/lib/wizard/apple/templates.test.ts, where both add a new describe block in the same spot. Keeping both blocks resolves it, and the file passes (20 tests). The source and the expected snippets merge cleanly, with SentryProfileLifecycleTrace inside the #if.

…iling-platform-check

Resolve the templates.test.ts conflict with #2790 by keeping both new
describe blocks: the profiling platform check and the 9.x API check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@antonis
antonis enabled auto-merge December 2, 2026 14:18
@github-actions github-actions Bot added the risk: low PR risk score: low label Dec 2, 2026
@antonis
antonis added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 6790d72 Dec 2, 2026
32 checks passed
@antonis
antonis deleted the fix/apple-wizard-profiling-platform-check branch December 2, 2026 14:28

This branch was successfully deployed

2 active deployments
Preview – sentry-local — 817a4388 Deployed Dec 2, 2026 by vercel[bot]
Preview – cli — 817a4388 Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant