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
c64ace84
Unverified
Commit
c64ace84
authored
May 04, 2018
by
Mikkel Nygaard Ravn
Committed by
GitHub
May 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recommend upgrading to Cocoapods 1.5.0 (#17210)
parent
7984f6e0
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
222 additions
and
118 deletions
+222
-118
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+1
-1
cocoapods.dart
packages/flutter_tools/lib/src/ios/cocoapods.dart
+70
-27
ios_workflow.dart
packages/flutter_tools/lib/src/ios/ios_workflow.dart
+6
-4
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+1
-1
Podfile-objc
packages/flutter_tools/templates/cocoapods/Podfile-objc
+4
-4
Podfile-swift
packages/flutter_tools/templates/cocoapods/Podfile-swift
+4
-4
.gitignore
packages/flutter_tools/templates/create/ios.tmpl/.gitignore
+1
-0
cocoapods_test.dart
packages/flutter_tools/test/ios/cocoapods_test.dart
+127
-63
ios_workflow_test.dart
packages/flutter_tools/test/ios/ios_workflow_test.dart
+8
-14
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
c64ace84
...
...
@@ -52,7 +52,7 @@ Future<T> runInContext<T>(
BotDetector:
()
=>
const
BotDetector
(),
Cache:
()
=>
new
Cache
(),
Clock:
()
=>
const
Clock
(),
CocoaPods:
()
=>
const
CocoaPods
(),
CocoaPods:
()
=>
new
CocoaPods
(),
Config:
()
=>
new
Config
(),
DevFSConfig:
()
=>
new
DevFSConfig
(),
DeviceManager:
()
=>
new
DeviceManager
(),
...
...
packages/flutter_tools/lib/src/ios/cocoapods.dart
View file @
c64ace84
...
...
@@ -33,25 +33,46 @@ const String cocoaPodsUpgradeInstructions = '''
CocoaPods
get
cocoaPods
=>
context
[
CocoaPods
];
class
CocoaPods
{
const
CocoaPods
();
/// Result of evaluating the CocoaPods installation.
enum
CocoaPodsStatus
{
/// iOS plugins will not work, installation required.
notInstalled
,
/// iOS plugins will not work, upgrade required.
belowMinimumVersion
,
/// iOS plugins may not work in certain situations (Swift, static libraries),
/// upgrade recommended.
belowRecommendedVersion
,
/// Everything should be fine.
recommended
,
}
Future
<
bool
>
get
hasCocoaPods
=>
exitsHappyAsync
(<
String
>[
'pod'
,
'--version'
]);
class
CocoaPods
{
Future
<
String
>
_versionText
;
// TODO(mravn): Insist on 1.5.0 once build bots have that installed.
// Earlier versions do not work with Swift and static libraries.
String
get
cocoaPodsMinimumVersion
=>
'1.0.0'
;
String
get
cocoaPodsRecommendedVersion
=>
'1.5.0'
;
Future
<
String
>
get
cocoaPodsVersionText
async
=>
(
await
runAsync
(<
String
>[
'pod'
,
'--version'
])).
processResult
.
stdout
.
trim
();
Future
<
String
>
get
cocoaPodsVersionText
{
_versionText
??=
runAsync
(<
String
>[
'pod'
,
'--version'
]).
then
<
String
>((
RunResult
result
)
{
return
result
.
exitCode
==
0
?
result
.
stdout
.
trim
()
:
null
;
});
return
_versionText
;
}
Future
<
bool
>
get
isCocoaPodsInstalledAndMeetsVersionCheck
async
{
if
(!
await
hasCocoaPods
)
return
false
;
Future
<
CocoaPodsStatus
>
get
evaluateCocoaPodsInstallation
async
{
final
String
versionText
=
await
cocoaPodsVersionText
;
if
(
versionText
==
null
)
return
CocoaPodsStatus
.
notInstalled
;
try
{
final
Version
installedVersion
=
new
Version
.
parse
(
await
cocoaPodsVersionText
);
return
installedVersion
>=
new
Version
.
parse
(
cocoaPodsMinimumVersion
);
final
Version
installedVersion
=
new
Version
.
parse
(
versionText
);
if
(
installedVersion
<
new
Version
.
parse
(
cocoaPodsMinimumVersion
))
return
CocoaPodsStatus
.
belowMinimumVersion
;
else
if
(
installedVersion
<
new
Version
.
parse
(
cocoaPodsRecommendedVersion
))
return
CocoaPodsStatus
.
belowRecommendedVersion
;
else
return
CocoaPodsStatus
.
recommended
;
}
on
FormatException
{
return
false
;
return
CocoaPodsStatus
.
notInstalled
;
}
}
...
...
@@ -79,16 +100,37 @@ class CocoaPods {
/// Make sure the CocoaPods tools are in the right states.
Future
<
bool
>
_checkPodCondition
()
async
{
if
(!
await
isCocoaPodsInstalledAndMeetsVersionCheck
)
{
final
String
minimumVersion
=
cocoaPodsMinimumVersion
;
printError
(
'Warning: CocoaPods version
$minimumVersion
or greater not installed. Skipping pod install.
\n
'
'
$noCocoaPodsConsequence
\n
'
'To install:
\n
'
'
$cocoaPodsInstallInstructions
\n
'
,
emphasis:
true
,
);
return
false
;
final
CocoaPodsStatus
installation
=
await
evaluateCocoaPodsInstallation
;
switch
(
installation
)
{
case
CocoaPodsStatus
.
notInstalled
:
printError
(
'Warning: CocoaPods not installed. Skipping pod install.
\n
'
'
$noCocoaPodsConsequence
\n
'
'To install:
\n
'
'
$cocoaPodsInstallInstructions
\n
'
,
emphasis:
true
,
);
return
false
;
case
CocoaPodsStatus
.
belowMinimumVersion
:
printError
(
'Warning: CocoaPods minimum required version
$cocoaPodsMinimumVersion
or greater not installed. Skipping pod install.
\n
'
'
$noCocoaPodsConsequence
\n
'
'To upgrade:
\n
'
'
$cocoaPodsUpgradeInstructions
\n
'
,
emphasis:
true
,
);
return
false
;
case
CocoaPodsStatus
.
belowRecommendedVersion
:
printError
(
'Warning: CocoaPods recommended version
$cocoaPodsRecommendedVersion
or greater not installed.
\n
'
'Pods handling may fail on some projects involving plugins.
\n
'
'To upgrade:
\n
'
'
$cocoaPodsUpgradeInstructions
\n
'
,
emphasis:
true
,
);
break
;
default
:
break
;
}
if
(!
await
isCocoaPodsInitialized
)
{
printError
(
...
...
@@ -155,19 +197,20 @@ class CocoaPods {
// Check if you need to run pod install.
// The pod install will run if any of below is true.
// 1.
The flutter.framework has changed (debug/release/profile)
// 2.
The podfile.lock doesn't exist
// 3.
The
Pods/Manifest.lock doesn't exist (It is deleted when plugins change)
// 4.
The p
odfile.lock doesn't match Pods/Manifest.lock.
// 1.
Flutter dependencies have changed
// 2.
Podfile.lock doesn't exist or is older than Podfile
// 3. Pods/Manifest.lock doesn't exist (It is deleted when plugins change)
// 4.
P
odfile.lock doesn't match Pods/Manifest.lock.
bool
_shouldRunPodInstall
(
Directory
appIosDirectory
,
bool
dependenciesChanged
)
{
if
(
dependenciesChanged
)
return
true
;
// Check if podfile.lock and Pods/Manifest.lock exist and match.
final
File
podfileFile
=
appIosDirectory
.
childFile
(
'Podfile'
);
final
File
podfileLockFile
=
appIosDirectory
.
childFile
(
'Podfile.lock'
);
final
File
manifestLockFile
=
appIosDirectory
.
childFile
(
fs
.
path
.
join
(
'Pods'
,
'Manifest.lock'
));
return
!
podfileLockFile
.
existsSync
()
||
!
manifestLockFile
.
existsSync
()
||
podfileLockFile
.
statSync
().
modified
.
isBefore
(
podfileFile
.
statSync
().
modified
)
||
podfileLockFile
.
readAsStringSync
()
!=
manifestLockFile
.
readAsStringSync
();
}
...
...
packages/flutter_tools/lib/src/ios/ios_workflow.dart
View file @
c64ace84
...
...
@@ -171,7 +171,9 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
}
}
if
(
await
cocoaPods
.
isCocoaPodsInstalledAndMeetsVersionCheck
)
{
final
CocoaPodsStatus
cocoaPodsStatus
=
await
cocoaPods
.
evaluateCocoaPodsInstallation
;
if
(
cocoaPodsStatus
==
CocoaPodsStatus
.
recommended
)
{
if
(
await
cocoaPods
.
isCocoaPodsInitialized
)
{
messages
.
add
(
new
ValidationMessage
(
'CocoaPods version
${await cocoaPods.cocoaPodsVersionText}
'
));
}
else
{
...
...
@@ -186,7 +188,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
}
}
else
{
brewStatus
=
ValidationType
.
partial
;
if
(
!
await
cocoaPods
.
hasCocoaPods
)
{
if
(
cocoaPodsStatus
==
CocoaPodsStatus
.
notInstalled
)
{
messages
.
add
(
new
ValidationMessage
.
error
(
'CocoaPods not installed.
\n
'
'
$noCocoaPodsConsequence
\n
'
...
...
@@ -194,8 +196,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
'
$cocoaPodsInstallInstructions
'
));
}
else
{
messages
.
add
(
new
ValidationMessage
.
error
(
'CocoaPods out of date (
$
cocoaPods
.cocoaPodsMinimumVersion is requir
ed).
\n
'
messages
.
add
(
new
ValidationMessage
.
hint
(
'CocoaPods out of date (
$
{cocoaPods.cocoaPodsRecommendedVersion}
is recommend
ed).
\n
'
'
$noCocoaPodsConsequence
\n
'
'To upgrade:
\n
'
'
$cocoaPodsUpgradeInstructions
'
...
...
packages/flutter_tools/lib/src/plugins.dart
View file @
c64ace84
...
...
@@ -238,7 +238,7 @@ void injectPlugins({String directory}) {
_writeAndroidPluginRegistrant
(
directory
,
plugins
);
if
(
fs
.
isDirectorySync
(
fs
.
path
.
join
(
directory
,
'ios'
)))
{
_writeIOSPluginRegistrant
(
directory
,
plugins
);
const
CocoaPods
cocoaPods
=
const
CocoaPods
();
final
CocoaPods
cocoaPods
=
new
CocoaPods
();
if
(
plugins
.
isNotEmpty
)
cocoaPods
.
setupPodfile
(
directory
);
if
(
changed
)
...
...
packages/flutter_tools/templates/cocoapods/Podfile-objc
View file @
c64ace84
...
...
@@ -29,8 +29,8 @@ 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/plugins')
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
...
...
@@ -39,7 +39,7 @@ target 'Runner' do
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('
Pods', '
.symlinks', 'flutter')
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
...
...
@@ -48,7 +48,7 @@ target 'Runner' do
# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('
Pods', '
.symlinks', 'plugins', p[:name])
symlink = File.join('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
...
...
packages/flutter_tools/templates/cocoapods/Podfile-swift
View file @
c64ace84
...
...
@@ -31,8 +31,8 @@ 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/plugins')
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
...
...
@@ -41,7 +41,7 @@ target 'Runner' do
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('
Pods', '
.symlinks', 'flutter')
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
...
...
@@ -50,7 +50,7 @@ target 'Runner' do
# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('
Pods', '
.symlinks', 'plugins', p[:name])
symlink = File.join('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
...
...
packages/flutter_tools/templates/create/ios.tmpl/.gitignore
View file @
c64ace84
...
...
@@ -42,3 +42,4 @@ Icon?
/ServiceDefinitions.json
Pods/
.symlinks/
packages/flutter_tools/test/ios/cocoapods_test.dart
View file @
c64ace84
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/ios/ios_workflow_test.dart
View file @
c64ace84
...
...
@@ -33,10 +33,10 @@ void main() {
cocoaPods
=
new
MockCocoaPods
();
fs
=
new
MemoryFileSystem
();
when
(
cocoaPods
.
isCocoaPodsInstalledAndMeetsVersionCheck
)
.
thenAnswer
((
_
)
=>
new
Future
<
bool
>.
value
(
true
)
);
when
(
cocoaPods
.
isCocoaPodsInitialized
)
.
thenAnswer
((
_
)
=>
new
Future
<
bool
>.
value
(
true
)
);
when
(
cocoaPods
.
evaluateCocoaPodsInstallation
)
.
thenAnswer
((
_
)
async
=>
CocoaPodsStatus
.
recommended
);
when
(
cocoaPods
.
isCocoaPodsInitialized
)
.
thenAnswer
((
_
)
async
=>
true
);
when
(
cocoaPods
.
cocoaPodsVersionText
).
thenAnswer
((
_
)
async
=>
'1.8.0'
);
});
testUsingContext
(
'Emit missing status when nothing is installed'
,
()
async
{
...
...
@@ -213,9 +213,8 @@ void main() {
.
thenReturn
(
'Xcode 8.2.1
\n
Build version 8C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
true
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
true
);
when
(
cocoaPods
.
isCocoaPodsInstalledAndMeetsVersionCheck
)
.
thenAnswer
((
_
)
=>
new
Future
<
bool
>.
value
(
false
));
when
(
cocoaPods
.
hasCocoaPods
).
thenAnswer
((
_
)
=>
new
Future
<
bool
>.
value
(
false
));
when
(
cocoaPods
.
evaluateCocoaPodsInstallation
)
.
thenAnswer
((
_
)
async
=>
CocoaPodsStatus
.
notInstalled
);
when
(
xcode
.
isSimctlInstalled
).
thenReturn
(
true
);
final
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
();
final
ValidationResult
result
=
await
workflow
.
validate
();
...
...
@@ -232,11 +231,8 @@ void main() {
.
thenReturn
(
'Xcode 8.2.1
\n
Build version 8C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
true
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
true
);
when
(
cocoaPods
.
isCocoaPodsInstalledAndMeetsVersionCheck
)
.
thenAnswer
((
_
)
=>
new
Future
<
bool
>.
value
(
false
));
when
(
cocoaPods
.
hasCocoaPods
).
thenAnswer
((
_
)
=>
new
Future
<
bool
>.
value
(
true
));
when
(
cocoaPods
.
cocoaPodsVersionText
)
.
thenAnswer
((
_
)
=>
new
Future
<
String
>.
value
(
'0.39.0'
));
when
(
cocoaPods
.
evaluateCocoaPodsInstallation
)
.
thenAnswer
((
_
)
async
=>
CocoaPodsStatus
.
belowRecommendedVersion
);
when
(
xcode
.
isSimctlInstalled
).
thenReturn
(
true
);
final
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
();
final
ValidationResult
result
=
await
workflow
.
validate
();
...
...
@@ -253,8 +249,6 @@ void main() {
.
thenReturn
(
'Xcode 8.2.1
\n
Build version 8C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
true
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
true
);
when
(
cocoaPods
.
isCocoaPodsInstalledAndMeetsVersionCheck
).
thenAnswer
((
_
)
async
=>
false
);
when
(
cocoaPods
.
hasCocoaPods
).
thenAnswer
((
_
)
async
=>
true
);
when
(
cocoaPods
.
isCocoaPodsInitialized
).
thenAnswer
((
_
)
async
=>
false
);
when
(
xcode
.
isSimctlInstalled
).
thenReturn
(
true
);
...
...
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