Skip to content

fix(cli): Warn when the iOS wizard can't link the Sentry package - #2792

Merged
antonis merged 2 commits into
mainfrom
fix/ios-wizard-unlinked-sentry-package
Dec 2, 2026
Merged

antonis merged 2 commits into
mainfrom
fix/ios-wizard-unlinked-sentry-package

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

This comes from testing sentry wizard ios on an XcodeGen project. XcodeGen adds a Frameworks build phase only to targets that link something, so the wizard couldn't link sentry-cocoa. It still wrote import Sentry and ended with "Sentry was successfully added to your project!", and the build then failed with:

Unable to resolve module dependency: 'Sentry'

ensureSwiftPackageProductLinked already returned { changed: false, linked: false } in this case and logged it only at debug level. updateXcodeProject dropped linked, so nothing upstream knew.

  • updateXcodeProject now returns { linked }, and configureXcodeProject passes it on to apple-wizard.ts.
  • When the package isn't linked, the wizard warns and explains how to add it by hand. With a project.yml next to the .xcodeproj, it shows the packages: and target dependencies: entries to add, since XcodeGen regenerates the .xcodeproj. Otherwise it points to File > Add Package Dependencies… in Xcode, with https://github.com/getsentry/sentry-cocoa, version 9.x, product Sentry.
  • It sets a spm-package-linked tag on every run, true or false.
  • It still injects the code snippet, so the app works once the package is added. It then ends with a setup-incomplete message instead of the success message.
  • The repository URL and version in these instructions come from sentry-swift-package.ts, so they can't drift from what the wizard links.
  • injectCodeSnippet's fallback warning no longer says the Sentry dependency was added, since that may not be true.

The Apple Snapshots flow (configure-snapshotpreviews-xcode-project.ts) didn't have this bug. apple-snapshots-wizard.ts already checks linked: it aborts when SnapshottingTests can't be linked to the test target, and warns when SnapshotPreferences can't be linked to a preview target. So it's unchanged.

The new xcodegen-no-frameworks-build-phase fixture is spm-swiftui-single-target with the Frameworks build phase removed, plus a project.yml.

via Antonis Lilis.

--

View Session [Sentry]

`ensureSwiftPackageProductLinked` returns `linked: false` when the target
has no Frameworks build phase, as in XcodeGen projects, but
`updateXcodeProject` dropped that. The wizard still injected
`import Sentry` and reported success, and the app then failed to build.

`updateXcodeProject` and `configureXcodeProject` now return whether the
package product is linked. When it isn't, the iOS wizard warns with
manual steps (Xcode, or `project.yml` for XcodeGen), sets the
`spm-package-linked` tag, still injects the snippet, and ends with a
setup-incomplete message instead of the success message.

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 1:28pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Dec 2, 2026 1:28pm UTC

Request Review

…t fails

Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
@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.

On an XcodeGen iOS project (no Frameworks build phase):

  • ✅ The wizard warns "The wizard couldn't add the Sentry package to the WizGen target." and prints the project.yml steps: packages: (Sentry, majorVersion: 9.0.0) and the target's dependencies:, then "run xcodegen again".
  • ✅ It still writes the snippet.
  • ✅ It ends with "Sentry setup is incomplete: your project won't build until you add the Sentry package…", with no success message.
  • ✅ After adding that YAML and running xcodegen generate, the project builds with Sentry linked, and the test event arrives.

One gap: the regeneration also drops the wizard's other .xcodeproj changes:

  • the "Upload Debug Symbols to Sentry" build phase;
  • the target's ENABLE_USER_SCRIPT_SANDBOXING = NO.

dwarf-with-dsym survives only because it's XcodeGen's own Release default. So no dSYM is uploaded, and the event arrives unsymbolicated (native_missing_dsym). The warning could also give the build phase as postBuildScripts: and the setting under settings:, so that one regeneration covers everything. This can be a follow-up.

The four Xcode-template projects (iOS SwiftUI, iOS Objective-C, tvOS, macOS) link the package as before and end with the success message.

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. This fixes a bug @sentry/wizard has too: its ensureSwiftPackageProductLinked returns linked: false for a target without a Frameworks build phase, and apple-wizard.ts ignores it and ends with "Sentry was successfully added". Passing linked up and ending with "setup is incomplete" is the right fix. Showing the project.yml entries rather than creating a Frameworks phase is right for XcodeGen, since the next xcodegen generate would remove a phase added to the .xcodeproj. Nothing changes for projects where the package links, and the Apple Snapshots flow already handles linked: false.

Not covered here, for later:

  • The XcodeGen check only looks for project.yml next to the .xcodeproj. A spec elsewhere, or a Tuist project, gets the Xcode instructions instead.
  • Regenerating with XcodeGen also removes the upload phase and the dSYM settings the wizard adds. This PR only warns about the package.

I'll confirm the warning and the YAML on a real XcodeGen project in the next iOS test run.

@antonis
antonis added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 588ec4a Dec 2, 2026
33 checks passed
@antonis
antonis deleted the fix/ios-wizard-unlinked-sentry-package branch December 2, 2026 14:01

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — d9b94320 Deployed Dec 2, 2026 by vercel[bot]
Preview – sentry-local — d9b94320 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: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant