Skip to content

Repository files navigation

Pigeon

Pigeon is a lightweight Swift framework that enables seamless communication between your main iOS app and its extensions through various transport methods.

Features

  • 🔄 Bidirectional communication between app and extensions
  • 📦 Multiple data transport options:
    • File-based communication
    • Coordinated file handling
    • WatchConnectivity session support (iOS 11.0+)
  • 💪 Type-safe message passing
  • 🔍 Easy message listening and handling
  • ⚡️ Darwin notification support for real-time updates

Requirements

  • iOS 12.0+ / watchOS 4.0+ / macOS 10.13+ / tvOS 12.0+
  • Swift 5.10+
  • Xcode 15+

Installation

Swift Package Manager

Add the following to your Package.swift file:

dependencies:[.package(url:"https://github.com/CodingIran/Pigeon.git", from:"0.0.7")]

Usage

Basic Setup

  1. First, configure your app group identifier in your project capabilities.

  2. Initialize Pigeon:

letpigeon=Pigeon(applicationGroupIdentifier:"group.com.your.app")

Sending Messages

// Send a message
try pigeon.passMessage("Hello Extensions!", for:"greeting")
// Send with reply handler
try pigeon.passMessage("Ping", for:"ping"){ reply inprint("Received reply: \(reply ??"no reply")")}

Listening for Messages

// Start listening
pigeon.listenMessage(for:"greeting"){ message, reply inprint("Received: \(message ??"no message")")
// Send reply if needed
try?reply("Message received!")}
// Stop listening
pigeon.stopListeningMessage(for:"greeting")

Transport Types

Pigeon supports multiple transport types:

// File-based transport (default)
letpigeon=Pigeon(applicationGroupIdentifier:"group.com.your.app", transitingType:.file)
// Coordinated file transport
letpigeon=Pigeon(applicationGroupIdentifier:"group.com.your.app", transitingType:.coordinatedFile)
// WatchConnectivity session transport (iOS 11.0+)
letpigeon=Pigeon(applicationGroupIdentifier:"group.com.your.app", transitingType:.sessionMessage)

Message Cleanup

// Clear specific message
try pigeon.clearMessageContents(for:"greeting")
// Clear all messages
try pigeon.clearAllMessageContents()

Error Handling

Pigeon provides detailed error handling through Pigeon.Error:

  • applicationGroupIdentifierNotConfigured
  • messageIdentifierInvalid
  • sessionUnReachable
  • fileCoordinatorFailed

License

MIT License

Author

CodingIran@gmail.com

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Pigeon is a lightweight Swift framework that enables seamless communication between your main iOS app and its extensions.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages