我下载了xCode 8.0 beta
并打开了一个最近写在 swift 2
中的项目然后我将其转换为 swift 3
使用 xCode。
然后我添加了一个 watchOS
使用设置“游戏”定位到我的项目
文件 > 新建 > 目标:
我检查了 WatchExtension
中的 GameScene.swift果然所有的代码都在那里并设置了一个场景:
import SpriteKit
class GameScene: SKScene {
private var spinnyNode : SKShapeNode?
override func sceneDidLoad() {
if let label = self.childNode(withName: "//helloLabel") as? SKLabelNode {
label.alpha = 0.0
label.run(SKAction.fadeIn(withDuration: 2.0))
}
let w = (self.size.width + self.size.height) * 0.05
let spinnyNode = SKShapeNode(rectOf: CGSize(width: w, height: w), cornerRadius: w * 0.3)
spinnyNode.position = CGPoint(x: 0.0, y: 0.0)
spinnyNode.strokeColor = UIColor.red()
spinnyNode.lineWidth = 8.0
spinnyNode.run(SKAction.sequence([SKAction.wait(forDuration: 0.5),
SKAction.fadeOut(withDuration: 0.5),
SKAction.removeFromParent()]))
spinnyNode.run(SKAction.repeatForever(SKAction.rotate(byAngle: 6.28, duration: 1)))
self.run(SKAction.repeatForever(SKAction.sequence([SKAction.wait(forDuration: 2.0),
SKAction.run({
let n = spinnyNode.copy() as! SKShapeNode
self.addChild(n)
})])))
}
override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered
}
}
不幸的是,我似乎无法在 Apple Watch Simulator 上安装它。
我已经尝试了所有我能想到的,包括:
- 清理构建等
- 卸载/重新安装,
- 检查了 info.plist for common errors ,
- 使用
Add Additional Simulators
与配对的 Apple Watch 创建了一个新的模拟器, - 添加了跳过安装 = 否,建议 here ,
- 在 iPhone 模拟器中从配对的 iOS Apple Watch 应用程序安装(只是不安装),
- 甚至添加了用户定义的项目设置,如 raywenderlich 中的建议watchOS 教程...
我什至无法让它安装或出现在 Apple Watch 上。我没有做什么?
更新
我已将 iOS 应用程序的部署目标调整为 10.0,我终于能够从 iPhone 模拟器中的 Apple Watch 应用程序安装它,除了从 Apple Watch 模拟器启动 Apple Watch 应用程序时,我得到以下信息错误:
dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: /Users/MYNAME/Library/Developer/CoreSimulator/Devices/XXXXXX-XXXX-XXXX-XXXX/data/Containers/Bundle/Application/XXXXXX-XXXX-XXXX-XXXX/MYAPPNAME.app/PlugIns/MYAPPWATCH Extension.appex/MYAPPWATCH Extension
Reason: image not found
(lldb)
这个错误是什么意思?不应该加载任何图像,因为它是默认的 SpriteKit 测试...
最佳答案
可能不是真正的解决方案,而是我在尝试各种方法数小时后找到的解决方法 here, on Stackoverflow ,对于发生在我上面的问题底部的错误。
因此,如果您将应用程序转换为 Swift 3.0,将 watchOS“游戏”目标添加到您的项目,将 iOS 部署目标更改为 10.0 并在 WatchOS 3.0 模拟器和 iPhone 6s iOS 10 模拟器上运行,更新以下设置:
将否更改为是:
Project > Targets > App Name > Embed Asset Packs In Product Bundle = YES
还有“你好,世界!”应该出现在 Apple Watch 上,带有一个旋转的、脉动的 spriteNode(没有在屏幕截图中显示,因为没有足够快地捕捉它)。
请注意,您可能需要从 iPhone 模拟器的 Apple Watch 应用程序安装该应用程序,方法是启动 Apple Watch 应用程序,单击您的应用程序,然后按“在 Apple Watch 上显示”。
关于xcode - 在 Apple Watch 模拟器(xCode 8、Swift 3、iOS 10)上的 watchOS 中运行 SpriteKit 游戏 - libswiftSwiftOnoneSupport 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37820755/