Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS release Failed to lookup symbol (dlsym(RTLD_DEFAULT, test_func): symbol not found) #7

Closed
hustxiaoc opened this issue Apr 30, 2020 · 5 comments
Assignees

Comments

@hustxiaoc
Copy link

It was ok in debug mode, but failed in release mode.

Failed to lookup symbol (dlsym(RTLD_DEFAULT, test_func): symbol not found)
#0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33)
@bugeats
Copy link

bugeats commented May 28, 2020

Hey @hustxiaoc is this still a problem for you?

I used this template to build a Flutter plugin referenced locally in my main Flutter app codebase. It works fine during development and as an Xcode run in release mode, but it does not work once the ios app is archived/bundled and exported/uploaded to Testflight.

Looking at the bundled .ipa assets, my plugin binary does not appear, and is only referenced in the compiled app binary as a text reference (using objdump). It appears to me that the plugin binary is not getting bundled, but only during the archive process.

@hustxiaoc
Copy link
Author

@bugeats I've got the exact issue you've encountered. Here is a another discussion about this issue. dart-lang/native#897

@bugeats
Copy link

bugeats commented May 29, 2020

@hustxiaoc try removing the line

    s.static_framework = true

From the .podspec file in your plugins ios directory. I also suggest clearing your app's build folder and rebuilding:

rm -r ./build
flutter build ios

Now create an Xcode archive build via the menu "Product -> Archive".

Let me know if that solves your problem and I can offer some more of my notes. I'm exhausted with this issue at the moment.

@hustxiaoc
Copy link
Author

@bugeats Issue not solved.

@brickpop
Copy link
Owner

brickpop commented Sep 6, 2020

Hi @hustxiaoc,

I'm sorry to be late on this, but where the readme says add a dummy method in SwiftMylibPlugin.swift that uses at least one of the native functions, it should say add a dummy call for every single one of them.

For some unexplainable reason:

  • In Debug mode, XCode will bundle the entire library if at least one library function is used.
  • In Release mode, XCode will do tree shaking, and only bundle the native functions and the callees that you explicitly reference

I learnt it the hard way myself, I'm updating the Readme right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants