We have an app with a lot of functionality. We have decided to move slowly to SwiftUI, and I’ve implemented one of the views as a SwiftUI view. We support older iOS versions (from 10.0), so I had to add a lot of if #available(iOS 13.0, *)
and @available(iOS 13.0, *)
wherever needed around. The app runs fine on the simulators with different iOS versions. I can install it on my iPhone 11 with iOS 14, but when I try to archive the app I get a lot of errors, like:
- Cannot find ‘UIHostingController’ in scope
- Unknown attribute ‘State’
and other stuff related to SwiftUI. It seems that it can’t archive older versions.
I triple checked that all the classes and calls that relates to SwiftUI are tagged as only available for iOS 13. The application runs correctly on the iOS 12.4 simulator.
Any ideas?
2
Answers
I haven't properly solved the issue, but Change the iOS Deployment Target to iOS 11.0 fixed it.
Changing the deployment target to iOS 11 as @Olav mentioned fixed it. However, digging a little deeper, it seems it’s because SwiftUI doesn’t build for armv7 . Setting the minimum to iOS 11 excludes armv7 automatically.
This issue can be resolved by either:
armv7
#if !arch(arm)
/#endif
arch(arm)
matches armv7,arch(arm64)
matches arm64 & arm64e