Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exposing flutter module as IOS framework results in "Failed to find assets path for "Frameworks/App.framework/flutter_assets"

I am receiving Failed to find assets path for "Frameworks/App.framework/flutter_assets when trying to expose a Flutter project via a framework to another IOS project (Add to App via a Framework).

I created a Flutter project that i now want to expose as a native Framework for IOS. We want to share our project with other companies so that they can integrate it in their IOS application.

I followed the documentation described on https://flutter.dev/docs/development/add-to-app/ios/project-setup and i used option C. This will create an XCFramework of our Flutter module and integrate it in our native IOS Framework which will have an API to work with the flutter project. In that way our IOS Framework can be seen as an Umbrella kind of Framework but also with an exposed API.

So what i created is:

  • A Flutter module
  • An IOS Framework
  • An IOS Project

I build the flutter module using ./flutterw build ios-framework --cocoapods --xcframework --no-universal --output=../WhiteLabelIOSFrameWork/Flutter --verbose into the IOS Framework. I added the libraries to the Framework and i created a codespec file for the Framework with only Flutter as a dependency. Afterwards i added a Podfile to the project and added the Framework as a dependency.

All of this is working (i only needed to upgrade to Flutter 1.24.X to have this fix available https://github.com/flutter/flutter/pull/69736). But when i start my Flutter engine it's unable to find the flutter_assets (Failed to find assets path for "Frameworks/App.framework/flutter_assets).

I tried building the ios-framework directly into our IOS project and skip the in between Framework and then it seems to work. So i think it cannot find the flutter_assets since the App.framework is not in the IOS project itself, but in a Framework in between.

Is there a way to move the flutter_assets path or so? Or any other idea on how to solve this?

Kind regards, Daan

like image 506
Daan Poron Avatar asked Nov 07 '22 03:11

Daan Poron


1 Answers

This issue cause when you create Flutter Engine without FlutterDartProject. Just add FlutterEngine(name: "your name", project: FlutterDartProject(precompiledDartBundle: Bundle.init(for: Self.self)))

like image 186
Hoa Pham Avatar answered Nov 14 '22 21:11

Hoa Pham