首页 > 解决方案 > 由于 SKOverlay.AppConfiguration,Apple 硅 Mac 支持问题

问题描述

我的应用使用 appStoreOverlay 显示推荐的应用,但提交到应用商店时出现错误。

ITMS-90863: Apple silicon Macs support issue - The app uses symbols that are not present on Mac:
/System/Library/Frameworks/_StoreKit_SwiftUI.framework/_StoreKit_SwiftUI
_$s7SwiftUI4ViewP010_StoreKit_aB0F03appD7Overlay11isPresented13configurationQrAB7BindingVySbG_So22SKOverlayConfigurationCyctRQOMQ

我认为 SKOverlay.AppConfiguration 不存在于硅 Mac 上。根据“构建通用 macOS 二进制文件”,我添加了一些宏并且代码仅在 iOS 中运行,但错误仍然存​​在。有什么建议么?

#if !targetEnvironment(macCatalyst) && os(iOS)
Button(action: { showRecommendedApp.toggle() }) { Text("App recommended".localized)  
    .appStoreOverlay(isPresented: $showRecommendedApp) {
        SKOverlay.AppConfiguration(appIdentifier: "12345", position: .bottom)
    }
#endif

标签: iosswiftuisilicon

解决方案


M1 Mac 可以直接运行 iOS 二进制文件,它们不需要 Mac Catalyst 构建。

您不能在编译时使用#if 来测试 M1,因为它是在 iOS 和 M1 Mac 上运行的相同二进制文件。

您可以使用运行时检查isiOSAppOnMac

if !ProcessInfo.processInfo.isiOSAppOnMac {
    Button ...
}

您仍然会收到警告,但您知道它将在运行时正确处理。


推荐阅读