Swiftpack.co - yechentide/LvDBWrapper as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by yechentide.
yechentide/LvDBWrapper v1.2.0
A Objective-C++ wrapper for leveldb.
⭐️ 0
🕓 38 weeks ago
iOS macOS
.package(url: "https://github.com/yechentide/LvDBWrapper.git", from: "v1.2.0")

LvDBWrapper

A Objective-C++ wrapper for leveldb.

Usage

Package.swift
(you can also use SPM from Xcode)

let package = Package(
    name: "Demo",
    platforms: [
        .macOS(.v12),
        .iOS(.v12)
    ],
    products: [
        .executable(name: "demo", targets: ["Demo"]),
    ],
    dependencies: [
        .package(url: "https://github.com/yechentide/LvDBWrapper", branch: "main")
    ],
    targets: [
        .executableTarget(name: "Demo", dependencies: [
            .product(name: "LvDBWrapper", package: "LvDBWrapper")
        ]),
    ]
)

import & use

import LvDBWrapper

guard let db = LvDB(dbPath: "db-dir-path") else { ... }

let wellKnownKey = "~local_player".data(using: .utf8)!
db.seek(wellKnownKey)
guard let key = db.key(), let value = db.value() else { return }

var firstToLastCount = 0
db.seekToFirst()
while db.valid() {
    firstToLastCount += 1
    db.next()
}

Support

This package wrapped 2 kind of c++ libraries: libz & libleveldb.
Each xcframework contains 3 static .a files for iOS(arm64), MacOS(arm64), Simulator(arm64).

iOS(arm64) MacOS(arm64) MacOS(x86) Simulator(arm64) Simulator(x86)
libz.xcframework ✔︎ ✔︎ ✔︎ ✔︎ ×
libleveldb.xcframework ✔︎ ✔︎ ✔︎ ✔︎ ×

attention

For MacOS projects, you can use this package directly.

For iOS projects, you need to do some additional work.
The static libraries for iOS platform, are built with my personal apple team account.
Maybe my account will expire some day and I can't and won't offer any guarantees.
So if your projects is for iOS, you must rebuild libz.a and libleveldb.a for iOS.
In this case, please replace the following files:
frameworks/libz.xcframework/ios-arm64/libz.a
frameworks/libleveldb.xcframework/ios-arm64/libleveldb.a

Build XCFramework yourself

Just run the script and add teams or change the minimum version when needed. It's so easy!

git clone https://github.com/yechentide/LvDBWrapper.git
cd LvDBWrapper/scripts
chmod u+x build.sh
./build.sh

After you get the xcframeworks, you can fork this repository, and swap xcframeworks in frameworks directory.

GitHub

link
Stars: 0
Last commit: 38 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

v1.2.0
38 weeks ago

New wrapper class for leveldb iterator

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