MessagePack
A MessagePack encoder and decoder for Codable types
Install / Use
/learn @Flight-School/MessagePackREADME
MessagePack
A MessagePack encoder and decoder for Codable types.
This functionality is discussed in Chapter 7 of Flight School Guide to Swift Codable.
Requirements
- Swift 4.2+
Usage
Encoding Messages
import MessagePack
let encoder = MessagePackEncoder()
let value = try! encoder.encode(["a": 1, "b": 2, "c": 3])
// [0x83, 0xA1, 0x62, 0x02, 0xA1, 0x61, 0x01, 0xA1, 0x63, 0x03]
Decoding Messages
import MessagePack
let decoder = MessagePackDecoder()
let data = Data(bytes: [0xCB, 0x40, 0x09, 0x21, 0xF9, 0xF0, 0x1B, 0x86, 0x6E])
let value = try! decoder.decode(Double.self, from: data)
// 3.14159
Installation
Swift Package Manager
Add the MessagePack package to your target dependencies in Package.swift:
import PackageDescription
let package = Package(
name: "YourProject",
dependencies: [
.package(
url: "https://github.com/Flight-School/MessagePack",
from: "1.2.3"
),
]
)
Then run the swift build command to build your project.
CocoaPods
You can install MessagePack via CocoaPods,
by adding the following line to your Podfile:
pod 'MessagePack-FlightSchool', '~> 1.2.4'
Run the pod install command to download the library
and integrate it into your Xcode project.
Note The module name for this library is "MessagePack" --- that is, to use it, you add
import MessagePackto the top of your Swift code just as you would by any other installation method. The pod is called "MessagePack-FlightSchool" because there's an existing pod with the name "MessagePack".
License
MIT
Contact
Mattt (@mattt)
Related Skills
node-connect
341.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
