From b0d6d9da141609e30cbde029690b9b2814810159 Mon Sep 17 00:00:00 2001 From: Playhi <000902play@gmail.com> Date: Mon, 17 Jan 2022 16:13:47 +0800 Subject: [PATCH 01/12] Fix crash when using Ashmem when MMKV_DISABLE_CRYPT defined When MMKV_DISABLE_CRYPT is defined, still generate the method cryptKey but always returns nullptr. --- Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp b/Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp index a9d378e6..ca68970d 100644 --- a/Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp +++ b/Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp @@ -712,6 +712,12 @@ MMKV_JNI void checkReSetCryptKey(JNIEnv *env, jobject instance, jstring cryptKey } } +# else + +MMKV_JNI jstring cryptKey(JNIEnv *env, jobject instance) { + return nullptr; +} + # endif // MMKV_DISABLE_CRYPT MMKV_JNI void trim(JNIEnv *env, jobject instance) { @@ -841,8 +847,8 @@ MMKV_JNI jlong restoreAll(JNIEnv *env, jobject obj, jstring srcDir/*, jstring ro static JNINativeMethod g_methods[] = { {"onExit", "()V", (void *) mmkv::onExit}, -# ifndef MMKV_DISABLE_CRYPT {"cryptKey", "()Ljava/lang/String;", (void *) mmkv::cryptKey}, +# ifndef MMKV_DISABLE_CRYPT {"reKey", "(Ljava/lang/String;)Z", (void *) mmkv::reKey}, {"checkReSetCryptKey", "(Ljava/lang/String;)V", (void *) mmkv::checkReSetCryptKey}, # endif From 5ab8f23f0a5119d5db582b43a154df75ea2a66f2 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Fri, 28 Jan 2022 10:42:24 +0100 Subject: [PATCH 02/12] feat: `hasValue` out parameter --- Core/MMKV.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++----- Core/MMKV.h | 14 +++++----- 2 files changed, 77 insertions(+), 14 deletions(-) diff --git a/Core/MMKV.cpp b/Core/MMKV.cpp index ef717da7..be7567b1 100755 --- a/Core/MMKV.cpp +++ b/Core/MMKV.cpp @@ -607,8 +607,11 @@ bool MMKV::getVector(MMKVKey_t key, vector &result) { #endif // MMKV_APPLE -bool MMKV::getBool(MMKVKey_t key, bool defaultValue) { +bool MMKV::getBool(MMKVKey_t key, bool defaultValue, bool *hasValue) { if (isKeyEmpty(key)) { + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } SCOPED_LOCK(m_lock); @@ -616,16 +619,25 @@ bool MMKV::getBool(MMKVKey_t key, bool defaultValue) { if (data.length() > 0) { try { CodedInputData input(data.getPtr(), data.length()); + if (hasValue != nullptr) { + *hasValue = true; + } return input.readBool(); } catch (std::exception &exception) { MMKVError("%s", exception.what()); } } + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } -int32_t MMKV::getInt32(MMKVKey_t key, int32_t defaultValue) { +int32_t MMKV::getInt32(MMKVKey_t key, int32_t defaultValue, bool *hasValue) { if (isKeyEmpty(key)) { + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } SCOPED_LOCK(m_lock); @@ -633,16 +645,25 @@ int32_t MMKV::getInt32(MMKVKey_t key, int32_t defaultValue) { if (data.length() > 0) { try { CodedInputData input(data.getPtr(), data.length()); + if (hasValue != nullptr) { + *hasValue = true; + } return input.readInt32(); } catch (std::exception &exception) { MMKVError("%s", exception.what()); } } + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } -uint32_t MMKV::getUInt32(MMKVKey_t key, uint32_t defaultValue) { +uint32_t MMKV::getUInt32(MMKVKey_t key, uint32_t defaultValue, bool *hasValue) { if (isKeyEmpty(key)) { + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } SCOPED_LOCK(m_lock); @@ -650,16 +671,25 @@ uint32_t MMKV::getUInt32(MMKVKey_t key, uint32_t defaultValue) { if (data.length() > 0) { try { CodedInputData input(data.getPtr(), data.length()); + if (hasValue != nullptr) { + *hasValue = true; + } return input.readUInt32(); } catch (std::exception &exception) { MMKVError("%s", exception.what()); } } + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } -int64_t MMKV::getInt64(MMKVKey_t key, int64_t defaultValue) { +int64_t MMKV::getInt64(MMKVKey_t key, int64_t defaultValue, bool *hasValue) { if (isKeyEmpty(key)) { + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } SCOPED_LOCK(m_lock); @@ -667,16 +697,25 @@ int64_t MMKV::getInt64(MMKVKey_t key, int64_t defaultValue) { if (data.length() > 0) { try { CodedInputData input(data.getPtr(), data.length()); + if (hasValue != nullptr) { + *hasValue = true; + } return input.readInt64(); } catch (std::exception &exception) { MMKVError("%s", exception.what()); } } + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } -uint64_t MMKV::getUInt64(MMKVKey_t key, uint64_t defaultValue) { +uint64_t MMKV::getUInt64(MMKVKey_t key, uint64_t defaultValue, bool *hasValue) { if (isKeyEmpty(key)) { + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } SCOPED_LOCK(m_lock); @@ -684,16 +723,25 @@ uint64_t MMKV::getUInt64(MMKVKey_t key, uint64_t defaultValue) { if (data.length() > 0) { try { CodedInputData input(data.getPtr(), data.length()); + if (hasValue != nullptr) { + *hasValue = true; + } return input.readUInt64(); } catch (std::exception &exception) { MMKVError("%s", exception.what()); } } + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } -float MMKV::getFloat(MMKVKey_t key, float defaultValue) { +float MMKV::getFloat(MMKVKey_t key, float defaultValue, bool *hasValue) { if (isKeyEmpty(key)) { + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } SCOPED_LOCK(m_lock); @@ -701,16 +749,25 @@ float MMKV::getFloat(MMKVKey_t key, float defaultValue) { if (data.length() > 0) { try { CodedInputData input(data.getPtr(), data.length()); + if (hasValue != nullptr) { + *hasValue = true; + } return input.readFloat(); } catch (std::exception &exception) { MMKVError("%s", exception.what()); } } + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } -double MMKV::getDouble(MMKVKey_t key, double defaultValue) { +double MMKV::getDouble(MMKVKey_t key, double defaultValue, bool *hasValue) { if (isKeyEmpty(key)) { + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } SCOPED_LOCK(m_lock); @@ -718,11 +775,17 @@ double MMKV::getDouble(MMKVKey_t key, double defaultValue) { if (data.length() > 0) { try { CodedInputData input(data.getPtr(), data.length()); + if (hasValue != nullptr) { + *hasValue = true; + } return input.readDouble(); } catch (std::exception &exception) { MMKVError("%s", exception.what()); } } + if (hasValue != nullptr) { + *hasValue = false; + } return defaultValue; } diff --git a/Core/MMKV.h b/Core/MMKV.h index c01e9995..ebc37d06 100644 --- a/Core/MMKV.h +++ b/Core/MMKV.h @@ -253,19 +253,19 @@ class MMKV { bool getVector(MMKVKey_t key, std::vector &result); #endif // MMKV_APPLE - bool getBool(MMKVKey_t key, bool defaultValue = false); + bool getBool(MMKVKey_t key, bool defaultValue = false, bool *outHasValue = nullptr); - int32_t getInt32(MMKVKey_t key, int32_t defaultValue = 0); + int32_t getInt32(MMKVKey_t key, int32_t defaultValue = 0, bool *outHasValue = nullptr); - uint32_t getUInt32(MMKVKey_t key, uint32_t defaultValue = 0); + uint32_t getUInt32(MMKVKey_t key, uint32_t defaultValue = 0, bool *outHasValue = nullptr); - int64_t getInt64(MMKVKey_t key, int64_t defaultValue = 0); + int64_t getInt64(MMKVKey_t key, int64_t defaultValue = 0, bool *outHasValue = nullptr); - uint64_t getUInt64(MMKVKey_t key, uint64_t defaultValue = 0); + uint64_t getUInt64(MMKVKey_t key, uint64_t defaultValue = 0, bool *outHasValue = nullptr); - float getFloat(MMKVKey_t key, float defaultValue = 0); + float getFloat(MMKVKey_t key, float defaultValue = 0, bool *outHasValue = nullptr); - double getDouble(MMKVKey_t key, double defaultValue = 0); + double getDouble(MMKVKey_t key, double defaultValue = 0, bool *outHasValue = nullptr); // return the actual size consumption of the key's value // pass actualSize = true to get value's length From 781586db677eb0245462e4e5b1d83ab53de3f8b2 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Fri, 28 Jan 2022 10:45:59 +0100 Subject: [PATCH 03/12] Use `OUT` define for better function signature --- Core/MMKV.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Core/MMKV.h b/Core/MMKV.h index ebc37d06..32abe638 100644 --- a/Core/MMKV.h +++ b/Core/MMKV.h @@ -47,6 +47,8 @@ enum MMKVMode : uint32_t { #endif }; +#define OUT + class MMKV { #ifndef MMKV_ANDROID std::string m_mmapKey; @@ -253,19 +255,19 @@ class MMKV { bool getVector(MMKVKey_t key, std::vector &result); #endif // MMKV_APPLE - bool getBool(MMKVKey_t key, bool defaultValue = false, bool *outHasValue = nullptr); + bool getBool(MMKVKey_t key, bool defaultValue = false, OUT bool *hasValue = nullptr); - int32_t getInt32(MMKVKey_t key, int32_t defaultValue = 0, bool *outHasValue = nullptr); + int32_t getInt32(MMKVKey_t key, int32_t defaultValue = 0, OUT bool *hasValue = nullptr); - uint32_t getUInt32(MMKVKey_t key, uint32_t defaultValue = 0, bool *outHasValue = nullptr); + uint32_t getUInt32(MMKVKey_t key, uint32_t defaultValue = 0, OUT bool *hasValue = nullptr); - int64_t getInt64(MMKVKey_t key, int64_t defaultValue = 0, bool *outHasValue = nullptr); + int64_t getInt64(MMKVKey_t key, int64_t defaultValue = 0, OUT bool *hasValue = nullptr); - uint64_t getUInt64(MMKVKey_t key, uint64_t defaultValue = 0, bool *outHasValue = nullptr); + uint64_t getUInt64(MMKVKey_t key, uint64_t defaultValue = 0, OUT bool *hasValue = nullptr); - float getFloat(MMKVKey_t key, float defaultValue = 0, bool *outHasValue = nullptr); + float getFloat(MMKVKey_t key, float defaultValue = 0, OUT bool *hasValue = nullptr); - double getDouble(MMKVKey_t key, double defaultValue = 0, bool *outHasValue = nullptr); + double getDouble(MMKVKey_t key, double defaultValue = 0, OUT bool *hasValue = nullptr); // return the actual size consumption of the key's value // pass actualSize = true to get value's length From b6784a85ee6fdf32c62e51ffcc3ecc44935eab46 Mon Sep 17 00:00:00 2001 From: guoling Date: Tue, 8 Feb 2022 12:00:49 +0800 Subject: [PATCH 04/12] xcscheme --- .../WatchApp (Notification).xcscheme | 25 +++++-------------- .../xcshareddata/xcschemes/WatchApp.xcscheme | 25 +++++-------------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme index 8076c76a..ebdb58b8 100644 --- a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme +++ b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme @@ -56,10 +56,8 @@ allowLocationSimulation = "YES" launchAutomaticallySubstyle = "8" notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns"> - + - + - + - - - - - + diff --git a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme index a8e610b3..7d8c5b4b 100644 --- a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme +++ b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme @@ -54,10 +54,8 @@ debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> - + - + - + - - - - - + From d6ee1d940024290958d7680cf76155a920a1ca2d Mon Sep 17 00:00:00 2001 From: guoling Date: Wed, 9 Feb 2022 11:09:25 +0800 Subject: [PATCH 05/12] fix grammar --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7d4b9634..685215d3 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ MMKV is an **efficient**, **small**, **easy-to-use** mobile key-value storage fr ## Features -* **Efficient**. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of Android to achieve best performance. +* **Efficient**. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of Android to achieve the best performance. * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes. * **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `sync`, no `apply` calls needed. * **Small**. - * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics and nothing more. It's really tidy. - * **About 50K in binary size**: MMKV adds about 50K per architecture on App size, and much less when zipped (apk). + * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy. + * **About 50K in binary size**: MMKV adds about 50K per architecture on App size, and much less when zipped (APK). ## Getting Started @@ -78,19 +78,19 @@ For more benchmark data, please refer to [our benchmark](https://github.com/Tenc ## Features -* **Efficient**. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of iOS/macOS to achieve best performance. +* **Efficient**. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of iOS/macOS to achieve the best performance. -* **Easy-to-use**. You can use MMKV as you go, no configurations needed. All changes are saved immediately, no `synchronize` calls needed. +* **Easy-to-use**. You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no `synchronize` calls are needed. * **Small**. * **A handful of files**: MMKV contains encode/decode helpers and mmap logics and nothing more. It's really tidy. - * **Less than 30K in binary size**: MMKV adds less than 30K per architecture on App size, and much less when zipped (ipa). + * **Less than 30K in binary size**: MMKV adds less than 30K per architecture on App size, and much less when zipped (IPA). ## Getting Started ### Installation Via CocoaPods: 1. Install [CocoaPods](https://guides.CocoaPods.org/using/getting-started.html); - 2. Open terminal, `cd` to your project directory, run `pod repo update` to make CocoaPods aware of the latest available MMKV versions; + 2. Open the 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; @@ -99,7 +99,7 @@ For more benchmark data, please refer to [our benchmark](https://github.com/Tenc For other installation options, see [iOS/macOS Setup](https://github.com/Tencent/MMKV/wiki/iOS_setup). ### Quick Tutorial -You can use MMKV as you go, no configurations needed. All changes are saved immediately, no `synchronize` calls needed. +You can use MMKV as you go, no configurations are needed. All changes are saved immediately, no `synchronize` calls are needed. Setup MMKV on App startup, in your `-[MyApp application: didFinishLaunchingWithOptions:]`, add these lines: ```objective-c @@ -139,13 +139,13 @@ For more benchmark data, please refer to [our benchmark](https://github.com/Tenc ## Features -* **Efficient**. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of Windows to achieve best performance. +* **Efficient**. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of Windows to achieve the best performance. * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes. -* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls needed. +* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls are needed. * **Small**. - * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics and nothing more. It's really tidy. + * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy. * **About 10K in binary size**: MMKV adds about 10K on application size, and much less when zipped. @@ -168,7 +168,7 @@ For more benchmark data, please refer to [our benchmark](https://github.com/Tenc note: -1. MMKV is compiled with `MT/MTd` runtime by default. If your project uses `MD/MDd`, you should change MMKV's setting to match your project's (`C/C++` -> `Code Generation` -> `Runtime Library`), or vise versa. +1. MMKV is compiled with `MT/MTd` runtime by default. If your project uses `MD/MDd`, you should change MMKV's setting to match your project's (`C/C++` -> `Code Generation` -> `Runtime Library`), or vice versa. 2. MMKV is developed with Visual Studio 2017, change the `Platform Toolset` if you use a different version of Visual Studio. For other installation options, see [Win32 Setup](https://github.com/Tencent/MMKV/wiki/windows_setup). @@ -210,20 +210,20 @@ MMKV also supports **Multi-Process Access**. Full tutorials can be found here [W ## Features -* **Efficient**. MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values, making the most of POSIX to achieve best performance. +* **Efficient**. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of POSIX to achieve the best performance. * **Multi-Process concurrency**: MMKV supports concurrent read-read and read-write access between processes. -* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls needed. +* **Easy-to-use**. You can use MMKV as you go. All changes are saved immediately, no `save`, no `sync` calls are needed. * **Small**. - * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics and nothing more. It's really tidy. + * **A handful of files**: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy. * **About 7K in binary size**: MMKV adds about 7K on application size, and much less when zipped. ## Getting Started ### Installation Via CMake -1. Getting source code from git repository: +1. Getting source code from the git repository: ``` git clone https://github.com/Tencent/MMKV.git From 873a09854ed4f4a1bbae9037b0e35c0e0b4b23c1 Mon Sep 17 00:00:00 2001 From: guoling Date: Wed, 9 Mar 2022 17:02:13 +0800 Subject: [PATCH 06/12] protect from possibly misuse Key-value-coding interfaces --- iOS/MMKV/MMKV/MMKV.h | 4 +++ iOS/MMKV/MMKV/libMMKV.mm | 8 ++++++ .../WatchApp (Notification).xcscheme | 25 ++++++++++++++----- .../xcshareddata/xcschemes/WatchApp.xcscheme | 25 ++++++++++++++----- 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/iOS/MMKV/MMKV/MMKV.h b/iOS/MMKV/MMKV/MMKV.h index f818636a..a2641c66 100644 --- a/iOS/MMKV/MMKV/MMKV.h +++ b/iOS/MMKV/MMKV/MMKV.h @@ -96,6 +96,10 @@ NS_ASSUME_NONNULL_BEGIN /// otherwise the behavior is undefined + (void)setMMKVBasePath:(NSString *)basePath __attribute__((deprecated("use +initializeMMKV: instead", "+initializeMMKV:"))); +// protection from possible misuse +- (void)setValue:(nullable id)value forKey:(NSString *)key __attribute__((deprecated("use setObject:forKey: instead"))); +- (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath __attribute__((deprecated("use setObject:forKey: instead"))); + - (NSString *)mmapID; /// transform plain text into encrypted text, or vice versa by passing newKey = nil diff --git a/iOS/MMKV/MMKV/libMMKV.mm b/iOS/MMKV/MMKV/libMMKV.mm index f698bdbf..6f326edb 100644 --- a/iOS/MMKV/MMKV/libMMKV.mm +++ b/iOS/MMKV/MMKV/libMMKV.mm @@ -652,6 +652,14 @@ + (void)setMMKVBasePath:(NSString *)basePath { } } +- (void)setValue:(nullable id)value forKey:(NSString *)key { + [super setValue:value forKey:key]; +} + +- (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath { + [super setValue:value forKeyPath:keyPath]; +} + static NSString *md5(NSString *value) { uint8_t md[MD5_DIGEST_LENGTH] = {}; char tmp[3] = {}, buf[33] = {}; diff --git a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme index ebdb58b8..8076c76a 100644 --- a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme +++ b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp (Notification).xcscheme @@ -56,8 +56,10 @@ allowLocationSimulation = "YES" launchAutomaticallySubstyle = "8" notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns"> - + - + - + - + + + + + diff --git a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme index 7d8c5b4b..a8e610b3 100644 --- a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme +++ b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme @@ -54,8 +54,10 @@ debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> - + - + - + - + + + + + From 62e27cd5cfe2010212c9484aad07e56470aeac75 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Mon, 14 Mar 2022 12:13:35 +0100 Subject: [PATCH 07/12] feat: Implement OUT `hasValue` parameter for iOS --- iOS/MMKV/MMKV/MMKV.h | 12 ++++++++++ iOS/MMKV/MMKV/libMMKV.mm | 51 +++++++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/iOS/MMKV/MMKV/MMKV.h b/iOS/MMKV/MMKV/MMKV.h index f818636a..16936003 100644 --- a/iOS/MMKV/MMKV/MMKV.h +++ b/iOS/MMKV/MMKV/MMKV.h @@ -20,6 +20,8 @@ #import "MMKVHandler.h" +#define OUT + typedef NS_ENUM(NSUInteger, MMKVMode) { MMKVSingleProcess = 0x1, MMKVMultiProcess = 0x2, @@ -133,33 +135,43 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)getBoolForKey:(NSString *)key __attribute__((swift_name("bool(forKey:)"))); - (BOOL)getBoolForKey:(NSString *)key defaultValue:(BOOL)defaultValue __attribute__((swift_name("bool(forKey:defaultValue:)"))); +- (BOOL)getBoolForKey:(NSString *)key defaultValue:(BOOL)defaultValue hasValue:(OUT BOOL *)hasValue __attribute__((swift_name("bool(forKey:defaultValue:hasValue:)"))); - (int32_t)getInt32ForKey:(NSString *)key NS_SWIFT_NAME(int32(forKey:)); - (int32_t)getInt32ForKey:(NSString *)key defaultValue:(int32_t)defaultValue NS_SWIFT_NAME(int32(forKey:defaultValue:)); +- (int32_t)getInt32ForKey:(NSString *)key defaultValue:(int32_t)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(int32(forKey:defaultValue:hasValue:)); - (uint32_t)getUInt32ForKey:(NSString *)key NS_SWIFT_NAME(uint32(forKey:)); - (uint32_t)getUInt32ForKey:(NSString *)key defaultValue:(uint32_t)defaultValue NS_SWIFT_NAME(uint32(forKey:defaultValue:)); +- (uint32_t)getUInt32ForKey:(NSString *)key defaultValue:(uint32_t)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(uint32(forKey:defaultValue:hasValue:)); - (int64_t)getInt64ForKey:(NSString *)key NS_SWIFT_NAME(int64(forKey:)); - (int64_t)getInt64ForKey:(NSString *)key defaultValue:(int64_t)defaultValue NS_SWIFT_NAME(int64(forKey:defaultValue:)); +- (int64_t)getInt64ForKey:(NSString *)key defaultValue:(int64_t)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(int64(forKey:defaultValue:hasValue:)); - (uint64_t)getUInt64ForKey:(NSString *)key NS_SWIFT_NAME(uint64(forKey:)); - (uint64_t)getUInt64ForKey:(NSString *)key defaultValue:(uint64_t)defaultValue NS_SWIFT_NAME(uint64(forKey:defaultValue:)); +- (uint64_t)getUInt64ForKey:(NSString *)key defaultValue:(uint64_t)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(uint64(forKey:defaultValue:hasValue:)); - (float)getFloatForKey:(NSString *)key NS_SWIFT_NAME(float(forKey:)); - (float)getFloatForKey:(NSString *)key defaultValue:(float)defaultValue NS_SWIFT_NAME(float(forKey:defaultValue:)); +- (float)getFloatForKey:(NSString *)key defaultValue:(float)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(float(forKey:defaultValue:hasValue:)); - (double)getDoubleForKey:(NSString *)key NS_SWIFT_NAME(double(forKey:)); - (double)getDoubleForKey:(NSString *)key defaultValue:(double)defaultValue NS_SWIFT_NAME(double(forKey:defaultValue:)); +- (double)getDoubleForKey:(NSString *)key defaultValue:(double)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(double(forKey:defaultValue:hasValue:)); - (nullable NSString *)getStringForKey:(NSString *)key NS_SWIFT_NAME(string(forKey:)); - (nullable NSString *)getStringForKey:(NSString *)key defaultValue:(nullable NSString *)defaultValue NS_SWIFT_NAME(string(forKey:defaultValue:)); +- (nullable NSString *)getStringForKey:(NSString *)key defaultValue:(nullable NSString *)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(string(forKey:defaultValue:hasValue:)); - (nullable NSDate *)getDateForKey:(NSString *)key NS_SWIFT_NAME(date(forKey:)); - (nullable NSDate *)getDateForKey:(NSString *)key defaultValue:(nullable NSDate *)defaultValue NS_SWIFT_NAME(date(forKey:defaultValue:)); +- (nullable NSDate *)getDateForKey:(NSString *)key defaultValue:(nullable NSDate *)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(date(forKey:defaultValue:hasValue:)); - (nullable NSData *)getDataForKey:(NSString *)key NS_SWIFT_NAME(data(forKey:)); - (nullable NSData *)getDataForKey:(NSString *)key defaultValue:(nullable NSData *)defaultValue NS_SWIFT_NAME(data(forKey:defaultValue:)); +- (nullable NSData *)getDataForKey:(NSString *)key defaultValue:(nullable NSData *)defaultValue hasValue:(OUT BOOL *)hasValue NS_SWIFT_NAME(data(forKey:defaultValue:hasValue:)); // return the actual size consumption of the key's value // Note: might be a little bigger than value's length diff --git a/iOS/MMKV/MMKV/libMMKV.mm b/iOS/MMKV/MMKV/libMMKV.mm index f698bdbf..ca15eaf7 100644 --- a/iOS/MMKV/MMKV/libMMKV.mm +++ b/iOS/MMKV/MMKV/libMMKV.mm @@ -386,7 +386,10 @@ - (BOOL)getBoolForKey:(NSString *)key { return [self getBoolForKey:key defaultValue:FALSE]; } - (BOOL)getBoolForKey:(NSString *)key defaultValue:(BOOL)defaultValue { - return m_mmkv->getBool(key, defaultValue); + return [self getBoolForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (BOOL)getBoolForKey:(NSString *)key defaultValue:(BOOL)defaultValue hasValue:(OUT BOOL *)hasValue { + return m_mmkv->getBool(key, defaultValue, hasValue); } - (int32_t)getInt32ForKey:(NSString *)key { @@ -395,51 +398,75 @@ - (int32_t)getInt32ForKey:(NSString *)key { - (int32_t)getInt32ForKey:(NSString *)key defaultValue:(int32_t)defaultValue { return m_mmkv->getInt32(key, defaultValue); } +- (int32_t)getInt32ForKey:(NSString *)key defaultValue:(int32_t)defaultValue hasValue:(OUT BOOL *)hasValue { + return m_mmkv->getInt32(key, defaultValue, hasValue); +} - (uint32_t)getUInt32ForKey:(NSString *)key { return [self getUInt32ForKey:key defaultValue:0]; } - (uint32_t)getUInt32ForKey:(NSString *)key defaultValue:(uint32_t)defaultValue { - return m_mmkv->getUInt32(key, defaultValue); + return [self getUInt32ForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (uint32_t)getUInt32ForKey:(NSString *)key defaultValue:(uint32_t)defaultValue hasValue:(OUT BOOL *)hasValue { + return m_mmkv->getUInt32(key, defaultValue, hasValue); } - (int64_t)getInt64ForKey:(NSString *)key { return [self getInt64ForKey:key defaultValue:0]; } - (int64_t)getInt64ForKey:(NSString *)key defaultValue:(int64_t)defaultValue { - return m_mmkv->getInt64(key, defaultValue); + return [self getInt64ForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (int64_t)getInt64ForKey:(NSString *)key defaultValue:(int64_t)defaultValue hasValue:(OUT BOOL *)hasValue { + return m_mmkv->getInt64(key, defaultValue, hasValue); } - (uint64_t)getUInt64ForKey:(NSString *)key { return [self getUInt64ForKey:key defaultValue:0]; } - (uint64_t)getUInt64ForKey:(NSString *)key defaultValue:(uint64_t)defaultValue { - return m_mmkv->getUInt64(key, defaultValue); + return [self getUInt64ForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (uint64_t)getUInt64ForKey:(NSString *)key defaultValue:(uint64_t)defaultValue hasValue:(OUT BOOL *)hasValue { + return m_mmkv->getUInt64(key, defaultValue, hasValue); } - (float)getFloatForKey:(NSString *)key { return [self getFloatForKey:key defaultValue:0]; } - (float)getFloatForKey:(NSString *)key defaultValue:(float)defaultValue { - return m_mmkv->getFloat(key, defaultValue); + return [self getFloatForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (float)getFloatForKey:(NSString *)key defaultValue:(float)defaultValue hasValue:(OUT BOOL *)hasValue { + return m_mmkv->getFloat(key, defaultValue, hasValue); } - (double)getDoubleForKey:(NSString *)key { return [self getDoubleForKey:key defaultValue:0]; } - (double)getDoubleForKey:(NSString *)key defaultValue:(double)defaultValue { - return m_mmkv->getDouble(key, defaultValue); + return [self getDoubleForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (double)getDoubleForKey:(NSString *)key defaultValue:(double)defaultValue hasValue:(OUT BOOL *)hasValue { + return m_mmkv->getDouble(key, defaultValue, hasValue); } - (nullable NSString *)getStringForKey:(NSString *)key { return [self getStringForKey:key defaultValue:nil]; } - (nullable NSString *)getStringForKey:(NSString *)key defaultValue:(nullable NSString *)defaultValue { + return [self getStringForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (nullable NSString *)getStringForKey:(NSString *)key defaultValue:(nullable NSString *)defaultValue hasValue:(OUT BOOL *)hasValue { if (key.length <= 0) { return defaultValue; } NSString *valueString = [self getObjectOfClass:NSString.class forKey:key]; if (!valueString) { + if (hasValue != nil) { + *hasValue = false; + } valueString = defaultValue; } return valueString; @@ -449,11 +476,17 @@ - (nullable NSDate *)getDateForKey:(NSString *)key { return [self getDateForKey:key defaultValue:nil]; } - (nullable NSDate *)getDateForKey:(NSString *)key defaultValue:(nullable NSDate *)defaultValue { + return [self getDateForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (nullable NSDate *)getDateForKey:(NSString *)key defaultValue:(nullable NSDate *)defaultValue hasValue:(OUT BOOL *)hasValue { if (key.length <= 0) { return defaultValue; } NSDate *valueDate = [self getObjectOfClass:NSDate.class forKey:key]; if (!valueDate) { + if (hasValue != nil) { + *hasValue = false; + } valueDate = defaultValue; } return valueDate; @@ -463,11 +496,17 @@ - (nullable NSData *)getDataForKey:(NSString *)key { return [self getDataForKey:key defaultValue:nil]; } - (nullable NSData *)getDataForKey:(NSString *)key defaultValue:(nullable NSData *)defaultValue { + return [self getDataForKey:key defaultValue:defaultValue hasValue:nil]; +} +- (nullable NSData *)getDataForKey:(NSString *)key defaultValue:(nullable NSData *)defaultValue hasValue:(OUT BOOL *)hasValue { if (key.length <= 0) { return defaultValue; } NSData *valueData = [self getObjectOfClass:NSData.class forKey:key]; if (!valueData) { + if (hasValue != nil) { + *hasValue = false; + } valueData = defaultValue; } return valueData; From a3ebaff181f4c4050c28aa39953ab9e6ed9e08c9 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Mon, 14 Mar 2022 12:23:30 +0100 Subject: [PATCH 08/12] fix: Use longest version for `getXXXX` --- iOS/MMKV/MMKV/libMMKV.mm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/iOS/MMKV/MMKV/libMMKV.mm b/iOS/MMKV/MMKV/libMMKV.mm index ca15eaf7..b5faf263 100644 --- a/iOS/MMKV/MMKV/libMMKV.mm +++ b/iOS/MMKV/MMKV/libMMKV.mm @@ -383,7 +383,7 @@ - (id)getObjectOfClass:(Class)cls forKey:(NSString *)key { } - (BOOL)getBoolForKey:(NSString *)key { - return [self getBoolForKey:key defaultValue:FALSE]; + return [self getBoolForKey:key defaultValue:FALSE hasValue:nil]; } - (BOOL)getBoolForKey:(NSString *)key defaultValue:(BOOL)defaultValue { return [self getBoolForKey:key defaultValue:defaultValue hasValue:nil]; @@ -393,17 +393,17 @@ - (BOOL)getBoolForKey:(NSString *)key defaultValue:(BOOL)defaultValue hasValue:( } - (int32_t)getInt32ForKey:(NSString *)key { - return [self getInt32ForKey:key defaultValue:0]; + return [self getInt32ForKey:key defaultValue:0 hasValue:nil]; } - (int32_t)getInt32ForKey:(NSString *)key defaultValue:(int32_t)defaultValue { - return m_mmkv->getInt32(key, defaultValue); + return [self getInt32ForKey:key defaultValue:defaultValue hasValue:nil]; } - (int32_t)getInt32ForKey:(NSString *)key defaultValue:(int32_t)defaultValue hasValue:(OUT BOOL *)hasValue { return m_mmkv->getInt32(key, defaultValue, hasValue); } - (uint32_t)getUInt32ForKey:(NSString *)key { - return [self getUInt32ForKey:key defaultValue:0]; + return [self getUInt32ForKey:key defaultValue:0 hasValue:nil]; } - (uint32_t)getUInt32ForKey:(NSString *)key defaultValue:(uint32_t)defaultValue { return [self getUInt32ForKey:key defaultValue:defaultValue hasValue:nil]; @@ -413,7 +413,7 @@ - (uint32_t)getUInt32ForKey:(NSString *)key defaultValue:(uint32_t)defaultValue } - (int64_t)getInt64ForKey:(NSString *)key { - return [self getInt64ForKey:key defaultValue:0]; + return [self getInt64ForKey:key defaultValue:0 hasValue:nil]; } - (int64_t)getInt64ForKey:(NSString *)key defaultValue:(int64_t)defaultValue { return [self getInt64ForKey:key defaultValue:defaultValue hasValue:nil]; @@ -423,7 +423,7 @@ - (int64_t)getInt64ForKey:(NSString *)key defaultValue:(int64_t)defaultValue has } - (uint64_t)getUInt64ForKey:(NSString *)key { - return [self getUInt64ForKey:key defaultValue:0]; + return [self getUInt64ForKey:key defaultValue:0 hasValue:nil]; } - (uint64_t)getUInt64ForKey:(NSString *)key defaultValue:(uint64_t)defaultValue { return [self getUInt64ForKey:key defaultValue:defaultValue hasValue:nil]; @@ -433,7 +433,7 @@ - (uint64_t)getUInt64ForKey:(NSString *)key defaultValue:(uint64_t)defaultValue } - (float)getFloatForKey:(NSString *)key { - return [self getFloatForKey:key defaultValue:0]; + return [self getFloatForKey:key defaultValue:0 hasValue:nil]; } - (float)getFloatForKey:(NSString *)key defaultValue:(float)defaultValue { return [self getFloatForKey:key defaultValue:defaultValue hasValue:nil]; @@ -443,7 +443,7 @@ - (float)getFloatForKey:(NSString *)key defaultValue:(float)defaultValue hasValu } - (double)getDoubleForKey:(NSString *)key { - return [self getDoubleForKey:key defaultValue:0]; + return [self getDoubleForKey:key defaultValue:0 hasValue:nil]; } - (double)getDoubleForKey:(NSString *)key defaultValue:(double)defaultValue { return [self getDoubleForKey:key defaultValue:defaultValue hasValue:nil]; @@ -453,7 +453,7 @@ - (double)getDoubleForKey:(NSString *)key defaultValue:(double)defaultValue hasV } - (nullable NSString *)getStringForKey:(NSString *)key { - return [self getStringForKey:key defaultValue:nil]; + return [self getStringForKey:key defaultValue:nil hasValue:nil]; } - (nullable NSString *)getStringForKey:(NSString *)key defaultValue:(nullable NSString *)defaultValue { return [self getStringForKey:key defaultValue:defaultValue hasValue:nil]; @@ -473,7 +473,7 @@ - (nullable NSString *)getStringForKey:(NSString *)key defaultValue:(nullable NS } - (nullable NSDate *)getDateForKey:(NSString *)key { - return [self getDateForKey:key defaultValue:nil]; + return [self getDateForKey:key defaultValue:nil hasValue:nil]; } - (nullable NSDate *)getDateForKey:(NSString *)key defaultValue:(nullable NSDate *)defaultValue { return [self getDateForKey:key defaultValue:defaultValue hasValue:nil]; From ddc27d0153ea8a71b49f68099ab9ed40e9890cd3 Mon Sep 17 00:00:00 2001 From: guoling Date: Wed, 30 Mar 2022 10:22:06 +0800 Subject: [PATCH 09/12] fix nullable error --- Core/Core.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Core.xcscheme | 2 +- .../xcschemes/MMKVWatchCore.xcscheme | 2 +- iOS/MMKV/MMKV.xcodeproj/project.pbxproj | 2 +- .../xcschemes/MMKV For App Extension.xcscheme | 2 +- .../xcschemes/MMKV Static.xcscheme | 2 +- .../xcshareddata/xcschemes/MMKV.xcscheme | 2 +- .../xcschemes/MMKVWatchExtension.xcscheme | 2 +- iOS/MMKV/MMKV/MMKV.h | 40 +++++++++---------- iOS/MMKV/MMKV/libMMKV.mm | 30 +++++++------- .../xcshareddata/xcschemes/MMKVDemo.xcscheme | 2 +- .../xcschemes/MMKVMacDemo.xcscheme | 2 +- .../xcschemes/MMKVTodayExtensionDemo.xcscheme | 2 +- .../WatchApp (Notification).xcscheme | 2 +- .../xcshareddata/xcschemes/WatchApp.xcscheme | 2 +- 15 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Core/Core.xcodeproj/project.pbxproj b/Core/Core.xcodeproj/project.pbxproj index 972139a9..2a25d755 100644 --- a/Core/Core.xcodeproj/project.pbxproj +++ b/Core/Core.xcodeproj/project.pbxproj @@ -349,7 +349,7 @@ CB9563D023AB2D9500ACCD39 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1240; + LastUpgradeCheck = 1330; ORGANIZATIONNAME = lingol; TargetAttributes = { CB9563D723AB2D9500ACCD39 = { diff --git a/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme b/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme index 163945e8..2b22f108 100644 --- a/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +++ b/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme @@ -1,6 +1,6 @@ getBool(key, defaultValue, hasValue); + return m_mmkv->getBool(key, defaultValue, (bool *) hasValue); } - (int32_t)getInt32ForKey:(NSString *)key { @@ -399,7 +399,7 @@ - (int32_t)getInt32ForKey:(NSString *)key defaultValue:(int32_t)defaultValue { return [self getInt32ForKey:key defaultValue:defaultValue hasValue:nil]; } - (int32_t)getInt32ForKey:(NSString *)key defaultValue:(int32_t)defaultValue hasValue:(OUT BOOL *)hasValue { - return m_mmkv->getInt32(key, defaultValue, hasValue); + return m_mmkv->getInt32(key, defaultValue, (bool *) hasValue); } - (uint32_t)getUInt32ForKey:(NSString *)key { @@ -409,7 +409,7 @@ - (uint32_t)getUInt32ForKey:(NSString *)key defaultValue:(uint32_t)defaultValue return [self getUInt32ForKey:key defaultValue:defaultValue hasValue:nil]; } - (uint32_t)getUInt32ForKey:(NSString *)key defaultValue:(uint32_t)defaultValue hasValue:(OUT BOOL *)hasValue { - return m_mmkv->getUInt32(key, defaultValue, hasValue); + return m_mmkv->getUInt32(key, defaultValue, (bool *) hasValue); } - (int64_t)getInt64ForKey:(NSString *)key { @@ -419,7 +419,7 @@ - (int64_t)getInt64ForKey:(NSString *)key defaultValue:(int64_t)defaultValue { return [self getInt64ForKey:key defaultValue:defaultValue hasValue:nil]; } - (int64_t)getInt64ForKey:(NSString *)key defaultValue:(int64_t)defaultValue hasValue:(OUT BOOL *)hasValue { - return m_mmkv->getInt64(key, defaultValue, hasValue); + return m_mmkv->getInt64(key, defaultValue, (bool *) hasValue); } - (uint64_t)getUInt64ForKey:(NSString *)key { @@ -429,7 +429,7 @@ - (uint64_t)getUInt64ForKey:(NSString *)key defaultValue:(uint64_t)defaultValue return [self getUInt64ForKey:key defaultValue:defaultValue hasValue:nil]; } - (uint64_t)getUInt64ForKey:(NSString *)key defaultValue:(uint64_t)defaultValue hasValue:(OUT BOOL *)hasValue { - return m_mmkv->getUInt64(key, defaultValue, hasValue); + return m_mmkv->getUInt64(key, defaultValue, (bool *) hasValue); } - (float)getFloatForKey:(NSString *)key { @@ -439,7 +439,7 @@ - (float)getFloatForKey:(NSString *)key defaultValue:(float)defaultValue { return [self getFloatForKey:key defaultValue:defaultValue hasValue:nil]; } - (float)getFloatForKey:(NSString *)key defaultValue:(float)defaultValue hasValue:(OUT BOOL *)hasValue { - return m_mmkv->getFloat(key, defaultValue, hasValue); + return m_mmkv->getFloat(key, defaultValue, (bool *) hasValue); } - (double)getDoubleForKey:(NSString *)key { @@ -449,7 +449,7 @@ - (double)getDoubleForKey:(NSString *)key defaultValue:(double)defaultValue { return [self getDoubleForKey:key defaultValue:defaultValue hasValue:nil]; } - (double)getDoubleForKey:(NSString *)key defaultValue:(double)defaultValue hasValue:(OUT BOOL *)hasValue { - return m_mmkv->getDouble(key, defaultValue, hasValue); + return m_mmkv->getDouble(key, defaultValue, (bool *) hasValue); } - (nullable NSString *)getStringForKey:(NSString *)key { @@ -740,7 +740,7 @@ + (BOOL)isFileValid:(NSString *)mmapID rootPath:(nullable NSString *)path { #pragma mark - backup & restore -+ (BOOL) backupOneMMKV:(NSString*)mmapID rootPath:(nullable NSString *)path toDirectory:(NSString*)dstDir { ++ (BOOL)backupOneMMKV:(NSString *)mmapID rootPath:(nullable NSString *)path toDirectory:(NSString *)dstDir { if (path.length > 0) { string rootPath(path.UTF8String); return mmkv::MMKV::backupOneToDirectory(mmapID.UTF8String, dstDir.UTF8String, &rootPath); @@ -748,7 +748,7 @@ + (BOOL) backupOneMMKV:(NSString*)mmapID rootPath:(nullable NSString *)path toDi return mmkv::MMKV::backupOneToDirectory(mmapID.UTF8String, dstDir.UTF8String); } -+ (BOOL) restoreOneMMKV:(NSString*)mmapID rootPath:(nullable NSString *)path fromDirectory:(NSString*)srcDir { ++ (BOOL)restoreOneMMKV:(NSString *)mmapID rootPath:(nullable NSString *)path fromDirectory:(NSString *)srcDir { if (path.length > 0) { string rootPath(path.UTF8String); return mmkv::MMKV::restoreOneFromDirectory(mmapID.UTF8String, srcDir.UTF8String, &rootPath); @@ -756,7 +756,7 @@ + (BOOL) restoreOneMMKV:(NSString*)mmapID rootPath:(nullable NSString *)path fro return mmkv::MMKV::restoreOneFromDirectory(mmapID.UTF8String, srcDir.UTF8String); } -+ (size_t) backupAll:(nullable NSString *)path toDirectory:(NSString*)dstDir { ++ (size_t)backupAll:(nullable NSString *)path toDirectory:(NSString *)dstDir { if (path.length > 0) { string rootPath(path.UTF8String); return mmkv::MMKV::backupAllToDirectory(dstDir.UTF8String, &rootPath); @@ -764,7 +764,7 @@ + (size_t) backupAll:(nullable NSString *)path toDirectory:(NSString*)dstDir { return mmkv::MMKV::backupAllToDirectory(dstDir.UTF8String); } -+ (size_t) restoreAll:(nullable NSString *)path fromDirectory:(NSString*)srcDir { ++ (size_t)restoreAll:(nullable NSString *)path fromDirectory:(NSString *)srcDir { if (path.length > 0) { string rootPath(path.UTF8String); return mmkv::MMKV::restoreAllFromDirectory(srcDir.UTF8String, &rootPath); @@ -772,7 +772,7 @@ + (size_t) restoreAll:(nullable NSString *)path fromDirectory:(NSString*)srcDir return mmkv::MMKV::restoreAllFromDirectory(srcDir.UTF8String); } -+ (BOOL)backupMultiProcessMMKV:(NSString *)mmapID toDirectory:(NSString*)dstDir { ++ (BOOL)backupMultiProcessMMKV:(NSString *)mmapID toDirectory:(NSString *)dstDir { if (!g_groupPath) { MMKVError("Backup a multi-process MMKV [%@] without setting groupDir makes no sense", mmapID); MMKV_ASSERT(0); @@ -780,7 +780,7 @@ + (BOOL)backupMultiProcessMMKV:(NSString *)mmapID toDirectory:(NSString*)dstDir return [MMKV backupOneMMKV:mmapID rootPath:g_groupPath toDirectory:dstDir]; } -+ (BOOL) restoreMultiProcessMMKV:(NSString*)mmapID fromDirectory:(NSString*)srcDir { ++ (BOOL)restoreMultiProcessMMKV:(NSString *)mmapID fromDirectory:(NSString *)srcDir { if (!g_groupPath) { MMKVError("Restore a multi-process MMKV [%@] without setting groupDir makes no sense", mmapID); MMKV_ASSERT(0); @@ -788,7 +788,7 @@ + (BOOL) restoreMultiProcessMMKV:(NSString*)mmapID fromDirectory:(NSString*)srcD return [MMKV restoreOneMMKV:mmapID rootPath:g_groupPath fromDirectory:srcDir]; } -+ (size_t) backupAllMultiProcessToDirectory:(NSString*)dstDir { ++ (size_t)backupAllMultiProcessToDirectory:(NSString *)dstDir { if (!g_groupPath) { MMKVError("Backup multi-process MMKV without setting groupDir makes no sense."); MMKV_ASSERT(0); @@ -796,7 +796,7 @@ + (size_t) backupAllMultiProcessToDirectory:(NSString*)dstDir { return [MMKV backupAll:g_groupPath toDirectory:dstDir]; } -+ (size_t) restoreAllMultiProcessFromDirectory:(NSString*)srcDir { ++ (size_t)restoreAllMultiProcessFromDirectory:(NSString *)srcDir { if (!g_groupPath) { MMKVError("Restore multi-process MMKV without setting groupDir makes no sense."); MMKV_ASSERT(0); diff --git a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/MMKVDemo.xcscheme b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/MMKVDemo.xcscheme index 7f1f02d0..097d7039 100644 --- a/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/MMKVDemo.xcscheme +++ b/iOS/MMKVDemo/MMKVDemo.xcodeproj/xcshareddata/xcschemes/MMKVDemo.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 30 Mar 2022 10:36:36 +0800 Subject: [PATCH 10/12] tidy --- iOS/MMKV/MMKV/MMKV.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOS/MMKV/MMKV/MMKV.h b/iOS/MMKV/MMKV/MMKV.h index 13e00a5d..1b74a570 100644 --- a/iOS/MMKV/MMKV/MMKV.h +++ b/iOS/MMKV/MMKV/MMKV.h @@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN /// @param mmapID any unique ID (com.tencent.xin.pay, etc), if you want a per-user mmkv, you could merge user-id within mmapID /// @param relativePath custom path of the file, `NSDocumentDirectory/mmkv` by default -+ (nullable instancetype)mmkvWithID:(NSString *)mmapID relativePath:(nullable NSString *)relativePath NS_SWIFT_NAME(init(mmapID:relativePath:))__attribute__((deprecated("use +mmkvWithID:rootPath: instead"))); ++ (nullable instancetype)mmkvWithID:(NSString *)mmapID relativePath:(nullable NSString *)relativePath NS_SWIFT_NAME(init(mmapID:relativePath:)) __attribute__((deprecated("use +mmkvWithID:rootPath: instead"))); /// @param mmapID any unique ID (com.tencent.xin.pay, etc), if you want a per-user mmkv, you could merge user-id within mmapID /// @param rootPath custom path of the file, `NSDocumentDirectory/mmkv` by default @@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN /// @param mmapID any unique ID (com.tencent.xin.pay, etc), if you want a per-user mmkv, you could merge user-id within mmapID /// @param cryptKey 16 bytes at most /// @param relativePath custom path of the file, `NSDocumentDirectory/mmkv` by default -+ (nullable instancetype)mmkvWithID:(NSString *)mmapID cryptKey:(nullable NSData *)cryptKey relativePath:(nullable NSString *)relativePath NS_SWIFT_NAME(init(mmapID:cryptKey:relativePath:))__attribute__((deprecated("use +mmkvWithID:cryptKey:rootPath: instead"))); ++ (nullable instancetype)mmkvWithID:(NSString *)mmapID cryptKey:(nullable NSData *)cryptKey relativePath:(nullable NSString *)relativePath NS_SWIFT_NAME(init(mmapID:cryptKey:relativePath:)) __attribute__((deprecated("use +mmkvWithID:cryptKey:rootPath: instead"))); /// @param mmapID any unique ID (com.tencent.xin.pay, etc), if you want a per-user mmkv, you could merge user-id within mmapID /// @param cryptKey 16 bytes at most From ec2621587506c297ebedf9184be196db0830a320 Mon Sep 17 00:00:00 2001 From: guoling Date: Wed, 30 Mar 2022 11:30:16 +0800 Subject: [PATCH 11/12] Replace the deprecated `device_info` package with `device_info_plus` #852 --- CHANGELOG.md | 14 +++++ Core/MMKVPredef.h | 2 +- MMKV.podspec | 4 +- MMKVAppExtension.podspec | 4 +- MMKVCore.podspec | 2 +- MMKVWatchExtension.podspec | 4 +- README.md | 6 +-- README_CN.md | 4 +- flutter/CHANGELOG.md | 4 ++ flutter/android/build.gradle | 2 +- flutter/example/ios/Podfile.lock | 16 +++--- flutter/example/pubspec.lock | 68 ++++++++++++++++++++----- flutter/ios/mmkvflutter.podspec | 4 +- flutter/lib/mmkv.dart | 4 +- flutter/pubspec.lock | 63 +++++++++++++++++------ flutter/pubspec.yaml | 4 +- iOS/MMKV/MMKV.xcodeproj/project.pbxproj | 12 ++--- 17 files changed, 154 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a28f022..74172def 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # MMKV Change Log +## v1.2.13 / 2022-03-30 + +### Android +* Fix crash on using Ashmem while `MMKV_DISABLE_CRYPT` macro is defined. + +### iOS +* Add ability to retrieve key existece while getting value, aka `-[MMKV getXXX:forKey:hasValue:]` methods. + +### POSIX +* Add ability to retrieve key existece while getting value, aka `MMKV::getXXX(key, defaultValue, hasValue)` methods. + +### Win32 +* Add ability to retrieve key existece while getting value, aka `MMKV::getXXX(key, defaultValue, hasValue)` methods. + ## v1.2.12 / 2022-01-17 ### Changes for All platforms * Fix a bug that a subsequential `clearAll()` call may fail to take effect in multi-process mode. diff --git a/Core/MMKVPredef.h b/Core/MMKVPredef.h index 371e354a..e49b60a4 100755 --- a/Core/MMKVPredef.h +++ b/Core/MMKVPredef.h @@ -34,7 +34,7 @@ #include #include -constexpr auto MMKV_VERSION = "v1.2.12"; +constexpr auto MMKV_VERSION = "v1.2.13"; #ifdef DEBUG # define MMKV_DEBUG diff --git a/MMKV.podspec b/MMKV.podspec index 7fabe67f..c39963b2 100644 --- a/MMKV.podspec +++ b/MMKV.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MMKV" - s.version = "1.2.12" + s.version = "1.2.13" s.summary = "MMKV is a cross-platform key-value storage framework developed by WeChat." s.description = <<-DESC @@ -31,7 +31,7 @@ Pod::Spec.new do |s| "CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF" => "NO", } - s.dependency 'MMKVCore', '~> 1.2.12' + s.dependency 'MMKVCore', '~> 1.2.13' end diff --git a/MMKVAppExtension.podspec b/MMKVAppExtension.podspec index 5935a4ac..35d90970 100644 --- a/MMKVAppExtension.podspec +++ b/MMKVAppExtension.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MMKVAppExtension" - s.version = "1.2.12" + s.version = "1.2.13" s.summary = "MMKV is a cross-platform key-value storage framework developed by WeChat." s.module_name = "MMKVAppExtension" @@ -31,7 +31,7 @@ Pod::Spec.new do |s| "GCC_PREPROCESSOR_DEFINITIONS" => "MMKV_IOS_EXTENSION", } - s.dependency 'MMKVCore', '~> 1.2.12' + s.dependency 'MMKVCore', '~> 1.2.13' end diff --git a/MMKVCore.podspec b/MMKVCore.podspec index 8ca310a8..388fd6b7 100644 --- a/MMKVCore.podspec +++ b/MMKVCore.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MMKVCore" - s.version = "1.2.12" + s.version = "1.2.13" s.summary = "MMKVCore for MMKV. MMKV is a cross-platform key-value storage framework developed by WeChat." s.description = <<-DESC diff --git a/MMKVWatchExtension.podspec b/MMKVWatchExtension.podspec index f3012161..c406f266 100644 --- a/MMKVWatchExtension.podspec +++ b/MMKVWatchExtension.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MMKVWatchExtension" - s.version = "1.2.12" + s.version = "1.2.13" s.summary = "MMKV is a cross-platform key-value storage framework developed by WeChat." s.module_name = "MMKVWatchExtension" @@ -31,7 +31,7 @@ Pod::Spec.new do |s| "GCC_PREPROCESSOR_DEFINITIONS" => "MMKV_IOS_EXTENSION", } - s.dependency 'MMKVCore', '~> 1.2.12' + s.dependency 'MMKVCore', '~> 1.2.13' end diff --git a/README.md b/README.md index 685215d3..eab38cd2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![license](https://img.shields.io/badge/license-BSD_3-brightgreen.svg?style=flat)](https://github.com/Tencent/MMKV/blob/master/LICENSE.TXT) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/MMKV/pulls) -[![Release Version](https://img.shields.io/badge/release-1.2.12-brightgreen.svg)](https://github.com/Tencent/MMKV/releases) +[![Release Version](https://img.shields.io/badge/release-1.2.13-brightgreen.svg)](https://github.com/Tencent/MMKV/releases) [![Platform](https://img.shields.io/badge/Platform-%20Android%20%7C%20iOS%2FmacOS%20%7C%20Win32%20%7C%20POSIX-brightgreen.svg)](https://github.com/Tencent/MMKV/wiki/home) 中文版本请参看[这里](./README_CN.md) @@ -28,8 +28,8 @@ Add the following lines to `build.gradle` on your app module: ```gradle dependencies { - implementation 'com.tencent:mmkv:1.2.12' - // replace "1.2.12" with any available version + implementation 'com.tencent:mmkv:1.2.13' + // replace "1.2.13" with any available version } ``` diff --git a/README_CN.md b/README_CN.md index d013c9ce..026e3e2f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -22,8 +22,8 @@ MMKV 是基于 mmap 内存映射的 key-value 组件,底层序列化/反序列 ```gradle dependencies { - implementation 'com.tencent:mmkv:1.2.12' - // replace "1.2.12" with any available version + implementation 'com.tencent:mmkv:1.2.13' + // replace "1.2.13" with any available version } ``` 从 v1.2.8 起, MMKV **迁移到 Maven Central**。 diff --git a/flutter/CHANGELOG.md b/flutter/CHANGELOG.md index 85e085d3..37dde33f 100644 --- a/flutter/CHANGELOG.md +++ b/flutter/CHANGELOG.md @@ -1,5 +1,9 @@ # MMKV for Flutter Change Log +## v1.2.14 / 2022-03-30 +* Replace the deprecated `device_info` package with `device_info_plus`. +* Keep up with MMKV native lib v1.2.13. + ## v1.2.13 / 2022-01-17 * Fix a bug that a subsequential `clearAll()` call may fail to take effect in multi-process mode. * Hide some OpenSSL symbols to prevent link-time symbol conflict, when an App somehow also static linking OpenSSL. diff --git a/flutter/android/build.gradle b/flutter/android/build.gradle index 579b2635..a0c7fd0e 100644 --- a/flutter/android/build.gradle +++ b/flutter/android/build.gradle @@ -33,6 +33,6 @@ android { } dependencies { - implementation 'com.tencent:mmkv-static:1.2.12' + implementation 'com.tencent:mmkv-static:1.2.13' } } diff --git a/flutter/example/ios/Podfile.lock b/flutter/example/ios/Podfile.lock index 5c16ab6b..0f185417 100644 --- a/flutter/example/ios/Podfile.lock +++ b/flutter/example/ios/Podfile.lock @@ -1,18 +1,18 @@ PODS: - - device_info (0.0.1): + - device_info_plus (0.0.1): - Flutter - Flutter (1.0.0) - MMKV (1.2.12): - MMKVCore (~> 1.2.12) - MMKVCore (1.2.12) - - mmkvflutter (1.2.12): + - mmkvflutter (1.2.13): - Flutter - MMKV (>= 1.2.12) - path_provider_ios (0.0.1): - Flutter DEPENDENCIES: - - device_info (from `.symlinks/plugins/device_info/ios`) + - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - Flutter (from `Flutter`) - mmkvflutter (from `.symlinks/plugins/mmkvflutter/ios`) - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) @@ -23,8 +23,8 @@ SPEC REPOS: - MMKVCore EXTERNAL SOURCES: - device_info: - :path: ".symlinks/plugins/device_info/ios" + device_info_plus: + :path: ".symlinks/plugins/device_info_plus/ios" Flutter: :path: Flutter mmkvflutter: @@ -33,12 +33,12 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/path_provider_ios/ios" SPEC CHECKSUMS: - device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 + device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a MMKV: f281020c9d9be5eb7a03ae746dc4deb570e46c23 MMKVCore: df0565f6b58463604731a68ba6cd89bc0b2d1d55 - mmkvflutter: bc0bb663f20c9c8754600d57e9ab01829344a9ce - path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5 + mmkvflutter: dfcdf1b58b7e4cb88a60903855a72de5a5632889 + path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 PODFILE CHECKSUM: 5892152591d599b8a50589fd8872b0421e2fc7b5 diff --git a/flutter/example/pubspec.lock b/flutter/example/pubspec.lock index 14e53b58..8f2a6a15 100644 --- a/flutter/example/pubspec.lock +++ b/flutter/example/pubspec.lock @@ -50,20 +50,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.4" - device_info: + device_info_plus: dependency: transitive description: - name: device_info + name: device_info_plus url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" - device_info_platform_interface: + version: "3.2.2" + device_info_plus_linux: + dependency: transitive + description: + name: device_info_plus_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + device_info_plus_macos: + dependency: transitive + description: + name: device_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.2" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0+1" + device_info_plus_web: + dependency: transitive + description: + name: device_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + device_info_plus_windows: dependency: transitive description: - name: device_info_platform_interface + name: device_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.1.1" fake_async: dependency: transitive description: @@ -95,6 +123,18 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: @@ -115,7 +155,7 @@ packages: path: ".." relative: true source: path - version: "1.2.13" + version: "1.2.14" path: dependency: transitive description: @@ -129,21 +169,21 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.9" path_provider_android: dependency: transitive description: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.12" path_provider_ios: dependency: transitive description: name: path_provider_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.8" path_provider_linux: dependency: transitive description: @@ -260,14 +300,14 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.3.5" + version: "2.5.0" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.0+1" sdks: - dart: ">=2.14.0 <3.0.0" - flutter: ">=2.5.0" + dart: ">=2.15.0 <3.0.0" + flutter: ">=2.8.0" diff --git a/flutter/ios/mmkvflutter.podspec b/flutter/ios/mmkvflutter.podspec index 5e05f050..387fd050 100644 --- a/flutter/ios/mmkvflutter.podspec +++ b/flutter/ios/mmkvflutter.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |s| s.name = 'mmkvflutter' - s.version = '1.2.12' + s.version = '1.2.13' s.summary = 'MMKV is a cross-platform key-value storage framework developed by WeChat.' s.description = <<-DESC The MMKV, for Flutter. @@ -19,7 +19,7 @@ Pod::Spec.new do |s| s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.dependency 'MMKV', '>= 1.2.12' + s.dependency 'MMKV', '>= 1.2.13' s.platform = :ios, '9.0' # Flutter.framework does not contain a i386 slice. diff --git a/flutter/lib/mmkv.dart b/flutter/lib/mmkv.dart index 4ac3f779..23401b76 100644 --- a/flutter/lib/mmkv.dart +++ b/flutter/lib/mmkv.dart @@ -24,7 +24,7 @@ import 'dart:ffi'; // For FFI import 'dart:io'; // For Platform.isX import 'dart:typed_data'; -import 'package:device_info/device_info.dart'; +import 'package:device_info_plus/device_info_plus.dart'; import 'package:ffi/ffi.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -176,7 +176,7 @@ class MMKV { } else { final rootDirPtr = _string2Pointer(rootDir); final androidInfo = await DeviceInfoPlugin().androidInfo; - final sdkInt = androidInfo.version.sdkInt; + final sdkInt = androidInfo.version.sdkInt ?? 0; final cacheDir = await getTemporaryDirectory(); final cacheDirPtr = _string2Pointer(cacheDir.path); diff --git a/flutter/pubspec.lock b/flutter/pubspec.lock index d2113df7..0e289781 100644 --- a/flutter/pubspec.lock +++ b/flutter/pubspec.lock @@ -92,20 +92,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.1" - device_info: + device_info_plus: dependency: "direct main" description: - name: device_info + name: device_info_plus url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" - device_info_platform_interface: + version: "3.2.2" + device_info_plus_linux: dependency: transitive description: - name: device_info_platform_interface + name: device_info_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.1.1" + device_info_plus_macos: + dependency: transitive + description: + name: device_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.2" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0+1" + device_info_plus_web: + dependency: transitive + description: + name: device_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + device_info_plus_windows: + dependency: transitive + description: + name: device_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" fake_async: dependency: transitive description: @@ -137,6 +165,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" frontend_server_client: dependency: transitive description: @@ -157,7 +190,7 @@ packages: name: http_multi_server url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.2.0" http_parser: dependency: transitive description: @@ -234,21 +267,21 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.9" path_provider_android: dependency: transitive description: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.12" path_provider_ios: dependency: transitive description: name: path_provider_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.8" path_provider_linux: dependency: transitive description: @@ -318,7 +351,7 @@ packages: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" shelf: dependency: transitive description: @@ -470,14 +503,14 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.3.5" + version: "2.5.0" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.0+1" yaml: dependency: transitive description: @@ -486,5 +519,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.14.0 <3.0.0" - flutter: ">=2.5.0" + dart: ">=2.15.0 <3.0.0" + flutter: ">=2.8.0" diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 56fbfd92..0a77f7d3 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: mmkv description: An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX. -version: 1.2.13 +version: 1.2.14 homepage: https://github.com/Tencent/mmkv environment: @@ -12,7 +12,7 @@ dependencies: sdk: flutter path_provider: ^2.0.1 ffi: ^1.0.0 - device_info: ^2.0.2 + device_info_plus: ^3.2.2 dev_dependencies: test: diff --git a/iOS/MMKV/MMKV.xcodeproj/project.pbxproj b/iOS/MMKV/MMKV.xcodeproj/project.pbxproj index 1ccee2ab..86a99327 100644 --- a/iOS/MMKV/MMKV.xcodeproj/project.pbxproj +++ b/iOS/MMKV/MMKV.xcodeproj/project.pbxproj @@ -486,7 +486,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.12; + MARKETING_VERSION = 1.2.13; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -529,7 +529,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.12; + MARKETING_VERSION = 1.2.13; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -728,7 +728,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.12; + MARKETING_VERSION = 1.2.13; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -766,7 +766,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.12; + MARKETING_VERSION = 1.2.13; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -811,7 +811,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.12; + MARKETING_VERSION = 1.2.13; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -858,7 +858,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.12; + MARKETING_VERSION = 1.2.13; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, From 112afa9c1451a336c1b85c35dc8de4ac190a78a3 Mon Sep 17 00:00:00 2001 From: guoling Date: Wed, 30 Mar 2022 11:49:18 +0800 Subject: [PATCH 12/12] prepare for v1.2.13 --- Android/MMKV/gradle.properties | 2 +- Android/MMKV/mmkvdemo/build.gradle | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Android/MMKV/gradle.properties b/Android/MMKV/gradle.properties index ed6d3151..722829aa 100644 --- a/Android/MMKV/gradle.properties +++ b/Android/MMKV/gradle.properties @@ -14,7 +14,7 @@ org.gradle.jvmargs=-Xmx1536m # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME_PREFIX=1.2.12 +VERSION_NAME_PREFIX=1.2.13 #VERSION_NAME_SUFFIX=-SNAPSHOT VERSION_NAME_SUFFIX= diff --git a/Android/MMKV/mmkvdemo/build.gradle b/Android/MMKV/mmkvdemo/build.gradle index 2ea9e6a4..a94923f0 100644 --- a/Android/MMKV/mmkvdemo/build.gradle +++ b/Android/MMKV/mmkvdemo/build.gradle @@ -76,9 +76,9 @@ repositories { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation project(':mmkv') -// implementation 'com.tencent:mmkv:1.2.12' -// implementation 'com.tencent:mmkv-static:1.2.12' // this is identical to 'com.tencent:mmkv' -// implementation 'com.tencent:mmkv-shared:1.2.12' +// implementation 'com.tencent:mmkv:1.2.13' +// implementation 'com.tencent:mmkv-static:1.2.13' // this is identical to 'com.tencent:mmkv' +// implementation 'com.tencent:mmkv-shared:1.2.13' implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' testImplementation 'junit:junit:4.13.2'