ios - 无法为 tvOS 目标构建 Objective-C 模块 CoreMotion 错误

标签 ios sprite-kit tvos core-motion

从我的 Sprite Kit iOS 游戏创建我的 tvOS 目标时,我遇到了一些错误。

第一个是:Could not build Objective-C module CoreMotion

第二:未找到 Umbrella header “CoreMotion.h”

enter image description here

为了移植游戏,我从 iOS 目标中选择了我的大部分文件和 Assets ,并检查了 TVOS 目标。

enter image description here

如果我注释掉所有 CoreMotion 代码,错误就会消失。我已经在谷歌和此处进行了搜索以找到答案,但没有找到任何实质性内容。

有人知道怎么解决吗?

最佳答案

问题是 tvOS 不支持 CoreMotion。

我必须使用 iOS 特定代码才能使其适用于所有相关代码。

像这样:

#if os(iOS)
   import CoreMotion
#endif

您还可以编写 tvOS 特定代码:

#if os(iOS)
  let gameGain: CGFloat = 2.5
#elseif os(tvOS) // tvOS
  let gameGain: CGFloat = 2.0
#endif

关于ios - 无法为 tvOS 目标构建 Objective-C 模块 CoreMotion 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34348432/

相关文章:

background - 在 tvOS 后台接收 "Siri remote"事件

iphone - 有没有办法以编程方式(通过应用程序)添加 AppStore 评论?

android - iOS 上的蓝牙连接

ios - 在 iOS 中创建一个导出的方法库类

ios - 使用 xcode/swift 如何将黑色图像的 SKSpriteNode 的颜色更改为白色?

ios - tvO 上的侧键盘

iphone - 在 Xcode 中构建 Lite/Full 应用程序的配置

swift - tvos swift spritekit - UITapGestureRecognizer 没有响应

ios - sprite-kit 中的简单组合乘数

ios - 使用 swift 我们可以以编程方式在 Apple TV 上播放照片吗?