iOS_setup

guoling edited this page Sep 19, 2018 · 2 revisions

MMKV for iOS

MMKV is an efficient, samll, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on iOS and Android.

Getting Started

Prerequisites

  • Apps using MMKV can target: iOS 8 or later.
  • Xcode 9.0 or later.

Installation

  • Via CocoaPods:
    1. Install CocoaPods;
    2. Open terminal, cd to your project directory, run pod repo update to make CocoaPods aware of the latest available MMKV versions;
    3. Edit your Podfile, add pod 'MMKV' to your app target;
    4. Run pod install;
    5. Open the .xcworkspace file generated by CocoaPods;
    6. Add #import <MMKV/MMKV.h> to your source file and we are done.
  • Via Carthage:
    1. Install Carthage;
    2. Edit your Cartfile, add github "Tencent/MMKV";
    3. Open terminal, cd to your project directory, run carthage update;
    4. Drag MMKV.framework from the appropriate platform directory in Carthage/Build/ to the Linked Binary and Libraries section of your Xcode project’s Build Phases settings;
    5. On your application target's Build Phases settings tab, click the "+" icon and choose New Run Script Phase. Create a Run Script with carthage copy-frameworks, add the paths to the framework under Input Files: $(SRCROOT)/Carthage/Build/iOS/MMKV.framework, and add the paths to the copied frameworks to the Output Files: $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/MMKV.framework;
    6. Add #import <MMKV/MMKV.h> to your source file and we are done.
  • Via Dynamic Framework:
    1. Getting source code from git repository:
      • git clone https://github.com/Tencent/MMKV.git
    2. Drag MMKV.xcodeproj in iOS/MMKV/ into your project;
    3. Add MMKV.framework to the Enbedded Binaries section of your Xcode project's General settings; Note that there are two frameworks here and the dynamic one should be chosen. You can check it at Build Phases->Target Dependencies. The right one is MMKV while MMKV Static is used for static lib.
    4. Add #import <MMKV/MMKV.h> to your source file and we are done.
  • Via Static Framework:
    1. Getting source code from git repository:
      • git clone https://github.com/Tencent/MMKV.git
    2. Drag MMKV.xcodeproj in iOS/MMKV/ into your project;
    3. Add MMKV Static to the Target Dependencies section of your Xcode project's Build Phases settings;
    4. Add libMMKV Static.alibz.tbd to the Linked Binary and Libraries section of your Xcode project's Build Phases settings;
    5. Add -all_load and -ObjC to the Other Linker Flags section of your Xcode project's Build Settings.
    6. Add #import <MMKV/MMKV.h> to your source file and we are done.

What's Next

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.