Skip to content

Commit cf35c8d

Browse files
committed
Run on iOS
1 parent c1d8a24 commit cf35c8d

File tree

4 files changed

+81
-47
lines changed

4 files changed

+81
-47
lines changed

ios/Flutter/Flutter.podspec

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# NOTE: This podspec is NOT to be published. It is only used as a local source!
3+
#
4+
5+
Pod::Spec.new do |s|
6+
s.name = 'Flutter'
7+
s.version = '1.0.0'
8+
s.summary = 'High-performance, high-fidelity mobile apps.'
9+
s.description = <<-DESC
10+
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
11+
DESC
12+
s.homepage = 'https://flutter.io'
13+
s.license = { :type => 'MIT' }
14+
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
15+
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
16+
s.ios.deployment_target = '8.0'
17+
s.vendored_frameworks = 'Flutter.framework'
18+
end

ios/Podfile

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,72 @@ def parse_KV_file(file, separator='=')
1515
if !File.exists? file_abs_path
1616
return [];
1717
end
18-
pods_ary = []
18+
generated_key_values = {}
1919
skip_line_start_symbols = ["#", "/"]
20-
File.foreach(file_abs_path) { |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-
pods_ary.push({:name => podname, :path => podpath});
28-
else
29-
puts "Invalid plugin specification: #{line}"
30-
end
31-
}
32-
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
3333
end
3434

3535
target 'Runner' do
3636
use_frameworks!
37+
use_modular_headers!
38+
39+
# Flutter Pod
3740

38-
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
39-
# referring to absolute paths on developers' machines.
40-
system('rm -rf .symlinks')
41-
system('mkdir -p .symlinks/plugins')
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.
4248

43-
# Flutter Pods
44-
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
45-
if generated_xcode_build_settings.empty?
46-
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
47-
end
48-
generated_xcode_build_settings.map { |p|
49-
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
50-
symlink = File.join('.symlinks', 'flutter')
51-
File.symlink(File.dirname(p[:path]), symlink)
52-
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
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"
5352
end
54-
}
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'
5566

5667
# 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')
5773
plugin_pods = parse_KV_file('../.flutter-plugins')
58-
plugin_pods.map { |p|
59-
symlink = File.join('.symlinks', 'plugins', p[:name])
60-
File.symlink(p[:path], symlink)
61-
pod p[:name], :path => File.join(symlink, 'ios')
62-
}
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
6379
end
6480

81+
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
82+
install! 'cocoapods', :disable_input_output_paths => true
83+
6584
post_install do |installer|
6685
installer.pods_project.targets.each do |target|
6786
target.build_configurations.each do |config|

ios/Podfile.lock

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,35 @@ PODS:
66
- Flutter
77
- url_launcher (0.0.1):
88
- Flutter
9+
- url_launcher_web (0.0.1):
10+
- Flutter
911

1012
DEPENDENCIES:
11-
- Flutter (from `.symlinks/flutter/ios`)
13+
- Flutter (from `Flutter`)
1214
- liquid_swipe (from `.symlinks/plugins/liquid_swipe/ios`)
1315
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
1416
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
17+
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)
1518

1619
EXTERNAL SOURCES:
1720
Flutter:
18-
:path: ".symlinks/flutter/ios"
21+
:path: Flutter
1922
liquid_swipe:
2023
:path: ".symlinks/plugins/liquid_swipe/ios"
2124
shared_preferences:
2225
:path: ".symlinks/plugins/shared_preferences/ios"
2326
url_launcher:
2427
:path: ".symlinks/plugins/url_launcher/ios"
28+
url_launcher_web:
29+
:path: ".symlinks/plugins/url_launcher_web/ios"
2530

2631
SPEC CHECKSUMS:
2732
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
2833
liquid_swipe: d3dbe523989a927528e7e7d2d0fc674da90cbbf7
2934
shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523
30-
url_launcher: 0067ddb8f10d36786672aa0722a21717dba3a298
35+
url_launcher: a1c0cc845906122c4784c542523d8cacbded5626
36+
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
3137

32-
PODFILE CHECKSUM: ebd43b443038e611b86ede96e613bd6033c49497
38+
PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83
3339

3440
COCOAPODS: 1.7.2

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,9 @@
242242
files = (
243243
);
244244
inputPaths = (
245-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
246-
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
247-
"${BUILT_PRODUCTS_DIR}/liquid_swipe/liquid_swipe.framework",
248-
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
249-
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
250245
);
251246
name = "[CP] Embed Pods Frameworks";
252247
outputPaths = (
253-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
254-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/liquid_swipe.framework",
255-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
256-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
257248
);
258249
runOnlyForDeploymentPostprocessing = 0;
259250
shellPath = /bin/sh;

0 commit comments

Comments
 (0)