Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make Podfiles use symlinks to local pods #14748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/internal/engine.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e5b72e5f87cae358b457b6c1cb55c4560ce3c46c
13cf22c284c24f81357aec6a89074a536efbf4d1
20 changes: 20 additions & 0 deletions packages/flutter_tools/lib/src/cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ class FlutterEngine extends CachedArtifact {
<String>['windows-x64', 'dart-sdk-windows-x64.zip'],
];

// A list of cache directory paths to which the LICENSE file should be copied.
List<String> _getLicenseDirs() {
if (cache.includeAllPlatforms || platform.isMacOS) {
return const <String>['ios', 'ios-profile', 'ios-release'];
}
return const <String>[];
}

@override
bool isUpToDateInner() {
final Directory pkgDir = cache.getCacheDir('pkg');
Expand All @@ -416,6 +424,12 @@ class FlutterEngine extends CachedArtifact {
if (!dir.existsSync())
return false;
}

for (String licenseDir in _getLicenseDirs()) {
final File file = fs.file(fs.path.join(location.path, licenseDir, 'LICENSE'));
if (!file.existsSync())
return false;
}
return true;
}

Expand Down Expand Up @@ -447,6 +461,12 @@ class FlutterEngine extends CachedArtifact {
os.unzip(frameworkZip, framework);
}
}

final File licenseSource = fs.file(fs.path.join(Cache.flutterRoot, 'LICENSE'));
for (String licenseDir in _getLicenseDirs()) {
final String licenseDestinationPath = fs.path.join(location.path, licenseDir, 'LICENSE');
await licenseSource.copy(licenseDestinationPath);
}
}

void _makeFilesExecutable(Directory dir) {
Expand Down
34 changes: 22 additions & 12 deletions packages/flutter_tools/templates/cocoapods/Podfile-objc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

def parse_KV_file(file,seperator='=')
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
Expand All @@ -13,12 +13,12 @@ def parse_KV_file(file,seperator='=')
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=seperator)
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname,:path=>podpath});
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
Expand All @@ -27,21 +27,31 @@ def parse_KV_file(file,seperator='=')
end

target 'Runner' do
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf Pods/.symlinks')
system('mkdir -p Pods/.symlinks/flutter')
system('mkdir -p Pods/.symlinks/plugins')

# Flutter Pods
generated_xcode_build_settings = parse_KV_file("./Flutter/Generated.xcconfig")
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter build or flutter run is executed once first."
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map{ |p|
if p[:name]=='FLUTTER_FRAMEWORK_DIR'
pod 'Flutter', :path => p[:path]
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('Pods', '.symlinks', 'flutter', File.basename(p[:path]))
File.symlink(p[:path], symlink)
pod 'Flutter', :path => symlink
end
}

# Plugin Pods
plugin_pods = parse_KV_file("../.flutter-plugins")
plugin_pods.map{ |p|
pod p[:name], :path => File.expand_path("ios",p[:path])
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('Pods', '.symlinks', 'plugins', File.basename(p[:path]))
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end

Expand All @@ -51,4 +61,4 @@ post_install do |installer|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
end
35 changes: 23 additions & 12 deletions packages/flutter_tools/templates/cocoapods/Podfile-swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

def parse_KV_file(file,seperator='=')
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
Expand All @@ -13,12 +13,12 @@ def parse_KV_file(file,seperator='=')
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=seperator)
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname,:path=>podpath});
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
Expand All @@ -28,21 +28,32 @@ end

target 'Runner' do
use_frameworks!

# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf Pods/.symlinks')
system('mkdir -p Pods/.symlinks/flutter')
system('mkdir -p Pods/.symlinks/plugins')

# Flutter Pods
generated_xcode_build_settings = parse_KV_file("./Flutter/Generated.xcconfig")
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter build or flutter run is executed once first."
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map{ |p|
if p[:name]=='FLUTTER_FRAMEWORK_DIR'
pod 'Flutter', :path => p[:path]
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('Pods', '.symlinks', 'flutter', File.basename(p[:path]))
File.symlink(p[:path], symlink)
pod 'Flutter', :path => symlink
end
}

# Plugin Pods
plugin_pods = parse_KV_file("../.flutter-plugins")
plugin_pods.map{ |p|
pod p[:name], :path => File.expand_path("ios",p[:path])
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('Pods', '.symlinks', 'plugins', File.basename(p[:path]))
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end

Expand All @@ -57,4 +68,4 @@ post_install do |installer|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
end