Browse Source

Update pod file.

Caijinglong 4 years ago
parent
commit
3527e3fd18

+ 58
- 34
example/ios/Podfile View File

@@ -4,56 +4,80 @@
4 4
 # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 5
 ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 6
 
7
+project 'Runner', {
8
+  'Debug' => :debug,
9
+  'Profile' => :release,
10
+  'Release' => :release,
11
+}
12
+
7 13
 def parse_KV_file(file, separator='=')
8 14
   file_abs_path = File.expand_path(file)
9 15
   if !File.exists? file_abs_path
10 16
     return [];
11 17
   end
12
-  pods_ary = []
18
+  generated_key_values = {}
13 19
   skip_line_start_symbols = ["#", "/"]
14
-  File.foreach(file_abs_path) { |line|
15
-      next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
16
-      plugin = line.split(pattern=separator)
17
-      if plugin.length == 2
18
-        podname = plugin[0].strip()
19
-        path = plugin[1].strip()
20
-        podpath = File.expand_path("#{path}", file_abs_path)
21
-        pods_ary.push({:name => podname, :path => podpath});
22
-      else
23
-        puts "Invalid plugin specification: #{line}"
24
-      end
25
-  }
26
-  return pods_ary
20
+  File.foreach(file_abs_path) do |line|
21
+    next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22
+    plugin = line.split(pattern=separator)
23
+    if plugin.length == 2
24
+      podname = plugin[0].strip()
25
+      path = plugin[1].strip()
26
+      podpath = File.expand_path("#{path}", file_abs_path)
27
+      generated_key_values[podname] = podpath
28
+    else
29
+      puts "Invalid plugin specification: #{line}"
30
+    end
31
+  end
32
+  generated_key_values
27 33
 end
28 34
 
29 35
 target 'Runner' do
30
-  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
31
-  # referring to absolute paths on developers' machines.
32
-  system('rm -rf .symlinks')
33
-  system('mkdir -p .symlinks/plugins')
36
+  # Flutter Pod
34 37
 
35
-  # Flutter Pods
36
-  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
37
-  if generated_xcode_build_settings.empty?
38
-    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
39
-  end
40
-  generated_xcode_build_settings.map { |p|
41
-    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
42
-      symlink = File.join('.symlinks', 'flutter')
43
-      File.symlink(File.dirname(p[:path]), symlink)
44
-      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
38
+  copied_flutter_dir = File.join(__dir__, 'Flutter')
39
+  copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
40
+  copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
41
+  unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
42
+    # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
43
+    # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
44
+    # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
45
+
46
+    generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
47
+    unless File.exist?(generated_xcode_build_settings_path)
48
+      raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
45 49
     end
46
-  }
50
+    generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
51
+    cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
52
+
53
+    unless File.exist?(copied_framework_path)
54
+      FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
55
+    end
56
+    unless File.exist?(copied_podspec_path)
57
+      FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
58
+    end
59
+  end
60
+
61
+  # Keep pod path relative so it can be checked into Podfile.lock.
62
+  pod 'Flutter', :path => 'Flutter'
47 63
 
48 64
   # Plugin Pods
65
+
66
+  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
67
+  # referring to absolute paths on developers' machines.
68
+  system('rm -rf .symlinks')
69
+  system('mkdir -p .symlinks/plugins')
49 70
   plugin_pods = parse_KV_file('../.flutter-plugins')
50
-  plugin_pods.map { |p|
51
-    symlink = File.join('.symlinks', 'plugins', p[:name])
52
-    File.symlink(p[:path], symlink)
53
-    pod p[:name], :path => File.join(symlink, 'ios')
54
-  }
71
+  plugin_pods.each do |name, path|
72
+    symlink = File.join('.symlinks', 'plugins', name)
73
+    File.symlink(path, symlink)
74
+    pod name, :path => File.join(symlink, 'ios')
75
+  end
55 76
 end
56 77
 
78
+# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
79
+install! 'cocoapods', :disable_input_output_paths => true
80
+
57 81
 post_install do |installer|
58 82
   installer.pods_project.targets.each do |target|
59 83
     target.build_configurations.each do |config|

+ 0
- 3
example/ios/Runner.xcodeproj/project.pbxproj View File

