My app uses a 3rd party lib (AMPopTip) which conditionally includes some SwiftUI code. The app builds and runs fine in Xcode 13, but the archive build fails with errors such as:
Cannot find type 'View' in scope
Cannot find 'UIHostingController' in scope
These errors only show up for armv7 architecture. At first, I thought I should not be building for armv7, but in fact the same archive build works fine in Xcode 12.5.
Got an answer back from Apple support and it did solve the problem:
Based on your request Apple Developer Technical Support believes that your question is answered by the "Xcode Release Notes: Xcode 13 Release
Notes" linked here: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes
Specifically:
Swift libraries depending on Combine may fail to build for targets including armv7 and i386 architectures. (82183186, 82189214)
Workaround:
Use an updated version of the library that isn’t impacted (if available) or remove armv7 and i386 support (for example, increase the deployment target of the library to iOS 11 or higher).
In my case, I addressed this by installing a local version of the package and then bumping the swift-tools-version
in Package.swift to 5.5. This info came in very handy: https://developer.apple.com/documentation/swift_packages/editing_a_package_dependency_as_a_local_package