Skip to content

Commit

Permalink
rename pub package to mmkv
Browse files Browse the repository at this point in the history
  • Loading branch information
lingol committed Nov 20, 2020
1 parent 05d8955 commit 95a7553
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 10 deletions.
6 changes: 3 additions & 3 deletions flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add the following lines to `pubspec.yaml` on your app module:

```yaml
dependencies:
mmkvflutter: ">=1.2.5"
mmkv: ">=1.2.5"
...
```

Expand All @@ -50,7 +50,7 @@ You can use MMKV as you go. All changes are saved immediately, no `sync`, no `ap
Setup MMKV on App startup, say your `main()` function, add these lines:

```dart
import 'package:mmkvflutter/mmkv.dart';
import 'package:mmkv/mmkv.dart';
void main() async {
Expand All @@ -68,7 +68,7 @@ Note that you have to **wait for MMKV to finish initialization** before accessin
* MMKV has a global instance, that can be used directly:

```dart
import 'package:mmkvflutter/mmkv.dart';
import 'package:mmkv/mmkv.dart';
var mmkv = MMKV.defaultMMKV();
mmkv.encodeBool('bool', true);
Expand Down
33 changes: 33 additions & 0 deletions flutter/example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,43 @@ def flutter_root
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

# to avoid conflict of the native lib name 'libMMKV.so' on iOS, we need to change the plugin name 'mmkv' to 'mmkvflutter'
def fix_mmkv_plugin_name
# locate the generated file '.flutter-plugins-dependencies', usually it's on the root dir of your flutter app or module
podfile_dir = File.dirname(File.realpath(__FILE__))
plugins_file = File.join(podfile_dir, '..', '.flutter-plugins-dependencies')

fix_mmkv_plugin_name_inside_dependencies(plugins_file)
end

# to avoid conflict of the native lib name 'libMMKV.so' on iOS, we need to change the plugin name 'mmkv' to 'mmkvflutter'
def fix_mmkv_plugin_name_inside_dependencies(plugin_deps_file)
plugin_deps_file = File.expand_path(plugin_deps_file)
unless File.exists?(plugin_deps_file)
raise "#{plugin_deps_file} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

dependencies_hash = JSON.parse(File.read(plugin_deps_file))
(dependencies_hash.dig('plugins', 'ios') || []).each do |plugin|
if plugin['name'] == 'mmkv'
plugin['name'] = 'mmkvflutter'

json = dependencies_hash.to_json
File.write(plugin_deps_file, json)
return
end
end
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

# to avoid conflict of the native lib name 'libMMKV.so' on iOS, we need to change the plugin name 'mmkv' to 'mmkvflutter'
fix_mmkv_plugin_name
# or simpley run with the relative path of the file '.flutter-plugins-dependencies'
# fix_mmkv_plugin_name_inside_dependencies('../.flutter-plugins-dependencies')

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
Expand Down
2 changes: 1 addition & 1 deletion flutter/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ SPEC CHECKSUMS:
mmkvflutter: d4a166f8ab6b4586cca40948feec6c9f65a34ad8
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c

PODFILE CHECKSUM: 004ec2c8f64c48818df891dd2d2ce417902bd270
PODFILE CHECKSUM: ef36e106ef9d8d594b1116eba84859922c477694

COCOAPODS: 1.10.0
2 changes: 1 addition & 1 deletion flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
import 'package:mmkvflutter/mmkvflutter.dart';
import 'package:mmkv/mmkv.dart';

void main() async {
// must wait for MMKV to finish initialization
Expand Down
2 changes: 1 addition & 1 deletion flutter/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
mmkvflutter:
mmkv:
dependency: "direct main"
description:
path: ".."
Expand Down
4 changes: 2 additions & 2 deletions flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ dependencies:
sdk: flutter
path_provider: ">=1.6.0 <2.0.0"

mmkvflutter:
mmkv:
# When depending on this package from a real application you should use:
# mmkvflutter: ^x.y.z
# mmkv: ^x.y.z
# See https://dart.dev/tools/pub/dependencies#version-constraints
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
Expand Down
2 changes: 1 addition & 1 deletion flutter/ios/Classes/flutter-bridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ - (void)mmkvLogWithLevel:(MMKVLogLevel)level file:(const char *)file line:(int)l
return "N";
}
};
NSLog(@"mmkvflutter:[%s] <%s:%d::%s> %@\n", LogLevelDesc(level), file, line, funcname, message);
NSLog(@"mmkv:[%s] <%s:%d::%s> %@\n", LogLevelDesc(level), file, line, funcname, message);
}
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: mmkvflutter
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.5
homepage: https://github.com/Tencent/mmkv
Expand Down

0 comments on commit 95a7553

Please sign in to comment.