Created
April 9, 2018 14:19
-
-
Save jeroen-meijer/efb9fb5f2d0bbaf7e1ff7b484b2cd30a to your computer and use it in GitHub Desktop.
Temporary solution for flutter/flutter issue #16036: "Flutter/Flutter.h not found." on iOS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Uncomment this line to define a global platform for your project | |
# platform :ios, '9.0' | |
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. | |
ENV['COCOAPODS_DISABLE_STATS'] = 'true' | |
def parse_KV_file(file, separator='=') | |
file_abs_path = File.expand_path(file) | |
if !File.exists? file_abs_path | |
return []; | |
end | |
pods_ary = [] | |
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=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}); | |
else | |
puts "Invalid plugin specification: #{line}" | |
end | |
} | |
return pods_ary | |
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/plugins') | |
# Flutter Pods | |
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 packages get is executed first." | |
end | |
generated_xcode_build_settings.map { |p| | |
if p[:name] == 'FLUTTER_FRAMEWORK_DIR' | |
symlink = File.join('Pods', '.symlinks', 'flutter') | |
File.symlink(File.dirname(p[:path]), symlink) | |
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) | |
end | |
} | |
# Plugin Pods | |
plugin_pods = parse_KV_file('../.flutter-plugins') | |
plugin_pods.map { |p| | |
symlink = File.join('Pods', '.symlinks', 'plugins', p[:name]) | |
File.symlink(p[:path], symlink) | |
pod p[:name], :path => File.join(symlink, 'ios') | |
} | |
end | |
pre_install do |installer| | |
# workaround for https://github.com/CocoaPods/CocoaPods/issues/3289 | |
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} | |
end | |
post_install do |installer| | |
installer.pods_project.targets.each do |target| | |
target.build_configurations.each do |config| | |
config.build_settings['ENABLE_BITCODE'] = 'NO' | |
end | |
target.headers_build_phase.files.each do |file| | |
file.settings = { 'ATTRIBUTES' => ['Public'] } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment