Also link dynamically when using Swift Package Manager#239
Open
FrankenApps wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a critical fix for iOS and macOS after the migration to Swift Package Manager.
Background
Albeit
flutter runandflutter run --releasework just fine for iOS at the moment, in an app built for distribution withflutter build ipa, the barcode detection does not work at all.The reason for this is that during archiving XCode strips exported symbols by default.
Fix
I fixed the regression by using dynamic linking as has been done with CocoaPods before.
Validation
Because I found it rather difficult to pin-point / validate the issue initially, I thought I'd provide a small overview for how to do it with the sample app, just in case you want to verify the change.
git submodule update --init --recursive && ./scripts/update_ios_macos_src.shcd exampleflutter pub getcd iosor
Note that the whole framework is gone with the current
mainbranch (you can for example verify this withotool -L "/tmp/Runner.xcarchive/Products/Applications/Runner.app/Runner" | grep zxingwhich does not find the framework on main, but does with the fix), but you can still somewhat verify the issue, by checking if the symbols are present in the statically linked app:as you will see the symbols are not present which means they were stripped out by XCode.
Alternative
Alternatively we could instruct users in the README to enable the
Non-Global SymbolsStrip Stylein their iOS and macOS XCode projects and keep linking statically, but I think providing a central fix here, that also aligns with the previous behavior when using CocoaPods is the preferred option.Notes on the PR
.build/directory of the native iOS and macOS projects in the.gitignorewhich is the standard practice