A peer to peer framework for OS X, iOS and watchOS 2 that presents a similar interface to the MultipeerConnectivity framework

Overview

CocoaMultipeer

Latest Release Build Status License Platform

Introduction

This repository is a peer to peer framework for OS X, iOS and watchOS 2 that presents a similar interface to the MultipeerConnectivity framework (which is iOS only) that lets you connect any 2 devices from any platform. This framework works with peer to peer networks like bluetooth and ad hoc wifi networks when available it also falls back onto using a wifi router when necessary. It is built on top of CFNetwork and NSNetService. It uses the newest Swift 2's features like error handling and protocol extensions.

Why build this?

With Apple introducing features like continuity and handoff, being able to stream data back and forth between devices would be a natural next step. Using airdrop like technology this allows you to send NSData instances back and forth between connected peers using NSStreams for output and input. This is easy to setup, literally 0 configuration and easy to send and recieve data. It is thread safe and never blocks the main thread by using callbacks to a delegate. It also includes a default UI for the interfaces so that its super easy to just plug and play and start sending your data. The best part about this is that it even supports peer to peer networks so data can be sent really fast instead of sending it over onto the internet using services like iCloud, Dropbox or even a web server. The high level of abstraction provides a great interface for any app developer.

Installation

Download Beta Frameworks

This framework is now in beta most of the functionality that will be present in the first official release is now present in this beta. The framework will leave beta as soon as Xcode 7 is officially released. Cocoapods support will come with the first release. To test and try out the beta you can download all the frameworks from here. After downloading the frameworks, drag the ones you want into your xcode project and make sure that the Copy Items if needed is checked and no targets are checked. Then, go into each target you want to add the framework in the xcode project file and under General -> Embedded Binaries click the plus and select the relevant framework. For instance for an iOS app choose the CocoaMultipeeriOS.framework. Doing this will ensure that the files are properly installed. Then finally, import it in the Swift or Objective C files you wish to as follows:

import CocoaMultipeeriOS // or Mac or WatchOS depending on the target.
@import CocoaMultipeeriOS; // or Mac, or WatchOS depending on the target.

Features

Note this framework is still under development and is not complete yet. Here's a list of completed features and expected soon features:

  • Session, Peer and Browser objects to interact with the API as expected.
  • Properties on the above objects to allow for introspection and customization.
  • Header docs for all public methods and variables that you should be interacting with.
  • Objective-C and Swift support
  • Zero-conf browser and invitations.
  • Error handling availability
  • Assertions and fatal errors for weird unusual circumstances so that you can trace the stack.
  • Thread safety and non-blocking (through the use of delegates)
  • iOS Browser and Advertieser UI which handles everything from accepting invitations to showing available connections.
  • Mac OS X Browser and Advertieser UI which handles everything from accepting invitations to showing available connections.
  • watchOS 2 sample code which shows you how to accept invitations, recieve and send data to available peers. Note: Using the watch as a server is currently unsupported due to hardware limitations presented by the watch. Using the frameworks it is programmatically possible to let the watch behave as a server however, I highly do not recommend you do this because of the unpredicitability of termination of watch apps.
  • Example of how to use the frameworks. Currently, the xcode project does have a Demos folder with Watch, iOS and Mac targets which have enough code to get you started using these frameworks however, they are not as well developed as they can be and will be fully commented and better coded in the first official release of the framework.
  • Test cases

Comparison To Apple's MultipeerConnectivity framework

Here's a list of differences between this framework and Apple's framework. In general I tried to make it as easy as posisble to port code using Apple's framework to this one. For the most part everything else is similar to Apple's framework and has similar features.

What we have?

  • Supports all platforms.
  • Single interface for client and server so no need to ask the user to choose whether they want to be the host or the client. In general, the way the framework works is everyone is a host and a client. If the device accepts a connection, it stops being a host and becomes a client.
  • Easy to setup and use quickly.

What we don't have?

  • No direct file transferring capability
  • No encryption support in this framework
  • No Reliable and Unreliable modes
  • No custom browsing logic using C CoreFoundation APIs - we do all the browsing for you and expose you to the found/lost peers using the delegate's methods.

P.S. Hopefully I can add support for these features in the near future.

How To Use - API

If you are stuck anywhere check out Apple's MultipeerConnectivity framework reference. This framework closely resembles that one and in fact it is possible to port almost all your code from using that framework to this one by simply changing the prefix from MC to MG. The major differences between the two frameworks is listed above. With the official release, this section will be fleshed out a bit more but for now you can check out the demos and use the header docs to understand how the framework works.

License

Licensed under the Apache License. See the LICENSE file for more details.

Conclusion

Want to contribute to this project? Make a pull request. Facing a problem? Report an issue. If you want to show your love for this project star it, clone it or even fork it.

