Skip to content

flutter build ios-framework Some plugin debug framework creation failing #63508

Closed

Description

@robrichardson13

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

  1. Create a new flutter module: flutter create --template module my_flutter
  2. In the modules pubspec.yaml add the following dependency: native_mixpanel: ^0.1.2 (this uses the Mixpanel-swift pod which has the module/name differences)
  3. Run flutter pub get
  4. Because this package requires target 9.0 and Swift 5.0 isnt declared we have to make some small modifications (step 5 and step 6)
  5. Edit .ios/Podfile and change platform :ios, '8.0' to platform :ios, '9.0'.
  6. Open the demo project in Xcode open .ios/Runner.xcworkspace/. Click on the Runner project on the left, then click on the Runner target. From there click Build Settings and click on the + to add a new Add User-Defined Setting. Type in SWIFT_VERSION for the property and 5.0 for the value.
  7. 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:
Screen Shot 2020-08-11 at 11 58 27 AM

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

  1. darshankawar commented on Aug 12, 2020

    @darshankawar
    Member

    Hi @robrichardson13,
    Do you get the error only when you try to add native_mixpanel plugin 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.

  2. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 12, 2020
  3. robrichardson13 commented on Aug 12, 2020

    @robrichardson13
    Author

    @darshankawar, the cloud_firestore: ^0.13.7 plugin 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:

    [   +1 ms] executing: [/my_flutter/build/ios/framework/] xcrun xcodebuild -create-xcframework -framework
    /my_flutter/build/ios/framework/Debug/iphoneos/Debug-iphoneos/PromisesObjC/FBLPromises.framework -framework
    /my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/FBLPromises/FBLPromises.framework -output
    /my_flutter/build/ios/framework/Debug/FBLPromises.xcframework
    [ +488 ms] error: unable to read the file at '/my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/FBLPromises/FBLPromises.framework/FBLPromises'
    
    
    [ +488 ms] xcframework successfully written out to: /my_flutter/build/ios/framework/Debug/FlutterPluginRegistrant.xcframework
    [        ] executing: [/my_flutter/build/ios/framework/] xcrun xcodebuild -create-xcframework -framework
    /my_flutter/build/ios/framework/Debug/iphoneos/Debug-iphoneos/gRPC-Core/grpc.framework -framework
    /my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/grpc/grpc.framework -output
    /my_flutter/build/ios/framework/Debug/grpc.xcframework
    [ +515 ms] error: unable to read the file at '/my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/grpc/grpc.framework/grpc'
    
    
    [   +1 ms] executing: [/my_flutter/build/ios/framework/] xcrun xcodebuild -create-xcframework -framework
    /my_flutter/build/ios/framework/Debug/iphoneos/Debug-iphoneos/BoringSSL-GRPC/openssl_grpc.framework -framework
    /my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/openssl_grpc/openssl_grpc.framework -output
    /my_flutter/build/ios/framework/Debug/openssl_grpc.xcframework
    [ +501 ms] error: unable to read the file at '/my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/openssl_grpc/openssl_grpc.framework/openssl_grpc'
    
    
    [   +1 ms] executing: [/my_flutter/build/ios/framework/] xcrun xcodebuild -create-xcframework -framework
    /my_flutter/build/ios/framework/Debug/iphoneos/Debug-iphoneos/gRPC-C++/grpcpp.framework -framework
    /my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/grpcpp/grpcpp.framework -output
    /my_flutter/build/ios/framework/Debug/grpcpp.xcframework
    [ +515 ms] error: unable to read the file at '/my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/grpcpp/grpcpp.framework/grpcpp'
    
    
    [        ] executing: [/my_flutter/build/ios/framework/] xcrun xcodebuild -create-xcframework -framework
    /my_flutter/build/ios/framework/Debug/iphoneos/Debug-iphoneos/leveldb-library/leveldb.framework -framework
    /my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/leveldb/leveldb.framework -output
    /my_flutter/build/ios/framework/Debug/leveldb.xcframework
    [ +491 ms] error: unable to read the file at '/my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/leveldb/leveldb.framework/leveldb'
    
    
    [        ] executing: [/my_flutter/build/ios/framework/] xcrun xcodebuild -create-xcframework -framework
    /my_flutter/build/ios/framework/Debug/iphoneos/Debug-iphoneos/abseil/absl.framework -framework
    /my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/absl/absl.framework -output
    /my_flutter/build/ios/framework/Debug/absl.xcframework
    [ +483 ms] error: unable to read the file at '/my_flutter/build/ios/framework/Debug/iphonesimulator/Debug-iphonesimulator/absl/absl.framework/absl'

    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.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 12, 2020
  5. darshankawar commented on Aug 13, 2020

    @darshankawar
    Member

    Issue is replicable on latest Stable 1.20.1.

    flutter doctor -v
    [✓] Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.2 19C57, locale en-US)
        • Flutter version 1.20.1 at /Users/deeptibelsare/Documents/Fluttersdk/flutter
        • Framework revision 2ae34518b8 (30 hours ago), 2020-08-05 19:53:19 -0700
        • Engine revision c8e3b94853
        • Dart version 2.9.0
    
    [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
        • Android SDK at /Users/deeptibelsare/Library/Android/sdk
        • Platform android-29, build-tools 29.0.3
        • ANDROID_HOME = /Users/deeptibelsare/Library/Android/sdk
        • ANDROID_SDK_ROOT = /Users/deeptibelsare/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
        ✗ Android license status unknown.
          Try re-installing or updating your Android SDK Manager.
          See https://developer.android.com/studio/#downloads or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.6)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.6, Build version 11E708
        • CocoaPods version 1.9.3
    
    [✓] Android Studio (version 3.6)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 45.1.1
        • Dart plugin version 192.7761
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    
     
    [✓] Connected device (2 available)            
        • SM A260G (mobile)           • 5200763ebcfa861f • android-arm • Android 8.1.0 (API 27)
        • sdk gphone x86 arm (mobile) • emulator-5554    • android-x86 • Android 11 (API 30) (emulator)
    
    ! Doctor found issues in 1 category.
    
  6. added
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    platform-iosiOS applications specifically
    t: xcode"xcodebuild" on iOS and general Xcode project management
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Aug 13, 2020
  7. added
    P2Important issues not at the top of the work list
    on Aug 18, 2020
  8. added a commit that references this issue on Sep 24, 2020
    8815b0a
  9. jmagman commented on Nov 5, 2020

    @jmagman
    Member

    @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!

  10. github-actions commented on Aug 10, 2021

    @github-actions

    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 -v and a minimal reproduction of the issue.

  11. locked as resolved and limited conversation to collaborators on Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowfound in release: 1.20Found to occur in 1.20has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyt: xcode"xcodebuild" on iOS and general Xcode project managementtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions