Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/contentful/Stargate
A communication channel from your Mac to your watch.
https://github.com/contentful/Stargate
Last synced: 3 months ago
JSON representation
A communication channel from your Mac to your watch.
- Host: GitHub
- URL: https://github.com/contentful/Stargate
- Owner: contentful
- License: mit
- Archived: true
- Created: 2015-05-03T15:33:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-29T00:37:43.000Z (over 9 years ago)
- Last Synced: 2024-04-30T00:45:32.248Z (9 months ago)
- Language: Swift
- Size: 854 KB
- Stars: 135
- Watchers: 12
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swift-cn - Stargate - A communication channel from your Mac to your watch. (Libs / Network)
README
# Stargate
[![Version](https://img.shields.io/cocoapods/v/Stargate.svg?style=flat)](http://cocoadocs.org/docsets/Stargate)
[![License](https://img.shields.io/cocoapods/l/Stargate.svg?style=flat)](http://cocoadocs.org/docsets/Stargate)
[![Platform](https://img.shields.io/cocoapods/p/Stargate.svg?style=flat)](http://cocoadocs.org/docsets/Stargate)
[![Build Status](https://img.shields.io/circleci/project/contentful-labs/Stargate.svg?style=flat)](https://circleci.com/gh/contentful-labs/Stargate)![](Stargate.gif)
A communication channel from your Mac to your watch.
Providing a convenient wrapper around [MMWormhole][1] and [PeerKit][2],
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`.## Usage
Simply install it via [CocoaPods][4]:
```ruby
use_frameworks!pod 'Stargate'
```Note: make sure you use version [0.37][5] or newer. Stargate is written in Swift 1.2,
so it requires Xcode 6.3 or newer as well.### On the Mac
Send and receive messages via Multipeer Connectivity:
```swift
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")
```### On the phone
Bridge messages between Multipeer and Darwin notifications:
```swift
let stargate = Abydos(applicationGroupIdentifier: "group.com.contentful.Stargate")
stargate.tunnel()
stargate.tunnelReplies(identifier: "stargate2")
```### On the watch
Send and receive messages via Darwin notifications:
```swift
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](Example/) 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][6] as host for the
WatchKit extension.## License
Copyright (c) 2015 Contentful GmbH. See [LICENSE](LICENSE) for further details.
[1]: https://github.com/mutualmobile/MMWormhole
[2]: https://github.com/jpsim/PeerKit
[4]: http://cocoapods.org
[5]: http://blog.cocoapods.org/CocoaPods-0.37/
[6]: http://openradar.appspot.com/radar?id=4975391517179904