Sentry requires `'APPLICATION_EXTENSION_API_ONLY=YES`
OS:
- [ ] Windows
- [x] MacOS
- [ ] Linux
Platform:
- [x] iOS
- [ ] Android
SDK:
- [x]
@sentry/react-native(>= 1.0.0) - [ ]
react-native-sentry(<= 0.43.2)
SDK version: 5.24.1
react-native version: 0.74.2
Are you using Expo?
- [ ] Yes
- [x] No
Are you using sentry.io or on-premise?
- [x] sentry.io (SaaS)
- [ ] on-premise
I have the following issue:
Build fails with:
SentryProfilerState.mm
Property 'date' cannot be found in forward class object 'SentryCurrentDateProvider'
This is also on Xcode 16.0 Beta, so I'm not sure if it's related or not to #3883
Actual result:
Build fails
Expected result:
Build does not fail.
Hi @Mitch528, thank you for the report, we'll check it.
Are your pods up to date, are you using the 'Sentry/HybridSDK', '8.29.1'? Just want to confirm this since workaround for https://github.com/getsentry/sentry-react-native/issues/3883 was changing manually the Sentry pod version.
Hi @krystofwoldrich yeah, pods are up-to-date. I've tried regenerating my Podfile.lock without luck as well.
I didn't explicitly include the pod in my Podfile but it does seem like it's included in the lockfile:
- RNSentry (5.24.1):
- hermes-engine
- React-Core
- React-hermes
- Sentry/HybridSDK (= 8.29.1)
...
- Sentry/HybridSDK (8.29.1)
@Mitch528 Thanks for the details.
I'm seeing this same issue issue Xcode 16 beta 3
Hi @zdtclement, thank you for the message, what version of the SDK are you using?
Are you running Xcode 16 on Sonoma or beta of Sequoia?
Hello everyone we have tested the Xcode 16 Beta 4 and RN 73 and could not reproduce the issue.
If the build is failing for you, could you share a minimal reproducible sample which we can debug?
Hello everyone we have tested the Xcode 16 Beta 4 and RN 73 and could not reproduce the issue.
If the build is failing for you, could you share a minimal reproducible sample which we can debug?
@krystofwoldrich
I found out why the build was failing for me. I had this in my Podfile in order to fix a OneSignal related issue.
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
Changing it to the following resolves the issue for me:
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if target.name != "Sentry"
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
@Mitch528 Thank you for the message!
We should add information about APPLICATION_EXTENSION_API_ONLY to the docs (RN manual setup on iOS, troubleshooting).
added to troubleshooting docs in https://github.com/getsentry/sentry-docs/pull/10087
After adding the above changes in my podFile. https://github.com/getsentry/sentry-react-native/issues/3908#issuecomment-2265703635
post_install do |installer|
config = use_native_modules!
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if target.name != "Sentry"
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
end
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
)
end
I keep on getting this error. Any one know how to fix this.
unexpected service error: The Xcode build system has crashed. Build again to continue.
@adityakmr7 I'm not sure this is related - did you cleaning build caches, derived data, etc.? Which version of macOS/Xcode are you using?
@adityakmr7 Have you used APPLICATION_EXTENSION_API_ONLY before? We recommend to explicitly set it to YES for Sentry at the end of the post install scripts.
More at: https://docs.sentry.io/platforms/react-native/troubleshooting/#unknown-receiver-somereceiver-use-of-undeclared-identifier-someidentifier
Can we remove the need of APPLICATION_EXTENSION_API_ONLY=YES from sentry-cocoa?
For reference https://developer.apple.com/documentation/xcode/build-settings-reference#Require-Only-App-Extension-Safe-API
target.build_configurations.each do |config|
if target.name != "Sentry"
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
This worked cool ! thanks
ref : https://github.com/getsentry/sentry-react-native/issues/3908#issuecomment-2265703635
Thank you for the message @sahad00.
Could you share a bit more details why you set ['APPLICATION_EXTENSION_API_ONLY'] = 'NO' for all other targets?
It looks like they are some libraries like the following, which change this values for all targets.
I don't mean to point to any particular library just adding here samples I've found to help us understand why our Sentry lib is encountering this issue.
- https://github.com/gitn00b1337/expo-widgets/blob/82042df354823db7dac6bbf73c890d63ae2e00f1/plugin/src/ios/withPodfile.ts#L56
- https://github.com/bndkt/react-native-widget-extension/blob/ee9d8974831025fa888868c38b4244529d58e428/plugin/src/withPodfile.ts#L38
- https://github.com/relateddigital/react-native-related-digital/blob/66dbac8a989f355f2caa9ca4b630024a93df27fc/README.md?plain=1#L327
- https://forums.swift.org/t/set-application-extension-api-only-on-a-spm-package/39333/57
- https://stackoverflow.com/questions/67494911/unable-to-compile-react-native-share-extension-ios-12-5
By setting APPLICATION_EXTENSION_API_ONLY to YES, we ensure our library is extension-safe, meaning it doesn’t use any APIs prohibited in app extensions. This is typically expected of libraries to maintain broad compatibility.
Setting APPLICATION_EXTENSION_API_ONLY = YES in our library’s pod_target_xcconfig is considered a good practice to ensure that any code within your library will work in both app and extension contexts without imposing restrictions on the app itself.
My understanding is that the need for the troubleshooting workaround on Cocoa and React Native is due to a CocoaPods issue (other related issues)propagating the change to the host application.
There are libraries that do not adopt this restriction. For example Firebase does not use the APPLICATION_EXTENSION_API_ONLY apart from SwiftLint (Crashlytics does not set the flag) . What they do is marking methods that are unavailable in extensions with NS_EXTENSION_UNAVAILABLE_IOS, NS_EXTENSION_UNAVAILABLE or @available(*ApplicationExtension, unavailable) in Swift.
Can we remove the need of
APPLICATION_EXTENSION_API_ONLY=YESfromsentry-cocoa?
I think we should keep the option to ensure compatibility with extensions on Cocoa and React Native. If we decide to drop the option we may use lint or static analysis tools to enforce the api restrictions.
Yes, make sense to keep it to stay compatible with app extensions.
But I think if possible we should be able to compile also with the flag set to NO.
What confuses me is that the Cocoa SDK only compiles with the flag set to YES.
If this flag only limits the API set I would expect the code also compile without it.
After Installing Xcode16 and with Mac chip M1 Pro and react native versions "0.72.4" and "@sentry/react-native": "^6.1.0", I'm getting this error building.
Command SwiftVerifyEmittedModuleInterface failed with a nonzero exit code
Thank you for reporting @iamthemuhammadirfan 🙇
Does the issue still occur after clearing all build caches including derived data?
Is the issue related with the APPLICATION_EXTENSION_API_ONLY build setting? If not, please consider opening a separate issue with more details and we will be glad to continue the investigation there 🙇
I've opened a PR with a possible work around for this issue https://github.com/getsentry/sentry-cocoa/pull/4599
After is merged this Issue will be closed.
https://github.com/getsentry/sentry-cocoa/pull/4603
https://github.com/getsentry/sentry-cocoa/pull/4603 adds a clear error message about the missconfigured flag.
Sentry Cocoa needs the flag to work/build correctly.
Closing since https://github.com/getsentry/sentry-cocoa/pull/4603 is merged 🎉