-
Notifications
You must be signed in to change notification settings - Fork 43
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 Failed to lookup symbol (dlsym(RTLD_DEFAULT, test_func): symbol not found) #897
Comments
@hustxiaoc Could you please provide more information? What version of Flutter are you using? And do you have a minimal reproduction? |
Sure, I'll create a minimal demo project.
Thanks. |
Or you can just try this plugin, it has the same error. https://pub.dev/packages/dvote_native#-example-tab-
|
Do the fixes mentioned dart-archive/ffi#39 (comment) work for you? |
I am facing the exactly the same problem on IOS, but only in release mode and only with .DynamicLibrary.lookupFunction. |
@hustxiaoc Did you manage to fix it ? Thanks! |
@vladimirdjokic76 It works fine in release mode after I rebuild the library, but the problem shows again in Archive mode. |
I'm going to use the old way, dart -> oc -> library. |
Thanks @hustxiaoc 👍 |
I ran into this issue recently as well, and was able to resolve it (after lots of trial/error). The long and the short of it is that Xcode performs aggressive dead code elimination, with no option for disabling it. Following this medium article is necessary but not entirely sufficient. You must also ensure the functions are invoked from a place in code that cannot be removed via dead code analysis (e.g. at the end of the Something like:
Not sure if the linker was updated after the writing of the article to be more aggressive. Additionally I had to disable code optimization in the Swift Compiler: |
@negator Great work , I'll try it. |
@negator I still got the issue after turning off Optimization |
@hustxiaoc looking at your test project it seems you are only calling the But I noticed many more functions in the header file. In my project I have 3 functions, that I explicitly invoke in dummy functions. After disabling optimizations and creating an archive, I can see the functions in my archive using
I imagine the binary you would need to inspect would be something like:
Do you at least see the Edit: For cocoapods, you might need to disable whole-module-optimization. This SO answer seems to work: https://stackoverflow.com/questions/46722323/project-pods-turn-on-whole-module-optimization/48550610#48550610 |
Will disable code optimization have a significant impact on the performance and app size? |
I don’t believe so, since flutter apps do not contain much swift code, but I’m not 100% sure. |
Disable optimizations not work because symbols are removed (or hidden) after export the archive. So main problem in the export. Issue with optimization you can fix by adding attributes to your function
My current workaround: Build library as framework and I load it as |
I am also facing the same issue. works for debug mode, but the issues on the release mode |
Has anybody managed to fix this? Nothing seems to work. Extremely frustrating to see that it works on debug/release but on in the archive. |
@awazgyawali You can try flutter channel for now, which is letting |
I figured out a workaround, inspired by the article refered by @dcharkes: using-ffi-on-flutter-plugins-to-run-native-rust-code
|
@xuchaoqian is this working for you? did you tested it in the Test Flight? |
It works on the real phone and the simulator. Not test it in the Test Flight yet. BTW., I edited my earlier comment to add step 2. |
HI All,
This is my solution, it also works in Test Flight...
Select Target Runner -> Build Settings -> Strip Style -> change from "All
Symbols" to "Non-Global Symbols"
this is the [app](https://apps.apple.com/app/id1518486203) :)
<img width="976" alt="Screenshot 2020-06-17 at 20 43 52" src="https://user-images.githubusercontent.com/11029148/84937058-7bd36780-b0db-11ea-9f4b-79f362adb6a0.png">
|
@AnisovAleksey @dcharkes |
I have tested my app in TestFlight. It works fine. |
@vladimirdjokic76 |
With latest flutter, was adding a universal static library but dart can't see it but iOS can see the symbol. Followed all the directive from https://flutter.dev/docs/development/platform-integration/c-interop#ios-symbols-stripped |
@dcharkes should i file another bug or the provided Information are enough ? |
Hi @bitsydarel, I'm also trying to get libpdfium to work on iOS and facing the same problem. Did you get it to run? |
@RalphBergmannKMB Did you manage to run libpdfium.a in a flutter ios / macos project? I'm currently having the same issues :-( |
@buehler yes, but the iOS part was hard. I'm currently on holiday on Crete and can't help you more, but my plan is to release a Flutter plugin for PDFium. In the end, I created my own version of this *.a file for iOS. |
Hey @RalphBergmannKMB thanks for the answer, I just had a breakthrough! I'm currently writing a plugin for PDFium in flutter since we need it for a project at our company. I'll keep you posted. |
Hey @RalphBergmannKMB I managed to run it on all platforms. MacOS and iOS need help (from c++) to export the symbols. If you're interested, the plugin is in an alpha (non-published on pub.dev) state on https://github.com/smartive/flutter_pdfium. We will improve the functionality as we develop the project and then we're going to publish it on pub.dev. |
I did it in a different way. I used the code from https://github.com/paulo-coutinho/pdfium-lib but changed the way the *.a file is generated for iOS (I can't remember exactly, just wait until I'm back home). Then I added those *.a and all the *.h files to the XCode project. And called a function from each *.h file, otherwise, XCode will remove the file. Finally, I generated the mappings for Dart (https://pub.dev/packages/ffigen) and everything was ready. I also tried to generate a Framework, but failed with singing issues :( |
But the result is absolutely amazing. We use PDFium to render PDF pages as bitmaps and display them in a Flutter app on Android and iOS. The UI doesn't freeze or something like that when you scroll from one page to another. It's super fast. |
This saved my week ✅ |
App worked building in debug or release mode, but bridge failed in testflight. https://github.com/dart-lang/ffi/issues/41
@vladimirdjokic76 thank youuu thank youuuuu thank youuuuuuuuuu |
It was ok in debug mode, but failed in release mode.
The text was updated successfully, but these errors were encountered: