【问题标题】:Running SpriteKit Game in watchOS on Apple Watch Simulator (xCode 8, Swift 3, iOS 10) - libswiftSwiftOnoneSupport Error在 Apple Watch 模拟器(xCode 8、Swift 3、iOS 10)上的 watchOS 中运行 SpriteKit 游戏 - libswiftSwiftOnoneSupport 错误
【发布时间】:2016-06-14 19:42:13
【问题描述】:

我下载了xCode 8.0 beta 并打开了一个最近用swift 2 编写的项目,然后我使用xCode 将其转换为swift 3

然后,我使用“游戏”设置将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 模拟器上安装它。

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

  • 清理构建等
  • 卸载/重新安装,
  • 检查了 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 测试...

【问题讨论】:

    标签: xcode swift sprite-kit apple-watch watchos


    【解决方案1】:

    可能不是真正的解决方案,但我在尝试各种事情数小时后发现了一个解决方法 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 上显示”。

    【讨论】:

    • 我的 iMessage 扩展应用程序出现 dyld 图像错误,但“在产品包中嵌入资产包”尚未修复。建议?
    猜你喜欢
    • 1970-01-01
    • 2015-01-16
    • 1970-01-01
    • 2019-02-19
    • 2016-11-22
    • 1970-01-01
    • 2017-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多