Repository navigation
fix(cli): Warn when the iOS wizard can't link the Sentry package - #2792
Conversation
`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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
…t fails Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
|
Tested end to end with the packed npm build of a local branch: On an XcodeGen iOS project (no Frameworks build phase):
One gap: the regeneration also drops the wizard's other
The four Xcode-template projects (iOS SwiftUI, iOS Objective-C, tvOS, macOS) link the package as before and end with the success message. |
antonis
left a comment
There was a problem hiding this comment.
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.ymlnext 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.
This comes from testing
sentry wizard ioson an XcodeGen project. XcodeGen adds a Frameworks build phase only to targets that link something, so the wizard couldn't linksentry-cocoa. It still wroteimport Sentryand ended with "Sentry was successfully added to your project!", and the build then failed with:ensureSwiftPackageProductLinkedalready returned{ changed: false, linked: false }in this case and logged it only at debug level.updateXcodeProjectdroppedlinked, so nothing upstream knew.updateXcodeProjectnow returns{ linked }, andconfigureXcodeProjectpasses it on toapple-wizard.ts.project.ymlnext to the.xcodeproj, it shows thepackages:and targetdependencies:entries to add, since XcodeGen regenerates the.xcodeproj. Otherwise it points to File > Add Package Dependencies… in Xcode, withhttps://github.com/getsentry/sentry-cocoa, version 9.x, productSentry.spm-package-linkedtag on every run, true or false.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.tsalready checkslinked: 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-phasefixture isspm-swiftui-single-targetwith the Frameworks build phase removed, plus aproject.yml.via Antonis Lilis.
--
View Session [Sentry]