Repository navigation
[Add2App] option B from iOS guide can't be used if app and module have a shared pod dependency #130220
Copy link
Copy link
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: existing-appsIntegration with existing apps via the add-to-app flowIntegration with existing apps via the add-to-app flowd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/found in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12Found to occur in 3.12has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
Option B from add to app iOS guide can't be used if app and module have a shared pod dependency.
I mentioned this issue in my feature request #114692 and it has a lot of details, but initially I didn't want to create a separate issue because I thought we had a simple workaround.
Steps to reproduce
- Integrate Flutter module into existing iOS app using Option B (or Option C) from the add2app iOS guide.
(We can use prebuilt_module from the Flutter samples as an example) - Make sure iOS app has a Cocoapods support.
(prebuilt_module: runpod initfrom theios_using_prebuilt_moduledirectory) - Add Cocoapods dependencies to the app.
(to theios_using_prebuilt_module).
# Pods for IOSUsingPrebuiltModule
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '8.8.0'
pod 'DatadogSDK' => '1.19.0'
pod 'DatadogSDKCrashReporting' => '1.19.0'- Add Flutter dependencies (plugins) to the module, these plugins should have dependencies we add in the step 2 as a direct/transitive dependencies.
(add to thepubspec.yamlfrom theflutter_moduledirectory)
datadog_flutter_plugin: 1.5.1
sentry_flutter: 7.8.0- Build iOS frameworks from the Flutter module.
(runflutter build ios-framework --output=../ios_using_prebuilt_module/Flutterfrom theflutter_module) - Embed frameworks to the app following Option B from the 'add to an existing iOS app' guide.
- Open project in XCode and start app for the simulator
(to open XCode from theflutter_module:
open ../ios_using_prebuilt_module/IOSUsingPrebuiltModule.xcworkspace)
Expected results
iOS app is built and launched successfully.
Actual results
XCode build errors:
Multiple commands produce '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/Datadog.framework'Multiple commands produce '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/Sentry.framework'Warnings:
duplicate output file '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/Datadog.framework' on task: PhaseScriptExecution [CP] Embed Pods Frameworks /Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Intermediates.noindex/IOSUsingPrebuiltModule.build/Debug-iphonesimulator/IOSUsingPrebuiltModule.build/Script-98112F522513510246BDAF44.shduplicate output file '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/Sentry.framework' on task: PhaseScriptExecution [CP] Embed Pods Frameworks /Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Intermediates.noindex/IOSUsingPrebuiltModule.build/Debug-iphonesimulator/IOSUsingPrebuiltModule.build/Script-98112F522513510246BDAF44.shCode sample
Created a branch from the flutter/samples repository where I followed Steps to reproduce:
https://github.com/p-mazhnik/flutter-samples/tree/add2app-issue
Sample is add_to_app/prebuilt_module.
Logs
XCode Logs
Showing All Messages
Prepare packages
Prepare build
Multiple commands produce '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/Datadog.framework'
Multiple commands produce '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/Sentry.framework'
Multiple commands produce '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/SentryPrivate.framework'
Building targets in dependency order
Computing target dependency graph and provisioning inputs
Build target IOSUsingPrebuiltModule
duplicate output file '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/Datadog.framework' on task: PhaseScriptExecution [CP] Embed Pods Frameworks /Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Intermediates.noindex/IOSUsingPrebuiltModule.build/Debug-iphonesimulator/IOSUsingPrebuiltModule.build/Script-98112F522513510246BDAF44.sh
duplicate output file '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/Sentry.framework' on task: PhaseScriptExecution [CP] Embed Pods Frameworks /Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Intermediates.noindex/IOSUsingPrebuiltModule.build/Debug-iphonesimulator/IOSUsingPrebuiltModule.build/Script-98112F522513510246BDAF44.sh
duplicate output file '/Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Products/Debug-iphonesimulator/IOSUsingPrebuiltModule.app/Frameworks/SentryPrivate.framework' on task: PhaseScriptExecution [CP] Embed Pods Frameworks /Users/mazhnik/Library/Developer/Xcode/DerivedData/IOSUsingPrebuiltModule-fslipirruxqfkpgbhswqnyfjfxeb/Build/Intermediates.noindex/IOSUsingPrebuiltModule.build/Debug-iphonesimulator/IOSUsingPrebuiltModule.build/Script-98112F522513510246BDAF44.sh
Activity Log Complete 09.07.2023, 10:05 0.2 seconds
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.3.1 22E772610a darwin-arm64,
locale ru-RU)
• Flutter version 3.10.5 on channel stable at /Users/mazhnik/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (4 weeks ago), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/mazhnik/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• ANDROID_HOME = /Users/mazhnik/Library/Android/sdk
• Java binary at: /Users/mazhnik/Library/Application
Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841
/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2)
• Android Studio at /Users/mazhnik/Library/Application
Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841
/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
17.0.6+0-17.0.6b802.4-9586694)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.3)
• IntelliJ at /Users/mazhnik/Applications/JetBrains Toolbox/IntelliJ IDEA
Ultimate.app
• Flutter plugin version 74.0.4
• Dart plugin version 231.9161.14
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.3)
• IntelliJ at /Users/mazhnik/Library/Application
Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9161.38/IntelliJ IDEA.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.73.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.52.0
[✓] Connected device (3 available)
• iPhone 14 Pro (mobile) • BB40A04B-5DC2-4B69-864F-8B42B652A2B5 • ios
• com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
• macOS (desktop) • macos •
darwin-arm64 • macOS 13.3.1 22E772610a darwin-arm64
• Chrome (web) • chrome •
web-javascript • Google Chrome 114.0.5735.198
[✓] Network resources
• All expected network resources are available.
• No issues found!Proposal
- Update flutter add-to-app documentation to indicate that Options B & Option C have limitation in case flutter plugin and native iOS app have a shared dependency.
- Introduce new flag
--[no-]-pluginsfor thebuild ios-frameworkcommand that excludes plugins from build (_producePluginsfunction is not called):
[Add2App] provide flag for 'build ios-framework' command to build only App.xcframework #114692 - Introduce Option D that suggests developers to:
- build frameworks using
flutter build ios-framework --no-plugins - link & embed
App.xcframeworkusing option B - link & embed
Flutter.xcframeworkusing option B or C - link plugins to project by adding them to
Podfiledirectly (e.g. by usinginstall_flutter_plugin_pods, similar to Option A). Another advantage -- we don't need to determine whether plugin produce static or dynamic framework (like in option B when embed plugins frameworks manually), Cocoapods will do this for us.- If using
install_flutter_plugin_podswe will run into a limitation:
it requires Flutter and module dependencies to be installed locally. Workaround is to copy plugins somewhere and add them to project manually or using script similar toflutter_install_plugin_pods. I am not sure if we should provide such scripts to the developers. - we may also need a slightly different version of
flutter_post_installscript
- If using
- build frameworks using
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: existing-appsIntegration with existing apps via the add-to-app flowIntegration with existing apps via the add-to-app flowd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/found in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12Found to occur in 3.12has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Activity
p-mazhnik commentedon Jul 9, 2023
Simple workaround that worked for me for some plugins:
do not embed frameworks produced by Flutter for which we have the
Multiple commands produce ...issue.For the sample code above, it means that we need to remove some frameworks from the
Frameworks, Libraries, and Embedded Contentsection of theGeneraltarget tab:Datadog.xcframework,Sentry.xcframeworkandSentryPrivate.xcframework. It worked for me previously for some plugins, for instance, if I have justsentrywithoutdatadog, it will work. Unfortunately, with the datadog and this workaround, we have multipleUndefined symbolissues:Build IOSUsingPrebuiltModule_2023-07-09T10-26-54.txt.
This was also reported in the DataDog repo: DataDog/dd-sdk-flutter#443
I believe this can't be a DataDogSdk issue, because all is working as expected using Option A. Probably it has smth to do with the fact that
datadog_flutter_plugin.xcframeworkis static.p-mazhnik commentedon Jul 9, 2023
Complex workaround that involves combination of Options A and B and custom scripts, can be found here:
#114692.
darshankawar commentedon Jul 10, 2023
Thanks for the detailed report. I was able to replicate the reported behavior using the code sample and steps to replicate provided.
stable, master flutter doctor -v
4rthurmonteiro commentedon Sep 22, 2023
Some update about this issue?
[flutter_tools] build ios-frameworks: option to exclude plugin framew…
nasko25 commentedon Jan 15, 2024
I also encountered this issue.
Is there an ETA on when it will be fixed?
I see that
--no-pluginshas been mentioned as a potential fix. Does this include not building any custom flutter plugins used in the project as well? If so, how can we build a flutter plugin separately from the main flutter project, since any native Pod dependencies are defined in the main project'sPodfile?Also, is there a way to define a custom Pod dependency only for a given flutter plugin?
It can be defined for the main flutter project with something like this:
But is there a way to define it only for a specific flutter plugin?
4rthurmonteiro commentedon Jan 18, 2024
Hello @nasko25,
My solution was:
App and Flutter
For example the app.podspec:
So in the podfile you can just add this podspec.
Plugins
Whene you do the
flutter pub get, a flutter-plugins-dependencies is generated with all the plugins necessary to run your flutter module. Also, in.ios/Flutterhas a folder called FlutterPluginRegistrant with all dependencies.Basically you can add the FlutterPluginRegistrant pod in your podfile and use a private cocoapods repo (Ex. Jfrog Artifactory) with the pods. Maybe you can use git too.
For example, my app has geolocator and maps. So the ios plugins in the FlutterPluginRegistrant I uploaded all to Jfrog.
In my case I use the Jfrog and works fine.
Example: Podfile
nasko25 commentedon Jan 25, 2024
Hey @4rthurmonteiro
Thank you for sharing your solution.
prasadsunny1 commentedon Jul 25, 2024
@4rthurmonteiro have you written about how you did it?
I am trying what you have suggested here, but I am stuck at the point where you are asking to create a pod lib for each dependency under
/ios/.symlinks/plugin_name/ios4rthurmonteiro commentedon Sep 18, 2024
hey @prasadsunny1 ! Did you get it?
EvanMasterson commentedon Mar 5, 2025
We have run into the exact same issue with the Add to App approach via Option B, we chose option B as our project is solely SPM, we do not want to integrate Cocoapods, it is at end of life.
Our native app has Datadog SDK in it, and we would also like to integrate Datadog SDK on the flutter side, all workarounds described above are not an option for a project that solely uses SPM. This would happen also with other SDK's such as Firebase.
Are there any known solutions for SPM? If not, is there work being done around this, if so is there an ETA?
I've found these #146957 and DataDog/dd-sdk-flutter#443 which outlines exactly the same issue.
It is not really acceptable that even defined in the limitations is to link via podspec, which brings Cocoapods back into the picture, https://docs.flutter.dev/add-to-app/ios/project-setup#method-b-limits
iamnabink commentedon Sep 14, 2025
Any solution on this?