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

Dynamic linking causes SwiftUI Previews to crash #18

Open
sena-mike opened this issue Nov 13, 2022 · 1 comment
Open

Dynamic linking causes SwiftUI Previews to crash #18

sena-mike opened this issue Nov 13, 2022 · 1 comment
Labels

Comments

@sena-mike
Copy link

When previewing a module that links against geos SwiftUI previews will fail to link with Cannot preview in this file and Update failed. Tapping on the diagnostic icon reveals a dynamic linker failure at runtime

LoadingError: failed to load library at path ".../Debug-iphonesimulator/PackageFrameworks/AppFeature_-763FCD0D750E0A09_PackageProduct.framework/AppFeature_-763FCD0D750E0A09_PackageProduct": Optional(dlopen(/Users/sena/Library/Developer/Xcode/DerivedData/Modules-dzuyxirpdnkkyqbokjvjlomldapx/Build/Intermediates.noindex/Previews/AppFeature/Products/Debug-iphonesimulator/PackageFrameworks/AppFeature_-763FCD0D750E0A09_PackageProduct.framework/AppFeature_-763FCD0D750E0A09_PackageProduct, 0x0000): Library not loaded: @rpath/geos.framework/geos
|    Referenced from: <1B72

see Library not loaded: @rpath/geos.framework/geos

When I disable dynamic linking in Package.swift the package still builds successfully and SwiftUI previews work again.

Is the reason for .dynamic linking of the upstream libgeos/geos C++ codebase solely for the LGPL license requirements? If so, it should be possible to create a static version of the library for the simulator while maintaining dynamic linking when not targeting the simulator.

The c++ code could be moved into a common module and two new modules be created geos and staticGeos. Both new modules would depend on common, geos would preserve backwards compatibility and be dynamically linked. staticGeos would be available for SwiftUI Previews use cases.

@macdrevx
Copy link
Member

Thanks for the suggestion. I'd be happy to review a PR if you want to propose a patch.

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

No branches or pull requests

2 participants