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:
- Clean builds, etc
- Uninstall/reinstall,
- Checked info.plist for common errors,
- Created a new simulator with paired Apple Watch using
Add Additional Simulators
, - Added Skip Install = No, suggested here,
- Install from Paired iOS Apple Watch App in iPhone Simulator (just doesn't install),
- Even added user defined project settings, as suggested in a raywenderlich watchOS tutorial...
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...