WCDB is a cross-platform database framework developed by WeChat.
中文版本请参看这里
WCDB is an efficient, complete, easy-to-use mobile database framework used in the WeChat application. It's currently available on iOS, macOS and Android.
WCDB for iOS/macOS
Features
Easy-to-use. Through WCDB, you can get objects from database in one line code.
WINQ (WCDB language integrated query): WINQ is a native data querying capability which frees developers from writing glue code to concatenate SQL query strings.
ORM (Object Relational Mapping): WCDB provides a flexible, easy-to-use ORM for creating tables, indices and constraints, as well as CRUD through ObjC objects.
[database getObjectsOfClass:WCTSampleConvenient.class fromTable:tableName where:WCTSampleConvenient.intValue>=10 limit:20];
Efficient. Through the framework layer and sqlcipher source optimization, WCDB have more efficient performance.
- Multi-threaded concurrency: WCDB supports concurrent read-read and read-write access via connection pooling.
- Batch Write Performance Test.
For more benchmark data, please refer to our benchmark.
Complete.
- Encryption Support: WCDB supports database encryption via SQLCipher.
- Corruption recovery: WCDB provides a built-in repair kit for database corruption recovery.
- Anti-injection: WCDB provides a built-in protection from SQL injection.
Getting Started
Prerequisites
- Apps using WCDB can target: iOS 7 or later, macOS 10.9 or later.
- Xcode 8.0 or later required.
- Objective-C++ required.
Installation
- Via Cocoapods:
- Install CocoaPods.
- Run
pod repo updateto make CocoaPods aware of the latest available WCDB versions. - In your Podfile, add
pod 'WCDB'to your app target. - From the command line, run
pod install. - Use the
.xcworkspacefile generated by CocoaPods to work on your project. - Add
#import <WCDB/WCDB.h>at the top of your Objective-C++ source files and start your WCDB journey. - Since WCDB is an Objective-C++ framework, for those files in your project that includes WCDB, you should rename their extension
.mto.mm.
- Via Carthage:
- Install Carthage.
- Add
github "Tencent/WCDB"to your Cartfile. - Run
carthage update. - Drag
WCDB.frameworkfrom the appropriate platform directory inCarthage/Build/to theLinked Binary and Librariessection of your Xcode project’sBuild Phasessettings. - On your application targets'
Build Phasessettings tab, click the "+" icon and chooseNew Run Script Phase. Create a Run Script withcarthage copy-frameworksand add the paths to the frameworks underInput Files:$(SRCROOT)/Carthage/Build/iOS/WCDB.frameworkor$(SRCROOT)/Carthage/Build/Mac/WCDB.framework. - Add
#import <WCDB/WCDB.h>at the top of your Objective-C++ source files and start your WCDB journey. - Since WCDB is an Objective-C++ framework, for those files in your project that includes WCDB, you should rename their extension
.mto.mm.
- Via Dynamic Framework: Note that Dynamic frameworks are not compatible with iOS 7. See “Static Framework” for iOS 7 support.
- Getting source code from git repository and update the submodule of sqlcipher.
git clone https://github.com/Tencent/wcdb.gitcd wcdbgit submodule update --init sqlcipher
- Drag
WCDB.xcodeprojinwcdb/apple/into your project. - Add
WCDB.frameworkto theEnbedded Binariessection of your Xcode project'sGeneral settings. Note that there are two frameworks here and the dynamic one should be chosen. You can check it atBuild Phases->Target Dependencies. The right one isWCDBwhile `WCDB iOS Static is used for static lib. - Add
#import <WCDB/WCDB.h>at the top of your Objective-C++ source files and start your WCDB journey. - Since WCDB is an Objective-C++ framework, for those files in your project that includes WCDB, you should rename their extension
.mto.mm.
- Getting source code from git repository and update the submodule of sqlcipher.
- Via Static Framework:
- Getting source code from git repository and update the submodule of sqlcipher.
git clone https://github.com/Tencent/wcdb.gitcd wcdbgit submodule update --init sqlcipher
- Drag
WCDB.xcodeprojinwcdb/apple/into your project. - Add
WCDB iOS Staticto theTarget Dependenciessection of your Xcode project'sBuild Phasessettings. - Add
WCDB.framework,libz.tbdto theLinked Binary and Librariessection of your Xcode project'sBuild Phasessettings. Note that there are twoWCDB.framework, you should choose the one fromWCDB iOS Statictarget. - Add
-all_loadand-ObjCto theOther Linker Flagssection of your Xcode project'sBuild Settings. - Add
#import <WCDB/WCDB.h>at the top of your Objective-C++ source files and start your WCDB journey. - Since WCDB is an Objective-C++ framework, for those files in your project that includes WCDB, you should rename their extension
.mto.mm.
- Getting source code from git repository and update the submodule of sqlcipher.
Tutorials
Tutorials can be found here.
Documentations
- Documentations can be found on our Wiki.
- API references for iOS/macOS can be found here.
- Performance data can be found on our benchmark.
You have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site.
ReplyDeletecoin mining