Search code examples
fluttercocoapodsassetsflutter-ios

Issues with asset images in pod dependency - Flutter


I'm trying to integrate a Swift CocoaPod into my Flutter proof of concept app. The pod contains UI components, including UIImages that are kept in the pod's Assets.xcassets.

Everything related to the pod dependency is working except for the image assets which don't show up on screen when running the app. They appear in the project when I look at the the Pods folder, but they just won't load at runtime.

What I've tried:

  • Copying the assets from the pod to my project directly worked, but I'd like to avoid doing this.
  • Adding the path to the assets folder in my pubspec.yaml file, but couldn't find a path that worked
  • Adding the pod as a static library in the Podfile instead of as a dynamic framework, but had issues with other dependencies of the the pod

I've created a native iOS Swift project and integrated the same pod there and everything is working fine, so I gather this must be a Flutter specific issue. Maybe Flutter isn't embedding the image assets properly? Or maybe I'm missing something?

Has anyone else had issues with loading assets when using CocoaPods in a Flutter app? Any pointers are appreciated


Solution

  • Adding use_frameworks! :linkage => :static to the Podfile worked for me. Leaving this here in case someone else encounters this issue.

    This command is available in CocoaPods 1.9+