Reputation: 3336
I downloaded xCode 8.0 beta
and opened a recent project written in swift 2
which I then converted to swift 3
using xCode.
I then added a watchOS
target to my project with the setting "game"
File > New > Target:
I checked the GameScene.swift in the WatchExtension
and sure enough all the code is there and sets up a scene:
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
}
}
Unfortunately I can't seem to get this to install on the Apple Watch Simulator.
I've tried everything I can think of, including:
Add Additional Simulators
,I just can't get it to even install or appear on the Apple Watch. what am I not doing?
UPDATE
I have adjusted the Deployment Target to 10.0 for the iOS App and I was finally able to install it from the Apple Watch app in the iPhone Simulator, except upon launching the Apple Watch App from the Apple Watch Simulator, I get the following error:
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)
What does this error mean? There shouldn't be any images to load as it's the default SpriteKit test...
Upvotes: 4
Views: 3014
Reputation: 3336
Probably not the real solution, but a work around that I found after hours of trying various things was found here, on Stackoverflow, for the Error occurring at the bottom of my question above.
So if you convert your App to Swift 3.0, Add a watchOS "game" Target to your project, change iOS Deployment Target to 10.0 and run on WatchOS 3.0 Simulator and iPhone 6s iOS 10 Simulator, update the following setting:
Change NO to YES:
Project > Targets > App Name > Embed Asset Packs In Product Bundle = YES
And "Hello, World!" should appear on the Apple Watch, with a spinning, pulsing spriteNode (not shown in screenshot as didn't capture it quick enough).
Please note, you may have to install the App from the Apple Watch App from the iPhone Simulator by launching the Apple Watch App, clicking your app, and pressing "show on Apple Watch".
Upvotes: 3