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.
When previewing a module that links against
geosSwiftUI previews will fail to link withCannot preview in this fileandUpdate failed. Tapping on the diagnostic icon reveals a dynamic linker failure at runtimesee
Library not loaded: @rpath/geos.framework/geosWhen I disable dynamic linking in
Package.swiftthe package still builds successfully and SwiftUI previews work again.Is the reason for
.dynamiclinking of the upstreamlibgeos/geosC++ codebase solely for the LGPL license requirements? If so, it should be possible to create astaticversion of the library for the simulator while maintainingdynamiclinking when not targeting the simulator.The c++ code could be moved into a
commonmodule and two new modules be createdgeosandstaticGeos. Both new modules would depend oncommon,geoswould preserve backwards compatibility and be dynamically linked.staticGeoswould be available for SwiftUI Previews use cases.