iosflutterxcodecocoapods

How to include an xcframework in a Flutter plugin that persists after pod install?


Problem

I'm developing a Flutter library that contains iOS native Swift code. This native code needs to call functions from an xcframework.

Currently, I can add the xcframework by manually dragging and dropping the file into Xcode.

Drag and drop xcframework to xcode

However, the xcframework will disapear whenever I run pod install, forcing me to re-add the xcframework each time. I have the vendored_frameworks inside the podspec as below:

  s.vendored_frameworks = 'ios/path/to/your/AnotherLibrary.xcframework'

Question

Is there a way to automatically include the xcframework in my Flutter plugin's iOS code that persists after running pod install?


Solution

  • I found the root cause and solution to this problem. The issue was with the naming convention of the static library inside the xcframework.

    Rename the static library from AnotherLibrary.a to libAnotherLibrary.a solved the issue.

    The "lib" prefix is the standard naming convention for static libraries, and Xcode's linker expects this format to properly resolve and link the library.