运行 Apple Watch 模拟器上 watchOS 中的 SpriteKit 游戏(xCode 8,Swift 3,iOS 10)- libswiftSwiftOnoneSupport 错误

Running SpriteKit Game in watchOS on Apple Watch Simulator (xCode 8, Swift 3, iOS 10) - libswiftSwiftOnoneSupport Error

我下载了 xCode 8.0 beta 并打开了一个最近用 swift 2 编写的项目,然后我使用 xCode.

将其转换为 swift 3

然后我使用 "game"

设置向我的项目添加了一个 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 模拟器上安装它。

我已经尝试了所有我能想到的,包括:

我什至无法在 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 Whosebug,针对我上面问题底部发生的错误。

因此,如果您将应用程序转换为 Swift 3.0,请将 watchOS "game" 目标添加到您的项目,将 iOS 部署目标更改为 10.0 并在 WatchOS 上 运行 3.0模拟器和iPhone6siOS10模拟器,更新以下设置:

将否更改为是:

Project > Targets > App Name > Embed Asset Packs In Product Bundle = YES

并且 "Hello, World!" 应该会出现在 Apple Watch 上,带有旋转的脉动 spriteNode(未在屏幕截图中显示,因为捕捉速度不够快)。

请注意,您可能需要从 iPhone 模拟器的 Apple Watch 应用程序安装应用程序,方法是启动 Apple Watch 应用程序,单击您的应用程序,然后按 "show on Apple Watch"。