No such module '_AVKit_SwiftUI'

Xcode 12.3 throws this Swift compiler error when building the archive of our app (for uploading to TestFlight). Debug builds run without any such errors.

Deployment target is iOS 9.0.

I've added some SwiftUI views which are all wrapped with
Code Block
@available(iOS 14.0, *)

One SwiftUI view uses VideoPlayer which requires an
Code Block
import AVKit

and that's exactly where the Swift compiler fails during archive build:

No such module '_AVKit_SwiftUI'

Does anybody have any idea how to fix this?

Accepted Reply

Well, it seems I have to exclude the armv7 architecture from builds, killing support for devices before iPhones 5s. Or at least that was the only thing that helped when comparing every build setting that differs between debug and release.

Maybe an alternative would be to wrap any SwiftUI-related code between
Code Block
#if arch(arm64)
...
#endif

to not completely drop support for older devices?

  • Stumbling again over my own post: Yes, the alternate approach did work. I wrapped each file that imports SwiftUI into #if arch(arm64) / #endif and also those parts in other files referencing the SwiftUI structs. In Objective-C files I used #if arch != armv7 instead.

Add a Comment

Replies

Well, it seems I have to exclude the armv7 architecture from builds, killing support for devices before iPhones 5s. Or at least that was the only thing that helped when comparing every build setting that differs between debug and release.

Maybe an alternative would be to wrap any SwiftUI-related code between
Code Block
#if arch(arm64)
...
#endif

to not completely drop support for older devices?

  • Stumbling again over my own post: Yes, the alternate approach did work. I wrapped each file that imports SwiftUI into #if arch(arm64) / #endif and also those parts in other files referencing the SwiftUI structs. In Objective-C files I used #if arch != armv7 instead.

Add a Comment