Add SPM support: vendored leveldb 1.22.5, wrapper kept verbatim MRC via -fno-objc-arc#2
Open
damian-kolasinski wants to merge 1 commit into
Open
Add SPM support: vendored leveldb 1.22.5, wrapper kept verbatim MRC via -fno-objc-arc#2damian-kolasinski wants to merge 1 commit into
damian-kolasinski wants to merge 1 commit into
Conversation
damian-kolasinski
force-pushed
the
spm-support
branch
from
July 18, 2026 20:03
642e5c9 to
d970405
Compare
damian-kolasinski
force-pushed
the
spm-support
branch
from
July 18, 2026 20:08
d970405 to
ea2c9ae
Compare
- Add Package.swift (swift-tools-version 5.9, iOS 15) exposing the Objective-LevelDB library product built from the Objective_LevelDB target (module name matches what CocoaPods generated, so existing #import <Objective_LevelDB/...> spellings keep working). - Vendor Google's leveldb under vendor/leveldb from https://github.com/firebase/leveldb tag CocoaPods-1.22.5 (the exact source tree the leveldb-library CocoaPods pod is built from), excluding tests, benchmarks and Windows-specific files. Built as the LevelDBLibrary target with the same defines as the pod (LEVELDB_PLATFORM_POSIX, LEVELDB_IS_BIG_ENDIAN=0, HAVE_FULLFSYNC=1). - Keep the wrapper sources verbatim MRC: ARC is disabled for the Objective_LevelDB target via cSettings unsafeFlags -fno-objc-arc (same pattern as appunite/protobuf), which means the package must be consumed by revision/branch, not by version. Podspec is untouched. - One bug fix: initWithPath:name:andOptions: stored the name and path ivars without retaining them (direct ivar assignment bypasses the retain property setters), leaving _name/_path dangling once the caller's strings are released. Now retained on init and released in dealloc. - Add Classes/include/Objective_LevelDB forwarding public headers, including an Objective-LevelDB-umbrella.h that mirrors the CocoaPods-generated umbrella header. Claude-Session: https://claude.ai/code/session_01LTj6vGgu7NmTs7bjupWAGh
damian-kolasinski
force-pushed
the
spm-support
branch
from
July 18, 2026 20:56
ea2c9ae to
c9b1277
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Swift Package Manager support so consumers (KingsChat iOS) can drop both the
Objective-LevelDBandleveldb-libraryCocoaPods — while keeping the wrapper sources verbatim MRC, byte-identical to master apart from exactly one bug fix.What's inside
Package.swift
cxxLanguageStandard: .gnucxx14.Objective-LevelDBbuilt from targetObjective_LevelDB. The target/module name deliberately matches the module name CocoaPods generated for this pod, so existing imports keep working unchanged:#import <Objective_LevelDB/LevelDB.h>#import <Objective_LevelDB/Objective-LevelDB-umbrella.h>(a matching umbrella header is shipped in the public headers)cSettings: [.unsafeFlags(["-fno-objc-arc"])]— the same pattern as appunite/protobuf, proven to work through Tuist with revision pinning. Because of the unsafe flag, this package can only be consumed by revision/branch, not by semver version.LevelDBLibrary: the vendored leveldb C++ library. It is intentionally NOT namedleveldbto avoid an SPM target-name collision withfirebase/leveldbwhen both packages end up in the same dependency graph (e.g. alongside firebase-ios-sdk).Vendored leveldb (
vendor/leveldb)CocoaPods-1.22.5(commita0bc79961d7be727d258d33d5a6b2f1023270ba1) — the exact tree theleveldb-libraryCocoaPods pod (resolved as 1.22.5 by consumers today) is built from; upstream leveldb 1.22 plus Firebase's build patches.db/leveldbutil.cc, Windows-specific files (env_windows*,windows_logger.h),db/c_test.c.LEVELDB_PLATFORM_POSIX,LEVELDB_IS_BIG_ENDIAN=0,HAVE_FULLFSYNC=1, linkslibc++, ships the pod'sPrivacyInfo.xcprivacy.The single wrapper change (vs master)
Classes/LevelDB.mm,initWithPath:name:andOptions::_name = name;and_path = path;stored the ivars without retaining them (direct ivar assignment bypasses theretainproperty setters), leaving_name/_pathdangling once the caller's strings are released. Fixed MRC-style; the complete wrapper diff vs master:(master's dealloc never released either ivar, so the releases are added alongside.)
Everything else — all other wrapper sources, headers, and the podspec (
requires_arc = false, version 2.1.4) — is byte-identical to master;git diff master -- Classes Objective-LevelDB.podspecshows only the two hunks above plus the newClasses/include/shim headers.Validation
xcodebuild -scheme Objective-LevelDB -destination "generic/platform=iOS Simulator" build— succeeds (alsogeneric/platform=iOS).databaseInLibraryWithName:, encoder/decoder blocks,setObject:forKey:, key/object prefix enumeration andNSStringFromLevelDBKey.-fno-objc-arclands after Xcode's default-fobjc-arcon the wrapper compile commands (last flag wins); MRC constructs like[super dealloc]would be hard compile errors under ARC, so the successful build is itself proof ARC is off.https://claude.ai/code/session_01LTj6vGgu7NmTs7bjupWAGh