Home

Awesome

WARNING: Unsupported now. Maintainer needed.

EJDB2Swift

EJDB2 Swift language binding

https://github.com/Softmotions/EJDB2Swift

import EJDB2

let db = try EJDB2Builder("example.db").withTruncate().open()

var id = try db.put("parrots", ["name": "Bianca", "age": 4])
print("Bianca record: \(id)")

id = try db.put("parrots", ["name": "Darko", "age": 8])
print("Bianca record: \(id)")

try db.createQuery("@parrots/[age > :?]").setInt64(0, 3).list().forEach({
  print("Found \($0)")
})

try? db.close()

Code examples:

OSX / Linux

Prerequisites

Setup

On OSX/Linux EJDB2 available as package for Swift package manager In order to use swift binding you should install system wide libejdb2 library with pkgconfig supplied.

On OSX

brew install ejdb

In another case you can build it manually with cmake

git clone https://github.com/Softmotions/ejdb
cd ./ejdb
git submodule update --init

mkdir ./build && cd ./build
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_HTTP=ON
make
sudo make install

Check all is ok:

git clone https://github.com/Softmotions/EJDB2Swift
cd ./EJDB2Swift

swift test

Now you are able to use swift binding on OSX/Linux.

iOS

iOS Prerequisites

Checkout example todo-list app https://github.com/Softmotions/EJDB2IOSExample

iOS Carthage

  1. Create Cartfile with the following content
    github "Softmotions/EJDB2Swift"
    
  2. Open your project XCode settings, navigate to: Build settings of your target then set
    • Header search paths to $(PROJECT_DIR)/Carthage/Checkouts/EJDB2Swift/include
    • Framework search paths to $(PROJECT_DIR)/Carthage/Build/iOS
  3. Run carthage update --verbose
  4. Then follow usual carthage project setup instructions.

Sample EJDB2 iOS app with Carthage

iOS Cocoapods

Setup Podfile like this:

platform :ios, '9.0'

target 'EJDB2ExampleApp' do
  use_frameworks!
  pod "EJDB2"
end
pod install --verbose

Initial build takes some time - be patient

Sample EJDB2 iOS app with Cocoapods