Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
319a61fd
Unverified
Commit
319a61fd
authored
Jun 10, 2020
by
Jenn Magder
Committed by
GitHub
Jun 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move iOS Podfile logic into tool (#59044)
parent
78a4016c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
273 additions
and
301 deletions
+273
-301
plugin_lint_mac.dart
dev/devicelab/bin/tasks/plugin_lint_mac.dart
+57
-1
Podfile
...egration_tests/flutter_driver_screenshot_test/ios/Podfile
+15
-61
project.pbxproj
...iver_screenshot_test/ios/Runner.xcodeproj/project.pbxproj
+5
-0
Podfile
dev/integration_tests/flutter_gallery/ios/Podfile
+14
-58
Podfile
dev/integration_tests/release_smoke_test/ios/Podfile
+14
-60
podhelper.rb
packages/flutter_tools/bin/podhelper.rb
+139
-0
Podfile-ios-objc
packages/flutter_tools/templates/cocoapods/Podfile-ios-objc
+14
-60
Podfile-ios-swift
packages/flutter_tools/templates/cocoapods/Podfile-ios-swift
+15
-61
No files found.
dev/devicelab/bin/tasks/plugin_lint_mac.dart
View file @
319a61fd
...
...
@@ -109,7 +109,7 @@ Future<void> main() async {
String
podspecContent
=
objcPubspec
.
readAsStringSync
();
podspecContent
=
podspecContent
.
replaceFirst
(
'
\n
dependencies:
\n
'
,
'
\n
dependencies:
\n
$objcPluginName
:
\n
path:
$objcPluginPath
\n
$swiftPluginName
:
\n
path:
$swiftPluginPath
\n
'
,
'
\n
dependencies:
\n
$objcPluginName
:
\n
path:
$objcPluginPath
\n
$swiftPluginName
:
\n
path:
$swiftPluginPath
\n
device_info:
\n
'
,
);
objcPubspec
.
writeAsStringSync
(
podspecContent
,
flush:
true
);
...
...
@@ -130,6 +130,7 @@ Future<void> main() async {
if
(
objcPodfileContent
.
contains
(
'use_frameworks!'
))
{
return
TaskResult
.
failure
(
'Expected default Objective-C Podfile to not contain use_frameworks'
);
}
_validatePodfile
(
objcAppPath
);
section
(
'Build Objective-C application with Swift and Objective-C plugins as frameworks'
);
...
...
@@ -199,6 +200,8 @@ Future<void> main() async {
);
});
_validatePodfile
(
swiftAppPath
);
return
TaskResult
.
success
(
null
);
}
catch
(
e
)
{
return
TaskResult
.
failure
(
e
.
toString
());
...
...
@@ -207,3 +210,56 @@ Future<void> main() async {
}
});
}
void
_validatePodfile
(
String
appPath
)
{
section
(
'Validate Podfile'
);
final
File
podfileLockFile
=
File
(
path
.
join
(
appPath
,
'ios'
,
'Podfile.lock'
));
final
String
podfileLockOutput
=
podfileLockFile
.
readAsStringSync
();
if
(!
podfileLockOutput
.
contains
(
':path: ".symlinks/plugins/device_info/ios"'
)
||
!
podfileLockOutput
.
contains
(
':path: Flutter'
)
||
!
podfileLockOutput
.
contains
(
':path: ".symlinks/plugins/test_plugin_objc/ios"'
)
||
!
podfileLockOutput
.
contains
(
':path: ".symlinks/plugins/test_plugin_swift/ios"'
))
{
throw
TaskResult
.
failure
(
'Podfile.lock does not contain expected pods'
);
}
checkFileExists
(
path
.
join
(
appPath
,
'ios'
,
'Flutter'
,
'Flutter.framework'
,
'Flutter'
,
));
checkFileExists
(
path
.
join
(
appPath
,
'ios'
,
'Flutter'
,
'Flutter.podspec'
,
));
final
String
pluginSymlinks
=
path
.
join
(
appPath
,
'ios'
,
'.symlinks'
,
'plugins'
,
);
checkDirectoryExists
(
path
.
join
(
pluginSymlinks
,
'device_info'
,
'ios'
,
));
checkDirectoryExists
(
path
.
join
(
pluginSymlinks
,
'test_plugin_objc'
,
'ios'
,
));
checkDirectoryExists
(
path
.
join
(
pluginSymlinks
,
'test_plugin_swift'
,
'ios'
,
));
}
dev/integration_tests/flutter_driver_screenshot_test/ios/Podfile
View file @
319a61fd
...
...
@@ -10,78 +10,32 @@ project 'Runner', {
'Release'
=>
:release
,
}
def
parse_KV_file
(
file
,
separator
=
'='
)
file_abs_path
=
File
.
expand_path
(
file
)
if
!
File
.
exists?
file_abs_path
return
[];
end
generated_key_values
=
{}
skip_line_start_symbols
=
[
"#"
,
"/"
]
File
.
foreach
(
file_abs_path
)
do
|
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
)
generated_key_values
[
podname
]
=
podpath
else
puts
"Invalid plugin specification:
#{
line
}
"
def
flutter_root
generated_xcode_build_settings_path
=
File
.
expand_path
(
File
.
join
(
'..'
,
'Flutter'
,
'Generated.xcconfig'
),
__FILE__
)
unless
File
.
exist?
(
generated_xcode_build_settings_path
)
raise
"
#{
generated_xcode_build_settings_path
}
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File
.
foreach
(
generated_xcode_build_settings_path
)
do
|
line
|
matches
=
line
.
match
(
/FLUTTER_ROOT\=(.*)/
)
return
matches
[
1
].
strip
if
matches
end
generated_key_values
raise
"FLUTTER_ROOT not found in
#{
generated_xcode_build_settings_path
}
. Try deleting Generated.xcconfig, then run flutter pub get"
end
require
File
.
expand_path
(
File
.
join
(
'packages'
,
'flutter_tools'
,
'bin'
,
'podhelper'
),
flutter_root
)
flutter_ios_podfile_setup
target
'Runner'
do
use_frameworks!
use_modular_headers!
# Flutter Pod
copied_flutter_dir
=
File
.
join
(
__dir__
,
'Flutter'
)
copied_framework_path
=
File
.
join
(
copied_flutter_dir
,
'Flutter.framework'
)
copied_podspec_path
=
File
.
join
(
copied_flutter_dir
,
'Flutter.podspec'
)
unless
File
.
exist?
(
copied_framework_path
)
&&
File
.
exist?
(
copied_podspec_path
)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path
=
File
.
join
(
copied_flutter_dir
,
'Generated.xcconfig'
)
unless
File
.
exist?
(
generated_xcode_build_settings_path
)
raise
"Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings
=
parse_KV_file
(
generated_xcode_build_settings_path
)
cached_framework_dir
=
generated_xcode_build_settings
[
'FLUTTER_FRAMEWORK_DIR'
];
unless
File
.
exist?
(
copied_framework_path
)
FileUtils
.
cp_r
(
File
.
join
(
cached_framework_dir
,
'Flutter.framework'
),
copied_flutter_dir
)
end
unless
File
.
exist?
(
copied_podspec_path
)
FileUtils
.
cp
(
File
.
join
(
cached_framework_dir
,
'Flutter.podspec'
),
copied_flutter_dir
)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod
'Flutter'
,
:path
=>
'Flutter'
# Plugin Pods
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system
(
'rm -rf .symlinks'
)
system
(
'mkdir -p .symlinks/plugins'
)
plugin_pods
=
parse_KV_file
(
'../.flutter-plugins'
)
plugin_pods
.
each
do
|
name
,
path
|
symlink
=
File
.
join
(
'.symlinks'
,
'plugins'
,
name
)
File
.
symlink
(
path
,
symlink
)
pod
name
,
:path
=>
File
.
join
(
symlink
,
'ios'
)
end
flutter_install_all_ios_pods
File
.
dirname
(
File
.
realpath
(
__FILE__
))
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
flutter_additional_ios_build_settings
(
target
)
end
end
dev/integration_tests/flutter_driver_screenshot_test/ios/Runner.xcodeproj/project.pbxproj
View file @
319a61fd
...
...
@@ -262,9 +262,14 @@
files
=
(
);
inputPaths
=
(
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh"
,
"${PODS_ROOT}/../Flutter/Flutter.framework"
,
"${BUILT_PRODUCTS_DIR}/device_info/device_info.framework"
,
);
name
=
"[CP] Embed Pods Frameworks"
;
outputPaths
=
(
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework"
,
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework"
,
);
runOnlyForDeploymentPostprocessing
=
0
;
shellPath
=
/bin/sh
;
...
...
dev/integration_tests/flutter_gallery/ios/Podfile
View file @
319a61fd
...
...
@@ -10,76 +10,32 @@ project 'Runner', {
'Release'
=>
:release
,
}
def
parse_KV_file
(
file
,
separator
=
'='
)
file_abs_path
=
File
.
expand_path
(
file
)
if
!
File
.
exists?
file_abs_path
return
[];
end
generated_key_values
=
{}
skip_line_start_symbols
=
[
"#"
,
"/"
]
File
.
foreach
(
file_abs_path
)
do
|
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
)
generated_key_values
[
podname
]
=
podpath
else
puts
"Invalid plugin specification:
#{
line
}
"
end
end
generated_key_values
end
target
'Runner'
do
# Flutter Pod
copied_flutter_dir
=
File
.
join
(
__dir__
,
'Flutter'
)
copied_framework_path
=
File
.
join
(
copied_flutter_dir
,
'Flutter.framework'
)
copied_podspec_path
=
File
.
join
(
copied_flutter_dir
,
'Flutter.podspec'
)
unless
File
.
exist?
(
copied_framework_path
)
&&
File
.
exist?
(
copied_podspec_path
)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path
=
File
.
join
(
copied_flutter_dir
,
'Generated.xcconfig'
)
def
flutter_root
generated_xcode_build_settings_path
=
File
.
expand_path
(
File
.
join
(
'..'
,
'Flutter'
,
'Generated.xcconfig'
),
__FILE__
)
unless
File
.
exist?
(
generated_xcode_build_settings_path
)
raise
"Generated.xcconfig
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
raise
"
#{
generated_xcode_build_settings_path
}
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings
=
parse_KV_file
(
generated_xcode_build_settings_path
)
cached_framework_dir
=
generated_xcode_build_settings
[
'FLUTTER_FRAMEWORK_DIR'
];
unless
File
.
exist?
(
copied_framework_path
)
FileUtils
.
cp_r
(
File
.
join
(
cached_framework_dir
,
'Flutter.framework'
),
copied_flutter_dir
)
end
unless
File
.
exist?
(
copied_podspec_path
)
FileUtils
.
cp
(
File
.
join
(
cached_framework_dir
,
'Flutter.podspec'
),
copied_flutter_dir
)
end
File
.
foreach
(
generated_xcode_build_settings_path
)
do
|
line
|
matches
=
line
.
match
(
/FLUTTER_ROOT\=(.*)/
)
return
matches
[
1
].
strip
if
matches
end
raise
"FLUTTER_ROOT not found in
#{
generated_xcode_build_settings_path
}
. Try deleting Generated.xcconfig, then run flutter pub get"
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod
'Flutter'
,
:path
=>
'Flutter'
require
File
.
expand_path
(
File
.
join
(
'packages'
,
'flutter_tools'
,
'bin'
,
'podhelper'
),
flutter_root
)
# Plugin Pods
flutter_ios_podfile_setup
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system
(
'rm -rf .symlinks'
)
system
(
'mkdir -p .symlinks/plugins'
)
plugin_pods
=
parse_KV_file
(
'../.flutter-plugins'
)
plugin_pods
.
each
do
|
name
,
path
|
symlink
=
File
.
join
(
'.symlinks'
,
'plugins'
,
name
)
File
.
symlink
(
path
,
symlink
)
pod
name
,
:path
=>
File
.
join
(
symlink
,
'ios'
)
end
target
'Runner'
do
flutter_install_all_ios_pods
File
.
dirname
(
File
.
realpath
(
__FILE__
))
end
post_install
do
|
installer
|
installer
.
pods_project
.
targets
.
each
do
|
target
|
flutter_additional_ios_build_settings
(
target
)
target
.
build_configurations
.
each
do
|
config
|
config
.
build_settings
[
'PROVISIONING_PROFILE_SPECIFIER'
]
=
''
config
.
build_settings
[
'ENABLE_BITCODE'
]
=
'NO'
end
end
end
dev/integration_tests/release_smoke_test/ios/Podfile
View file @
319a61fd
...
...
@@ -10,75 +10,29 @@ project 'Runner', {
'Release'
=>
:release
,
}
def
parse_KV_file
(
file
,
separator
=
'='
)
file_abs_path
=
File
.
expand_path
(
file
)
if
!
File
.
exists?
file_abs_path
return
[];
end
generated_key_values
=
{}
skip_line_start_symbols
=
[
"#"
,
"/"
]
File
.
foreach
(
file_abs_path
)
do
|
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
)
generated_key_values
[
podname
]
=
podpath
else
puts
"Invalid plugin specification:
#{
line
}
"
end
end
generated_key_values
end
target
'Runner'
do
# Flutter Pod
copied_flutter_dir
=
File
.
join
(
__dir__
,
'Flutter'
)
copied_framework_path
=
File
.
join
(
copied_flutter_dir
,
'Flutter.framework'
)
copied_podspec_path
=
File
.
join
(
copied_flutter_dir
,
'Flutter.podspec'
)
unless
File
.
exist?
(
copied_framework_path
)
&&
File
.
exist?
(
copied_podspec_path
)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path
=
File
.
join
(
copied_flutter_dir
,
'Generated.xcconfig'
)
def
flutter_root
generated_xcode_build_settings_path
=
File
.
expand_path
(
File
.
join
(
'..'
,
'Flutter'
,
'Generated.xcconfig'
),
__FILE__
)
unless
File
.
exist?
(
generated_xcode_build_settings_path
)
raise
"Generated.xcconfig
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
raise
"
#{
generated_xcode_build_settings_path
}
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings
=
parse_KV_file
(
generated_xcode_build_settings_path
)
cached_framework_dir
=
generated_xcode_build_settings
[
'FLUTTER_FRAMEWORK_DIR'
];
unless
File
.
exist?
(
copied_framework_path
)
FileUtils
.
cp_r
(
File
.
join
(
cached_framework_dir
,
'Flutter.framework'
),
copied_flutter_dir
)
end
unless
File
.
exist?
(
copied_podspec_path
)
FileUtils
.
cp
(
File
.
join
(
cached_framework_dir
,
'Flutter.podspec'
),
copied_flutter_dir
)
end
File
.
foreach
(
generated_xcode_build_settings_path
)
do
|
line
|
matches
=
line
.
match
(
/FLUTTER_ROOT\=(.*)/
)
return
matches
[
1
].
strip
if
matches
end
raise
"FLUTTER_ROOT not found in
#{
generated_xcode_build_settings_path
}
. Try deleting Generated.xcconfig, then run flutter pub get"
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod
'Flutter'
,
:path
=>
'Flutter'
require
File
.
expand_path
(
File
.
join
(
'packages'
,
'flutter_tools'
,
'bin'
,
'podhelper'
),
flutter_root
)
# Plugin Pods
flutter_ios_podfile_setup
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system
(
'rm -rf .symlinks'
)
system
(
'mkdir -p .symlinks/plugins'
)
plugin_pods
=
parse_KV_file
(
'../.flutter-plugins'
)
plugin_pods
.
each
do
|
name
,
path
|
symlink
=
File
.
join
(
'.symlinks'
,
'plugins'
,
name
)
File
.
symlink
(
path
,
symlink
)
pod
name
,
:path
=>
File
.
join
(
symlink
,
'ios'
)
end
target
'Runner'
do
flutter_install_all_ios_pods
File
.
dirname
(
File
.
realpath
(
__FILE__
))
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
flutter_additional_ios_build_settings
(
target
)
end
end
packages/flutter_tools/bin/podhelper.rb
0 → 100644
View file @
319a61fd
# Copyright 2014 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Minimum CocoaPods Ruby version is 2.0.
# Don't depend on features newer than that.
# Hook for Podfile setup, installation settings.
#
# @example
# flutter_ios_podfile_setup
# target 'Runner' do
# ...
# end
def
flutter_ios_podfile_setup
end
# Add iOS build settings to pod targets.
#
# @example
# post_install do |installer|
# installer.pods_project.targets.each do |target|
# flutter_additional_ios_build_settings(target)
# end
# end
# @param [PBXAggregateTarget] target Pod target.
def
flutter_additional_ios_build_settings
(
target
)
target
.
build_configurations
.
each
do
|
build_configuration
|
build_configuration
.
build_settings
[
'ENABLE_BITCODE'
]
=
'NO'
end
end
# Install pods needed to embed Flutter iOS engine and plugins.
#
# @example
# target 'Runner' do
# flutter_install_all_ios_pods
# end
# @param [String] ios_application_path Path of the iOS directory of the Flutter app.
# Optional, defaults to the Podfile directory.
def
flutter_install_all_ios_pods
(
ios_application_path
=
nil
)
flutter_install_ios_engine_pod
(
ios_application_path
)
flutter_install_ios_plugin_pods
(
ios_application_path
)
end
# Install iOS Flutter engine pod.
#
# @example
# target 'Runner' do
# flutter_install_ios_engine_pod
# end
# @param [String] ios_application_path Path of the iOS directory of the Flutter app.
# Optional, defaults to the Podfile directory.
def
flutter_install_ios_engine_pod
(
ios_application_path
=
nil
)
# defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
ios_application_path
||=
File
.
dirname
(
defined_in_file
.
realpath
)
if
self
.
respond_to?
(
:defined_in_file
)
raise
'Could not find iOS application path'
unless
ios_application_path
copied_flutter_dir
=
File
.
join
(
ios_application_path
,
'Flutter'
)
copied_framework_path
=
File
.
join
(
copied_flutter_dir
,
'Flutter.framework'
)
copied_podspec_path
=
File
.
join
(
copied_flutter_dir
,
'Flutter.podspec'
)
unless
File
.
exist?
(
copied_framework_path
)
&&
File
.
exist?
(
copied_podspec_path
)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration,
# which can handle a local engine.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
# This podhelper script is at $FLUTTER_ROOT/packages/flutter_tools/bin.
# Copy frameworks from $FLUTTER_ROOT/bin/cache/artifacts/engine/ios (Debug).
debug_framework_dir
=
File
.
expand_path
(
File
.
join
(
'..'
,
'..'
,
'..'
,
'..'
,
'bin'
,
'cache'
,
'artifacts'
,
'engine'
,
'ios'
),
__FILE__
)
unless
File
.
exist?
(
copied_framework_path
)
# Avoid the complication of dependencies like FileUtils.
system
(
'cp'
,
'-r'
,
File
.
expand_path
(
'Flutter.framework'
,
debug_framework_dir
),
copied_flutter_dir
)
end
unless
File
.
exist?
(
copied_podspec_path
)
system
(
'cp'
,
File
.
expand_path
(
'Flutter.podspec'
,
debug_framework_dir
),
copied_flutter_dir
)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod
'Flutter'
,
:path
=>
'Flutter'
end
# Install iOS Flutter plugin pods.
#
# @example
# target 'Runner' do
# flutter_install_ios_plugin_pods
# end
# @param [String] ios_application_path Path of the iOS directory of the Flutter app.
# Optional, defaults to the Podfile directory.
def
flutter_install_ios_plugin_pods
(
ios_application_path
=
nil
)
# defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
ios_application_path
||=
File
.
dirname
(
defined_in_file
.
realpath
)
if
self
.
respond_to?
(
:defined_in_file
)
raise
'Could not find iOS application path'
unless
ios_application_path
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
symlink_dir
=
File
.
expand_path
(
'.symlinks'
,
ios_application_path
)
system
(
'rm'
,
'-rf'
,
symlink_dir
)
# Avoid the complication of dependencies like FileUtils.
symlink_plugins_dir
=
File
.
expand_path
(
'plugins'
,
symlink_dir
)
system
(
'mkdir'
,
'-p'
,
symlink_plugins_dir
)
plugins_file
=
File
.
join
(
ios_application_path
,
'..'
,
'.flutter-plugins'
)
plugin_pods
=
flutter_parse_plugins_file
(
plugins_file
)
plugin_pods
.
each
do
|
name
,
path
|
symlink
=
File
.
join
(
symlink_plugins_dir
,
name
)
File
.
symlink
(
path
,
symlink
)
# Keep pod path relative so it can be checked into Podfile.lock.
pod
name
,
:path
=>
File
.
join
(
'.symlinks'
,
'plugins'
,
name
,
'ios'
)
end
end
def
flutter_parse_plugins_file
(
file
)
file_path
=
File
.
expand_path
(
file
)
unless
File
.
exists?
file_path
return
{};
end
generated_key_values
=
{}
skip_line_start_symbols
=
[
"#"
,
"/"
]
File
.
foreach
(
file_path
)
do
|
line
|
next
if
skip_line_start_symbols
.
any?
{
|
symbol
|
line
=~
/^\s*
#{
symbol
}
/
}
plugin
=
line
.
split
(
'='
)
if
plugin
.
length
==
2
podname
=
plugin
[
0
].
strip
path
=
plugin
[
1
].
strip
podpath
=
File
.
expand_path
(
path
,
file_path
)
generated_key_values
[
podname
]
=
File
.
expand_path
(
path
,
file_path
)
else
puts
"Invalid plugin specification:
#{
line
}
"
end
end
generated_key_values
end
packages/flutter_tools/templates/cocoapods/Podfile-ios-objc
View file @
319a61fd
...
...
@@ -10,75 +10,29 @@ project 'Runner', {
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |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)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end
end
generated_key_values
end
target 'Runner' do
# Flutter Pod
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
raise "#{generated_xcode_build_settings_path}
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
# Plugin Pods
flutter_ios_podfile_setup
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
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
flutter_additional_ios_build_settings(target)
end
end
packages/flutter_tools/templates/cocoapods/Podfile-ios-swift
View file @
319a61fd
...
...
@@ -10,78 +10,32 @@ project 'Runner', {
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |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)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
generated_key_values
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
# Flutter Pod
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
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
flutter_additional_ios_build_settings(target)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment