flutter-rust-ffi icon indicating copy to clipboard operation
flutter-rust-ffi copied to clipboard

Ensure the bundling of C symbols on iOS archive

Open brickpop opened this issue 4 years ago • 1 comments

Option 1

Follow https://flutter.dev/docs/development/platform-integration/c-interop#ios-symbols-stripped

Option 2

See from https://github.com/drewcrawford/Rust-iOS-Example#the-case-of-the-missing-symbols


What seems to happen is Xcode strips some symbols from a framework when it's built. So if you have libhello.a inside a framework, and the framework doesn't call anything inside libhello.a, all of libhello.a is striped. If you only call one function, the others are stripped etc.

So what you have to do is declare an exported_symbols.txt like

_hello
_benchmark

And then set that file as the framework's Exported Symbols File in the framework's build settings.

brickpop avatar Dec 24 '20 09:12 brickpop

Append to the podfile (main app)


post_install do |installer|
  project = installer.pods_project

  project.targets.each do |target|
    if target.name == 'PublicA'
      # Link dependencies into PublicA.framework
      target.build_configurations.each do |config|
        #config.build_settings['DEAD_CODE_STRIPPING'] = 'NO'
        config.build_settings['STRIP_STYLE'] = "non-global"
      end
    end
  end

end

Or append on the library podspec:


spec.pod_target_xcconfig = { 'STRIP_STYLE' => 'non-global' }  # ...  'OTHER_LDFLAGS' => '-lObjC' 

brickpop avatar Dec 27 '20 12:12 brickpop