Build flutter as macos-framework and import into swift:Failed to build module 'sentry_flutter'
Platform
Dart, Flutter Desktop macOS
Obfuscation
Disabled
Debug Info
Disabled
Doctor
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.5 24F74 darwin-arm64, locale zh-Hans-CN) [1,271ms] • Flutter version 3.29.2 on channel stable at /Users/huangfeiyang/flutterSDK/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision c236373904 (3 个月前), 2025-03-13 16:17:06 -0400 • Engine revision 18b71d647a • Dart version 3.7.2 • DevTools version 2.42.3
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.4s]
• Android SDK at /Users/huangfeiyang/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: flutter config --jdk-dir="path/to/jdk".
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [2.1s] • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16E140 • CocoaPods version 1.16.2
[✓] Chrome - develop for the web [33ms] • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.3) [33ms] • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
[✓] IntelliJ IDEA Community Edition (version 2023.3.6) [31ms] • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.100.2) [9ms] • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.110.0
[!] Proxy Configuration [8ms] • HTTP_PROXY is set ! NO_PROXY is not set
[✓] Connected device (3 available) [6.2s] • macOS (desktop) • macos • darwin-arm64 • macOS 15.5 24F74 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.5 24F74 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 136.0.7103.114
[✓] Network resources [974ms] • All expected network resources are available.
! Doctor found issues in 1 category.
Version
8.14.2
Steps to Reproduce
- add sentry_flutter in flutter project:
// pubspec.yaml
dependencies:
sentry_flutter: ^8.14.2
- run command:"flutter build macos-framework",it will generate some *.xcframework at
{flutterProjectDir}/build/macos/framework/Debug/
Due to our business reasons, we did not build the Mac app directly through the Flutter project, but built the framework
- create a new macos app xcode project, and add these *.xcframework into xcode project
- build error
I found that "SentrySdkInfo.h" does not exist
Expected Result
build success
Actual Result
build error
(But if I run the flutter project as macos app directly, it's ok. If you use framework, you will get an error)
Are you willing to submit a PR?
None
That seems odd, @philprime do you maybe know what's wrong?
I can't tell whether this is a Flutter tooling issue or not
Yes, this is odd. Which version of Sentry Cocoa is used here? Where does the framework come from?
-
Which version of Sentry Cocoa is used here? Instead of using sentry cocoa directly, I use the sentry flutter plugin.
-
Where does the framework come from? Generate the framework through
flutter build macos-frameworkcommand
Since he mentioned using 8.14.2 it would be sentry-cocoa 8.46.0
@Messiahfy could you check if older versions of the Sentry Flutter SDK work?
I'm in the exact same situation as @Messiahfy.
I tried version 8.11.0. According to the changelog (https://pub.dev/packages/sentry_flutter/changelog), the Cocoa SDK version for this release is 8.41.0. However, the issue still persists.
I suspect the main problem is that when using the flutter build macos-framework command, the built framework is missing necessary header files. But I'm not quite clear on how this build process works. My reasoning is based on the following observations:
- When I manually replace the precompiled Sentry.xcframework, the error can be avoided. (I downloaded it from here: https://github.com/getsentry/sentry-cocoa/releases?page=2)
- Alternatively, when I add the two missing header files to the framework produced by Flutter, the error can also be avoided. (Specifically, these are: SentryInternalSerializable.h and SentrySdkInfo.h)
- When I compared the header files in the precompiled framework with those in the framework built using flutter build macos-framework, I found that there are significantly fewer headers in the latter. Both of the above-mentioned header files are located in the PrivateHeaders directory.
Therefore, I suspect that during the flutter build macos-framework process, the necessary header files are not being exposed.
Thanks for the details, we will have a look
hey sorry we don't have an update yet here.
I assume this is still an issue?
Yes, this issue still exists
Gotcha, I'll investigate this whether it's a Flutter tooling issue or a Sentry issue
Closing this as we do not support this use case currently - I'd suggest to use the current workaround mentioned in this comment.
Let us know if you have any more questions