Comments
  • Can't run iOS app on iPad.

    Can't run iOS app on iPad.

    When I attempt to run the iOS app on an iPad I get the following:

    MultipeerCocoaiOS/MGBrowserTableViewController.swift: 17: 22: fatal error: use of unimplemented initializer 'init(nibName:bundle:)' for class 'MultipeerCocoaiOS.MGBrowserTableViewController'

    opened by pkclsoft 3
  • Official Release

    Official Release

    Dear Manav,

    Wanted to check if you plan to release a production version of CocoaMultipeer anytime soon :)

    Alternatively, is the Beta version good enough to be used in production iOS apps?

    Thanks much. Krishna

    opened by krishnamurthy80 0
  • Unable to run Demo on iOS 8.x

    Unable to run Demo on iOS 8.x

    This is related to the issue #2 that you closed already. It turns out that the problem was not iPad specific; rather it is a problem with the subclassing of UITableViewController. See the link below for a description of the problem. I don't know how to fix it.

    http://petersteinberger.com/blog/2015/uitableviewcontroller-designated-initializer-woes/

    opened by pkclsoft 0
  • Enhancement: Support raw NSData, not just JSON

    Enhancement: Support raw NSData, not just JSON

    Having integrated the common code into a project in which I need to transmit binary data via NSData objects, the data is all being thrown away as the framework is expecting JSON only data.

    I think, to be a truly useful, flexible framework it needs to support more than just JSON as a message package.

    opened by pkclsoft 4
  • Won't build.

    Won't build.

    I've opened the project in Xcode 7 or 7.1, and attempted to build the iOS app (I'd like to see the framework functioning before I try integrating it).

    I am unable to build because when Xcode tries to build the MultipeerCocoaWatchOS framework (presumably for the Watch app), it fails with errors on every reference to NSNetService, as if Foundation isn't available.

    screen shot 2015-09-20 at 3 48 02 pm bug 
    opened by pkclsoft 5
Releases(v0.0.1-beta)
Owner
Manav Gabhawala
Manav Gabhawala
A testable RxSwift wrapper around MultipeerConnectivity

A testable RxSwift wrapper around MultipeerConnectivity

RxSwift Community 69 Jul 5, 2022
Lightweight Networking and Parsing framework made for iOS, Mac, WatchOS and tvOS.

NetworkKit A lightweight iOS, Mac and Watch OS framework that makes networking and parsing super simple. Uses the open-sourced JSONHelper with functio

Alex Telek 30 Nov 19, 2022
A delightful networking framework for iOS, macOS, watchOS, and tvOS.

AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the Foundation URL Loading System, extending t

AFNetworking 33.3k Jan 5, 2023
🌏 A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.

A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications. ?? TermiNetwork was tested in a produc

Bill Panagiotopoulos 90 Dec 17, 2022
QwikHttp is a robust, yet lightweight and simple to use HTTP networking library for iOS, tvOS and watchOS

QwikHttp is a robust, yet lightweight and simple to use HTTP networking library. It allows you to customize every aspect of your http requests within a single line of code, using a Builder style syntax to keep your code super clean.

Logan Sease 2 Mar 20, 2022
A new, clean and lean network interface reachability library written in Swift.

Reachability A new, clean and lean network interface reachability library written in Swift. Remarks Network reachability changes can be monitored usin

Alecrim 7 Aug 8, 2022
Setup your class structure in Xcode Interface Builder and save() in Parse Server.

ISParseBind With ISParseBind you can save, update and query PFObjects using the power of Xcode Interface Builder resources. https://www.youtube.com/wa

Weni 10 Mar 28, 2022
SwiftyReachability is a simple and lightweight network interface manager written in Swift.

SwiftyReachability is a simple and lightweight network interface manager written in Swift. Freely inspired by https://github.com/tonymillion/Reachabil

Antonio Guerra 5 Nov 4, 2022
WKZombie is an iOS/OSX web-browser without a graphical user interface.

WKZombie is a Swift framework for iOS/OSX to navigate within websites and collect data without the need of User Interface or API, also known as Headless browser. It can be used to run automated tests / snapshots and manipulate websites using Javascript.

Mathias Köhnke 1.1k Dec 16, 2022
SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)

SwiftSoup is a pure Swift library, cross-platform (macOS, iOS, tvOS, watchOS and Linux!), for working with real-world HTML. It provides a very conveni

Nabil Chatbi 3.7k Dec 28, 2022
ZeroMQ Swift Bindings for iOS, macOS, tvOS and watchOS

SwiftyZeroMQ - ZeroMQ Swift Bindings for iOS, macOS, tvOS and watchOS This library provides easy-to-use iOS, macOS, tvOS and watchOS Swift bindings fo

Ahmad M. Zawawi 60 Sep 15, 2022
Lightweight REST library for iOS and watchOS. Available on cococapods

RMHttp RMHttp is a Lightweight REST library for iOS and watchOS. Features Chainable Request URL / JSON Parameter Encoding HTTP Methods GET/POST/DELETE

Roger Molas 7 Nov 19, 2022
A networking library for iOS, macOS, watchOS and tvOS

Thunder Request Thunder Request is a Framework used to simplify making http and https web requests. Installation Setting up your app to use ThunderBas

3 SIDED CUBE 16 Nov 19, 2022
Apple watch app to interface with Transmission Client

TransmissionWatch Apple watch app to interface with Transmission Client Currrent

Aayush 2 Dec 23, 2021
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and more…)

Perfect: Server-Side Swift 简体中文 Perfect: Server-Side Swift Perfect is a complete and powerful toolbox, framework, and application server for Linux, iO

PerfectlySoft Inc. 13.9k Jan 6, 2023
RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X

RestKit RestKit is a modern Objective-C framework for implementing RESTful web services clients on iOS and Mac OS X. It provides a powerful object map

The RestKit Project 10.2k Dec 29, 2022
Shawn Frank 2 Aug 31, 2022
OAuth2 framework for macOS and iOS, written in Swift.

OAuth2 OAuth2 frameworks for macOS, iOS and tvOS written in Swift 5.0. ⤵️ Installation ?? Usage ?? Sample macOS app (with data loader examples) ?? Tec

Pascal Pfiffner 1.1k Jan 8, 2023
Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.

BlueSocket Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux. Prerequisites Swift Swift Open Source swift-5.1

Kitura 1.3k Dec 26, 2022