feat: Add iOS-ObjectiveCpp-NoModules sample reproducing #4543#7433
feat: Add iOS-ObjectiveCpp-NoModules sample reproducing #4543#7433
Conversation
…mple apps Add a new "SentrySPM" SPM product that allows consumers to compile Sentry directly from source, as an alternative to the pre-built xcframework binary targets. The product uses a thin Swift wrapper module (Sources/SentrySPM/) that re-exports both the ObjC and Swift modules via @_exported import, so consumers only need `import SentrySPM`. Architecture: - SentryHeaders: public ObjC headers - _SentryPrivate: internal ObjC headers - SentrySwift: all Swift source - SentryObjCInternal: all ObjC/C source (renamed from SentryObjc) - SentrySPM: thin re-export wrapper Also adds SwiftUI sample apps for all supported platforms (iOS, watchOS, tvOS, macOS, visionOS) that use the SentrySPM product with XcodeGen, along with Makefile build targets and CI workflow integration.
- Override IOS_SIMULATOR_OS=latest and IOS_DEVICE_NAME for the build-sample-spm CI job since macos-26 runners have Xcode 26.x simulators, not 18.4/iPhone 16 Pro - Update prepare-package.sh to keep SentrySPM product in the products array when --remove-binary-targets is used, so the existing Samples/SPM project can resolve its SentrySPM dependency during workspace builds
Add a sample project that reproduces the ObjC++ without-modules issue where SentrySDK is undeclared when using #import <Sentry/Sentry.h> with CLANG_ENABLE_MODULES=NO. Since SDK 8.54, SentrySDK is a Swift class and only visible via Sentry-Swift.h or @import Sentry, both of which are unusable from ObjC++ without modules. This sample serves as a test case for the pure ObjC SDK wrapper proposed in #6342. It is intentionally not in CI since it does not build with the current SDK. Refs #4543 Refs #6342
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7433 +/- ##
=============================================
- Coverage 85.283% 85.258% -0.026%
=============================================
Files 479 479
Lines 28608 28579 -29
Branches 12419 12426 +7
=============================================
- Hits 24398 24366 -32
- Misses 4164 4167 +3
Partials 46 46 see 10 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
The build-sample-iOS-ObjectiveCpp-NoModules target was missing the -destination flag, which would cause xcodebuild to resolve a destination automatically. This is unreliable on CI and may target the wrong platform. Refs #4543
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 18c94be | 1218.26 ms | 1258.80 ms | 40.54 ms |
| 70fb69e | 1230.45 ms | 1257.00 ms | 26.55 ms |
| dbf22c2 | 1214.19 ms | 1241.67 ms | 27.48 ms |
| d540ef3 | 1214.37 ms | 1241.06 ms | 26.69 ms |
| 17b7e88 | 1223.04 ms | 1253.48 ms | 30.43 ms |
| 29f846e | 1210.51 ms | 1238.66 ms | 28.15 ms |
| 1357911 | 1224.57 ms | 1261.00 ms | 36.43 ms |
| bbee1ba | 1197.79 ms | 1215.42 ms | 17.63 ms |
| d8db577 | 1206.83 ms | 1244.39 ms | 37.56 ms |
| e8cc4e7 | 1204.21 ms | 1239.22 ms | 35.01 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 18c94be | 24.14 KiB | 1.10 MiB | 1.08 MiB |
| 70fb69e | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| dbf22c2 | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| d540ef3 | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| 17b7e88 | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| 29f846e | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| 1357911 | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| bbee1ba | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| d8db577 | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| e8cc4e7 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
Previous results on branch: philprime/objective-cpp-no-modules-sample
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 67fbc93 | 1216.34 ms | 1242.29 ms | 25.95 ms |
| e835d88 | 1213.98 ms | 1241.22 ms | 27.24 ms |
| fe3a236 | 1209.71 ms | 1234.55 ms | 24.84 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 67fbc93 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| e835d88 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| fe3a236 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
There was a problem hiding this comment.
Pull request overview
Adds a new iOS sample app intended to reliably reproduce the Objective-C++ “no modules” import breakage (ObjC++ .mm + CLANG_ENABLE_MODULES=NO + #import <Sentry/Sentry.h>) described in #4543, to serve as a future verification target for the ObjC wrapper proposal in #6342.
Changes:
- Add new XcodeGen-based sample project under
Samples/iOS-ObjectiveCpp-NoModules/that intentionally fails to compile with the current SDK. - Wire the sample into the repo’s workspace and XcodeGen generation flow (
make xcode-ci), and add a dedicated build target in the Makefile. - Ignore the generated
.xcodeprojfor the new sample.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Sentry.xcworkspace/contents.xcworkspacedata | Adds the new sample’s generated Xcode project reference to the workspace. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/main.mm | App entry point for the ObjC++ sample. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules.entitlements | Entitlements placeholder for the sample app. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/ViewController.mm | ObjC++ view controller that triggers the intended SentrySDK undeclared error. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/ViewController.h | View controller header for the sample. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/Info.plist | App Info.plist for the new sample target. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/Base.lproj/Main.storyboard | Minimal UI (label + button) for exercising the code path. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/Base.lproj/LaunchScreen.storyboard | Launch screen storyboard for the sample. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/AppDelegate.mm | ObjC++ AppDelegate that demonstrates the failing SentrySDK startWithConfigureOptions: usage. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules/AppDelegate.h | AppDelegate header for the sample. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules.yml | XcodeGen spec defining the sample target and dependencies. |
| Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules.xcconfig | Build settings for the sample, including CLANG_ENABLE_MODULES = NO. |
| Samples/iOS-ObjectiveCpp-NoModules/README.md | Documents the repro scenario and how to generate/build the sample. |
| Makefile | Adds a new build-sample-iOS-ObjectiveCpp-NoModules target and includes the sample in xcode-ci generation. |
| .gitignore | Ignores the generated Samples/iOS-ObjectiveCpp-NoModules/*.xcodeproj. |
Files not reviewed (1)
- Sentry.xcworkspace/contents.xcworkspacedata: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update the "This Sample" section to accurately describe that the sample uses only #import <Sentry/Sentry.h> and does not import Sentry-Swift.h. Clarify that attempting to include Sentry-Swift.h fails with forward declaration errors when used from .mm files without modules.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Add a sample project that reproduces the ObjC++ without-modules issue where SentrySDK is undeclared when using #import <Sentry/Sentry.h> with CLANG_ENABLE_MODULES=NO. Since SDK 8.54, SentrySDK is a Swift class and only visible via Sentry-Swift.h or @import Sentry, both of which are unusable from ObjC++ without modules. This sample serves as a test case for the pure ObjC SDK wrapper proposed in #6342. It is intentionally not in CI since it does not build with the current SDK. Add build-sample-iOS-ObjectiveCpp-NoModules target to build the ObjC++ without-modules reproducer. This target is expected to fail until the pure ObjC SDK wrapper (#6342) is implemented. The build-sample-iOS-ObjectiveCpp-NoModules target was missing the -destination flag, which would cause xcodebuild to resolve a destination automatically. This is unreliable on CI and may target the wrong platform.
This PR needs to be merged after #7430
Summary
Samples/iOS-ObjectiveCpp-NoModules) that reproduces the ObjC++ without-modules issue from Replay options not visible from Objective-C without @import #4543.mmfiles withCLANG_ENABLE_MODULES=NOand#import <Sentry/Sentry.h>, which fails witherror: use of undeclared identifier 'SentrySDK'since SDK 8.54 movedSentrySDKto SwiftBackground
Since SDK 8.54,
SentrySDKis a Swift class only visible viaSentry-Swift.hor@import Sentry. Projects that cannot enable Clang modules (React Native ≤0.76, Haxe, custom build systems) can only use#import <Sentry/Sentry.h>, which no longer includesSentrySDK. The sample is intentionally not in the CI build matrix since it does not build with the current SDK.Test plan
xcodegen --spec Samples/iOS-ObjectiveCpp-NoModules/iOS-ObjectiveCpp-NoModules.ymlgenerates the projectiOS-ObjectiveCpp-NoModulesfails witherror: use of undeclared identifier 'SentrySDK'— confirming the reproducer works#skip-changelog
Refs #4543
Refs #6342