@@ -227,12 +227,9 @@
227 227
 			files = (
228 228
 			);
229 229
 			inputPaths = (
230
-				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
231
-				"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
232 230
 			);
233 231
 			name = "[CP] Embed Pods Frameworks";
234 232
 			outputPaths = (
235
-				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
236 233
 			);
237 234
 			runOnlyForDeploymentPostprocessing = 0;
238 235
 			shellPath = /bin/sh;

+ 2
- 1
example/lib/main.dart View File

@@ -114,7 +114,8 @@ class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
114 114
   }
115 115
 
116 116
   void _testPhotoListParams() async {
117
-    var assetPathList = await PhotoManager.getImageAsset();
117
+    var assetPathList =
118
+        await PhotoManager.getAssetPathList(type: RequestType.image);
118 119
     _pickAsset(PickType.all, pathList: assetPathList);
119 120
   }
120 121
 

+ 1
- 0
lib/src/provider/config_provider.dart View File

@@ -4,6 +4,7 @@ import 'package:photo/src/provider/asset_provider.dart';
4 4
 import 'package:photo/src/provider/i18n_provider.dart';
5 5
 import 'package:photo_manager/photo_manager.dart';
6 6
 
7
+// ignore_for_file: deprecated_member_use
7 8
 class PhotoPickerProvider extends InheritedWidget {
8 9
   final Options options;
9 10
   final I18nProvider provider;

+ 6
- 5
lib/src/ui/page/photo_main_page.dart View File

@@ -214,13 +214,14 @@ class _PhotoMainPageState extends State<PhotoMainPage>
214 214
     List<AssetPathEntity> pathList;
215 215
     switch (options.pickType) {
216 216
       case PickType.onlyImage:
217
-        pathList = await PhotoManager.getImageAsset();
217
+        pathList = await PhotoManager.getAssetPathList(type: RequestType.image);
218 218
         break;
219 219
       case PickType.onlyVideo:
220
-        pathList = await PhotoManager.getVideoAsset();
220
+        pathList = await PhotoManager.getAssetPathList(type: RequestType.image);
221 221
         break;
222 222
       default:
223
-        pathList = await PhotoManager.getAssetPathList();
223
+        pathList = await PhotoManager.getAssetPathList(
224
+            type: RequestType.image | RequestType.video);
224 225
     }
225 226
 
226 227
     _onRefreshAssetPathList(pathList);
@@ -502,10 +503,10 @@ class _PhotoMainPageState extends State<PhotoMainPage>
502 503
     List<AssetPathEntity> pathList;
503 504
     switch (options.pickType) {
504 505
       case PickType.onlyImage:
505
-        pathList = await PhotoManager.getImageAsset();
506
+        pathList = await PhotoManager.getAssetPathList(type: RequestType.image);
506 507
         break;
507 508
       case PickType.onlyVideo:
508
-        pathList = await PhotoManager.getVideoAsset();
509
+        pathList = await PhotoManager.getAssetPathList(type: RequestType.image);
509 510
         break;
510 511
       default:
511 512
         pathList = await PhotoManager.getAssetPathList();

+ 1
- 1
pubspec.lock View File

@@ -115,7 +115,7 @@ packages:
115 115
       name: photo_manager
116 116
       url: "https://pub.flutter-io.cn"
117 117
     source: hosted
118
-    version: "0.4.8"
118
+    version: "0.5.0"
119 119
   quiver:
120 120
     dependency: transitive
121 121
     description:

+ 2
- 2
pubspec.yaml View File

@@ -1,6 +1,6 @@
1 1
 name: photo
2 2
 description: image picker, multi picker support video/icloud asset, use flutter as ui, if you want to build custom ui, you just use photo_manager.
3
-version: 0.4.8
3
+version: 0.5.0-dev.1
4 4
 author: caijinglong<cjl_spy@163.com>
5 5
 homepage: https://github.com/CaiJingLong/flutter_photo
6 6
 
@@ -11,7 +11,7 @@ dependencies:
11 11
   flutter:
12 12
     sdk: flutter
13 13
 
14
-  photo_manager: ^0.4.8
14
+  photo_manager: ^0.5.0
15 15
   # photo_manager:
16 16
   #   git:
17 17
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git