Repository navigation
flutter build ios-framework Some plugin debug framework creation failing #63508
Description
Issue
So after tons of debugging, I figured out that some plugin packages (native iOS pods) fail to properly create their respective frameworks (in debug) if in their Podspec their name differs from their module name. An example would be a pod with the following spec:
Pod::Spec.new do |s|
s.name = 'Mixpanel-swift'
s.module_name = 'Mixpanel'Steps to Reproduce
- Create a new flutter module:
flutter create --template module my_flutter - In the modules
pubspec.yamladd the following dependency:native_mixpanel: ^0.1.2(this uses theMixpanel-swiftpod which has the module/name differences) - Run
flutter pub get - Because this package requires target
9.0andSwift 5.0isnt declared we have to make some small modifications (step 5 and step 6) - Edit
.ios/Podfileand changeplatform :ios, '8.0'toplatform :ios, '9.0'. - Open the demo project in Xcode
open .ios/Runner.xcworkspace/. Click on theRunnerproject on the left, then click on theRunnertarget. From there clickBuild Settingsand click on the+to add a newAdd User-Defined Setting. Type inSWIFT_VERSIONfor the property and5.0for the value. - Run
flutter build ios-framework --no-release --no-profile --no-universal --xcframework --verbose
Logs
[ +1 ms] executing: [/my_flutter/build/ios/framework/] xcrun xcodebuild -create-xcframework -framework
/my_flutter/build/ios/framework/Debug/iphoneos/Debug-iphoneos/Mixpanel-swift/Mixpanel.framework -framework
/my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/Mixpanel/Mixpanel.framework -output
/my_flutter/build/ios/framework/Debug/Mixpanel.xcframework
[ +467 ms] error: unable to read the file at '/my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/Mixpanel/Mixpanel.framework/Mixpanel'You can see that Debug-iphonesimulator/Mixpanel/Mixpanel.framework/Mixpanel doesnt exist because it actually exists at path: Debug-iphonesimulator/Mixpanel-swift/Mixpanel.framework/Mixpanel instead.
Solution
This problem occurs because when building debug frameworks, it assumes the Pod name and module name match, which causes the file to not be found. This happens in 2 spots in this file build_ios_framework.dart here:
if (mode == BuildMode.debug)
simulatorBuildConfiguration
.childDirectory(binaryName)
.childDirectory(podFrameworkName)
.childFile(binaryName)
.path,A fix would be adding this variable:
final String frameworkDir = globals.fs.path.basename(podProduct.dirname);and using it in the debug path:
if (mode == BuildMode.debug)
simulatorBuildConfiguration
.childDirectory(binaryName)
.childDirectory(frameworkDir)
.childFile(binaryName)
.path,Here is a diff on the file changes:

Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.6 19G73, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.47.3)
[✓] Connected device (1 available)
• No issues found!
Activity
darshankawar commentedon Aug 12, 2020
Hi @robrichardson13,
Do you get the error only when you try to add
native_mixpanelplugin or with other plugins as well ?Reason I asked this is, since that plugin is a 3rd party, it may have been using different pod and module name (that's my guess) that may not be compatible.
Can you try with any one of Flutter's first party plugin and see if you still experience this issue ?
Thanks.
robrichardson13 commentedon Aug 12, 2020
@darshankawar, the
cloud_firestore: ^0.13.7plugin also contains the issue. If you have a project that only brings in this dependency, you'll see the following errors when trying to build:To test this plugin, you won't have to change the Podfile or project file. This probably would have been a better example to outline in my first post.
darshankawar commentedon Aug 13, 2020
Issue is replicable on latest Stable 1.20.1.
flutter doctor -v
resolve flutter#63508
jmagman commentedon Nov 5, 2020
@robrichardson13 I believe this is fixed on the master channel, if you are able to test and verify it now works that would be extremely helpful!
github-actions commentedon Aug 10, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.