Swiftpack.co -  dingwilson/MultiPeer as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
📱📲 A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices
.package(url: "https://github.com/dingwilson/MultiPeer.git", from: "0.2.0")

Build Status CocoaPods Version Status Carthage compatible doccov iOS MacOS tvOS Swift MIT License

A wrapper for Apple's MultipeerConnectivity framework for offline data transmission between Apple devices. This framework makes it easy to automatically connect to multiple nearby devices and share information using either bluetooth or wifi radios.

  1. Features
  2. Integration
  3. Usage
  4. Example
  5. License
  6. Authors


  • ☑ Supports iOS/macOS/tvOS
  • ☑ Auto Connection
  • ☑ Auto Invitations/Advertising
  • ☑ Send/Receive data via MultipeerConnectivity Framework
  • ☑ Specify data types for easy handling



You can use CocoaPods to install MultiPeer by adding it to your Podfile:

pod 'MultiPeer'


You can use Carthage to install MultiPeer by adding it to your Cartfile:

github "dingwilson/MultiPeer"

Swift Package Manager

For SPM, add the following to your package dependencies:

.package(url: "https://github.com/dingwilson/MultiPeer.git", .upToNextMinor(from: "0.0.0"))


To get started, import MultiPeer.

import MultiPeer

Then, simply initialize MultiPeer with the name of your session (serviceType). There are two modes of connections (advertiser and browser). To utilize both, simply use .autoConnect().

MultiPeer.instance.initialize(serviceType: "demo-app")

Any data transmitted by MultiPeer will always be accompanied by a numerical "type", to ensure other peers know what kind of data is being received, and how to properly process it. You can manage this by creating a UInt32 enum, as shown below:

enum DataType: UInt32 {
  case string = 1
  case image = 2
  // ...

To send data, simply use the .send(object: type:) function:

MultiPeer.instance.send(object: "Hello World!", type: DataType.string.rawValue)

To receive data, we must conform to the MultiPeerDelegate protocol:

func multiPeer(didReceiveData data: Data, ofType type: UInt32, from peerID: MCPeerID) {
  switch type {
    case DataType.string.rawValue:
      let string = data.convert() as! String
      // do something with the received string
    case DataType.image.rawValue:
      let image = UIImage(data: data)
      // do something with the received UIImage

func multiPeer(connectedDevicesChanged devices: [String]) {

Ensure that you set the MultiPeer delegate.

MultiPeer.instance.delegate = self

Finally you'll need to enable incoming / outgoing connections in your entitlements.

Congratulations! You have successfully sent data using MultiPeer! For more detailed information (including details of other functions), please see the docs.


For an example app using MultiPeer, checkout MultiPeer_Sample.


MultiPeer is released under an MIT License. See LICENSE for details.


Project heavily inspired by Apple-Signal.


Stars: 176
Last commit: 9 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API