EJDB2Swift
EJDB2 Swift language binding
https://github.com/Softmotions/EJDB2Swift
- OSX
- iOS
- Linux
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 linux it can be accomplished by installing Debian ejdb2
package from ppa:adamansky/ejdb2
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
- cmake
- XCode
Checkout example todo-list app https://github.com/Softmotions/EJDB2IOSExample
iOS Carthage
- Create
Cartfile
with the following contentgithub "Softmotions/EJDB2Swift"
- 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
- Header search paths to
- Run
carthage update --verbose
- 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