I have an app with minimum deployment target of iOS 12.0. There are parts written in SwiftUI and Combine. All methods and types using the two libraries are marked with @available(iOS 13.0, *). The app has been running in this mixed setup since January without problems.
To take advantage of ABI stability and reduce the app size I want to set the new minimum deployment target to iOS 12.2.
When I do that the app crashes on launch (iOS 12.4 simulator) with the following printed to the console:
dyld: lazy symbol binding failed: can't resolve symbol _$s7Combine9PublishedVMa in /Users/YYYYYYYYY/Library/Developer/CoreSimulator/Devices/UUD-UUD-UUD-UUD/data/Containers/Bundle/Application/UUD/XXXXXXX.app/XXXXXXX because dependent dylib #29 could not be loaded dyld: can't resolve symbol _$s7Combine9PublishedVMa in /Users/YYYYYYYYY/Library/Developer/CoreSimulator/Devices/UUD-UUD-UUD-UUD/data/Containers/Bundle/Application/UUD-UUD-UUD-UUD/XXXXXXXapp/XXXXXXX because dependent dylib #29 could not be loaded
The app also crashes when attempting to launch on iPhone running iOS 12.4.
If I remove all @Published from the code but leave all other Combine and SwiftUI related bits the app can be used on iOS 12.
Even though all the classes containing @Published are marked with @available(iOS 13.0, *) I have tried wrapping them additionally in #if canImport(Combine) or applying #if canImport(Combine) to each @Published variable. This does not help.
I know I could change
@Published var name = ""
to
var name = "" {
willSet {
objectWillChange.send()
}
}
But that seems like a nasty workaround.
How can I increase deployment target to iOS 12.2 and keep using @Published when device is running iOS 13.0 or higher?