TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | May 2015 |
SPMSupports SPM | ✗ |
Maintained by Rouven Weßling, JP Wright.
Depends on: | |
MMWormhole | ~> 1.1 |
PeerKit | ~> 1.1 |
A communication channel from your Mac to your watch.
Providing a convenient wrapper around MMWormhole and PeerKit,
Stargate leverages Multipeer Connectivity and App Groups to communicate between an
OS X application and ᴡᴀᴛᴄʜ via your iPhone. The communication is bi-directional and
lets you send any object that complies with NSCoding
.
Simply install it via CocoaPods:
use_frameworks!
pod 'Stargate'
Note: make sure you use version 0.37 or newer. Stargate is written in Swift 1.2, so it requires Xcode 6.3 or newer as well.
Send and receive messages via Multipeer Connectivity:
let stargate = Earth(applicationGroupIdentifier: "group.com.contentful.Stargate")
stargate.listenForMessage(identifier: "stargate2") { (object) -> Void in
println("Received message on Mac: \(object)")
}
stargate.passMessage("YOLO", identifier: "stargate")
Bridge messages between Multipeer and Darwin notifications:
let stargate = Abydos(applicationGroupIdentifier: "group.com.contentful.Stargate")
stargate.tunnel()
stargate.tunnelReplies(identifier: "stargate2")
Send and receive messages via Darwin notifications:
let stargate = Atlantis(applicationGroupIdentifier: "group.com.contentful.Stargate")
stargate.passMessage("YOLO", identifier:"stargate2")
stargate.listenForMessage(identifier:"stargate") { (object) -> Void in
println("Received message on watch: \(object)")
}
stargate.stopListeningForMessage(identifier:"stargate")
Look at the example project for guidance on how to set up one project for all three platforms. When creating the targets, make sure you don't accidentially select the OS X target as host for the WatchKit extension.
Copyright (c) 2015 Contentful GmbH. See LICENSE for further details.