Skip to content

Commit 21ade49

Browse files
authored
Merge pull request #251 from woodwen/master
升级安卓/ios依赖库
2 parents e319bc6 + 0345c06 commit 21ade49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+592
-248
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.packages
55
.pub/
66
.idea/
7+
.fvm/
78

89
pubspec.lock
910

android/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ group 'com.example.imagegallerysaver'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.6.10'
5+
ext.kotlin_version = '1.7.10'
66
repositories {
77
google()
8-
jcenter()
8+
mavenCentral()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:7.1.2'
12+
classpath 'com.android.tools.build:gradle:7.2.0'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}
1616

1717
rootProject.allprojects {
1818
repositories {
1919
google()
20-
jcenter()
20+
mavenCentral()
2121
}
2222
}
2323

android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

example/android/app/build.gradle

+9-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 31
29+
compileSdkVersion flutter.compileSdkVersion
30+
ndkVersion flutter.ndkVersion
3031

3132
compileOptions {
3233
sourceCompatibility JavaVersion.VERSION_1_8
3334
targetCompatibility JavaVersion.VERSION_1_8
3435
}
36+
37+
kotlinOptions {
38+
jvmTarget = '1.8'
39+
}
40+
3541
sourceSets {
3642
main.java.srcDirs += 'src/main/kotlin'
3743
}
@@ -41,10 +47,9 @@ android {
4147
}
4248

4349
defaultConfig {
44-
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4550
applicationId "com.example.imagegallerysaverexample"
46-
minSdkVersion 16
47-
targetSdkVersion 29
51+
minSdkVersion flutter.minSdkVersion
52+
targetSdkVersion flutter.targetSdkVersion
4853
versionCode flutterVersionCode.toInteger()
4954
versionName flutterVersionName
5055
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

example/android/app/src/main/AndroidManifest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-->
88
<uses-permission android:name="android.permission.INTERNET"/>
99
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
10+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
1011

1112
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
1213
calls FlutterMain.startInitialization(this); in its onCreate method.
@@ -20,6 +21,7 @@
2021
android:icon="@mipmap/ic_launcher">
2122
<activity
2223
android:name="io.flutter.embedding.android.FlutterActivity"
24+
android:exported="true"
2325
android:launchMode="singleTop"
2426
android:theme="@style/LaunchTheme"
2527
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"

example/android/build.gradle

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
buildscript {
2-
ext.kotlin_version = '1.6.10'
2+
ext.kotlin_version = '1.7.10'
33
repositories {
44
google()
5-
jcenter()
5+
mavenCentral()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.1.2'
9+
classpath 'com.android.tools.build:gradle:7.2.0'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}
1313

1414
allprojects {
1515
repositories {
1616
google()
17-
jcenter()
17+
mavenCentral()
1818
}
1919
}
2020

@@ -26,6 +26,6 @@ subprojects {
2626
project.evaluationDependsOn(':app')
2727
}
2828

29-
task clean(type: Delete) {
29+
tasks.register("clean", Delete) {
3030
delete rootProject.buildDir
3131
}

example/android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

example/ios/.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
**/dgph
2+
*.mode1v3
3+
*.mode2v3
4+
*.moved-aside
5+
*.pbxuser
6+
*.perspectivev3
7+
**/*sync/
8+
.sconsign.dblite
9+
.tags*
10+
**/.vagrant/
11+
**/DerivedData/
12+
Icon?
13+
**/Pods/
14+
**/.symlinks/
15+
profile
16+
xcuserdata
17+
**/.generated/
18+
Flutter/App.framework
19+
Flutter/Flutter.framework
20+
Flutter/Flutter.podspec
21+
Flutter/Generated.xcconfig
22+
Flutter/ephemeral/
23+
Flutter/app.flx
24+
Flutter/app.zip
25+
Flutter/flutter_assets/
26+
Flutter/flutter_export_environment.sh
27+
ServiceDefinitions.json
28+
Runner/GeneratedPluginRegistrant.*
29+
30+
# Exceptions to above rules.
31+
!default.mode1v3
32+
!default.mode2v3
33+
!default.pbxuser
34+
!default.perspectivev3

example/ios/Flutter/.last_build_id

-1
This file was deleted.

example/ios/Flutter/AppFrameworkInfo.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>8.0</string>
24+
<string>11.0</string>
2525
</dict>
2626
</plist>

example/ios/Flutter/Debug.xcconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
22
#include "Generated.xcconfig"

example/ios/Flutter/Release.xcconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
22
#include "Generated.xcconfig"

example/ios/Podfile

+19-62
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '9.0'
2+
# platform :ios, '11.0'
3+
4+
# source '源地址'
5+
source 'https://github.com/CocoaPods/Specs.git'
36

47
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
58
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
@@ -10,78 +13,32 @@ project 'Runner', {
1013
'Release' => :release,
1114
}
1215

13-
def parse_KV_file(file, separator='=')
14-
file_abs_path = File.expand_path(file)
15-
if !File.exists? file_abs_path
16-
return [];
16+
def flutter_root
17+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
18+
unless File.exist?(generated_xcode_build_settings_path)
19+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
1720
end
18-
generated_key_values = {}
19-
skip_line_start_symbols = ["#", "/"]
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
21+
22+
File.foreach(generated_xcode_build_settings_path) do |line|
23+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
24+
return matches[1].strip if matches
3125
end
32-
generated_key_values
26+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
3327
end
3428

29+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
30+
31+
flutter_ios_podfile_setup
32+
3533
target 'Runner' do
3634
use_frameworks!
3735
use_modular_headers!
3836

39-
# Flutter Pod
40-
41-
copied_flutter_dir = File.join(__dir__, 'Flutter')
42-
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
43-
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
44-
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
45-
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
46-
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
47-
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
48-
49-
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
50-
unless File.exist?(generated_xcode_build_settings_path)
51-
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
52-
end
53-
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
54-
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
55-
56-
unless File.exist?(copied_framework_path)
57-
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
58-
end
59-
unless File.exist?(copied_podspec_path)
60-
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
61-
end
62-
end
63-
64-
# Keep pod path relative so it can be checked into Podfile.lock.
65-
pod 'Flutter', :path => 'Flutter'
66-
67-
# Plugin Pods
68-
69-
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
70-
# referring to absolute paths on developers' machines.
71-
system('rm -rf .symlinks')
72-
system('mkdir -p .symlinks/plugins')
73-
plugin_pods = parse_KV_file('../.flutter-plugins')
74-
plugin_pods.each do |name, path|
75-
symlink = File.join('.symlinks', 'plugins', name)
76-
File.symlink(path, symlink)
77-
pod name, :path => File.join(symlink, 'ios')
78-
end
37+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
7938
end
8039

8140
post_install do |installer|
8241
installer.pods_project.targets.each do |target|
83-
target.build_configurations.each do |config|
84-
config.build_settings['ENABLE_BITCODE'] = 'NO'
85-
end
42+
flutter_additional_ios_build_settings(target)
8643
end
8744
end

0 commit comments

Comments
 (0)