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
f7f1685c
Unverified
Commit
f7f1685c
authored
Feb 17, 2018
by
xster
Committed by
GitHub
Feb 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure broken pod install runs triggers pod install on next flutter build (#14753)
parent
297fd943
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
28 deletions
+66
-28
cocoapods.dart
packages/flutter_tools/lib/src/ios/cocoapods.dart
+22
-19
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+1
-1
cocoapods_test.dart
packages/flutter_tools/test/ios/cocoapods_test.dart
+43
-8
No files found.
packages/flutter_tools/lib/src/ios/cocoapods.dart
View file @
f7f1685c
...
@@ -57,18 +57,19 @@ class CocoaPods {
...
@@ -57,18 +57,19 @@ class CocoaPods {
Future
<
bool
>
get
isCocoaPodsInitialized
=>
fs
.
isDirectory
(
fs
.
path
.
join
(
homeDirPath
,
'.cocoapods'
,
'repos'
,
'master'
));
Future
<
bool
>
get
isCocoaPodsInitialized
=>
fs
.
isDirectory
(
fs
.
path
.
join
(
homeDirPath
,
'.cocoapods'
,
'repos'
,
'master'
));
Future
<
Null
>
processPods
({
Future
<
Null
>
processPods
({
@required
Directory
appIosDir
,
@required
Directory
appIosDir
ectory
,
// For backward compatibility with previously created Podfile only.
// For backward compatibility with previously created Podfile only.
@required
String
iosEngineDir
,
@required
String
iosEngineDir
,
bool
isSwift:
false
,
bool
isSwift:
false
,
bool
flutterPodChanged:
true
,
bool
flutterPodChanged:
true
,
})
async
{
})
async
{
if
(!(
await
appIosDir
.
childFile
(
'Podfile'
).
exists
()))
{
if
(!(
await
appIosDir
ectory
.
childFile
(
'Podfile'
).
exists
()))
{
throwToolExit
(
'Podfile missing'
);
throwToolExit
(
'Podfile missing'
);
}
}
if
(
await
_checkPodCondition
())
{
if
(
await
_checkPodCondition
())
{
if
(
_shouldRunPodInstall
(
appIosDir
.
path
,
flutterPodChanged
))
if
(
_shouldRunPodInstall
(
appIosDirectory
,
flutterPodChanged
))
{
await
_runPodInstall
(
appIosDir
,
iosEngineDir
);
await
_runPodInstall
(
appIosDirectory
,
iosEngineDir
);
}
}
}
}
}
...
@@ -100,18 +101,18 @@ class CocoaPods {
...
@@ -100,18 +101,18 @@ class CocoaPods {
return
true
;
return
true
;
}
}
/// Ensures the `ios` sub-project of the Flutter project at [
d
irectory]
/// Ensures the `ios` sub-project of the Flutter project at [
appD
irectory]
/// contains a suitable `Podfile` and that its `Flutter/Xxx.xcconfig` files
/// contains a suitable `Podfile` and that its `Flutter/Xxx.xcconfig` files
/// include pods configuration.
/// include pods configuration.
void
setupPodfile
(
String
d
irectory
)
{
void
setupPodfile
(
String
appD
irectory
)
{
if
(!
xcodeProjectInterpreter
.
canInterpretXcodeProjects
)
{
if
(!
xcodeProjectInterpreter
.
canInterpretXcodeProjects
)
{
// Don't do anything for iOS when host platform doesn't support it.
// Don't do anything for iOS when host platform doesn't support it.
return
;
return
;
}
}
final
String
podfilePath
=
fs
.
path
.
join
(
d
irectory
,
'ios'
,
'Podfile'
);
final
String
podfilePath
=
fs
.
path
.
join
(
appD
irectory
,
'ios'
,
'Podfile'
);
if
(!
fs
.
file
(
podfilePath
).
existsSync
())
{
if
(!
fs
.
file
(
podfilePath
).
existsSync
())
{
final
bool
isSwift
=
xcodeProjectInterpreter
.
getBuildSettings
(
final
bool
isSwift
=
xcodeProjectInterpreter
.
getBuildSettings
(
fs
.
path
.
join
(
d
irectory
,
'ios'
,
'Runner.xcodeproj'
),
fs
.
path
.
join
(
appD
irectory
,
'ios'
,
'Runner.xcodeproj'
),
'Runner'
,
'Runner'
,
).
containsKey
(
'SWIFT_VERSION'
);
).
containsKey
(
'SWIFT_VERSION'
);
final
File
podfileTemplate
=
fs
.
file
(
fs
.
path
.
join
(
final
File
podfileTemplate
=
fs
.
file
(
fs
.
path
.
join
(
...
@@ -124,12 +125,12 @@ class CocoaPods {
...
@@ -124,12 +125,12 @@ class CocoaPods {
));
));
podfileTemplate
.
copySync
(
podfilePath
);
podfileTemplate
.
copySync
(
podfilePath
);
}
}
_addPodsDependencyToFlutterXcconfig
(
d
irectory
,
'Debug'
);
_addPodsDependencyToFlutterXcconfig
(
appD
irectory
,
'Debug'
);
_addPodsDependencyToFlutterXcconfig
(
d
irectory
,
'Release'
);
_addPodsDependencyToFlutterXcconfig
(
appD
irectory
,
'Release'
);
}
}
void
_addPodsDependencyToFlutterXcconfig
(
String
d
irectory
,
String
mode
)
{
void
_addPodsDependencyToFlutterXcconfig
(
String
appD
irectory
,
String
mode
)
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
d
irectory
,
'ios'
,
'Flutter'
,
'
$mode
.xcconfig'
));
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
appD
irectory
,
'ios'
,
'Flutter'
,
'
$mode
.xcconfig'
));
if
(
file
.
existsSync
())
{
if
(
file
.
existsSync
())
{
final
String
content
=
file
.
readAsStringSync
();
final
String
content
=
file
.
readAsStringSync
();
final
String
include
=
'#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.
${mode
final
String
include
=
'#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.
${mode
...
@@ -140,9 +141,9 @@ class CocoaPods {
...
@@ -140,9 +141,9 @@ class CocoaPods {
}
}
/// Ensures that pod install is deemed needed on next check.
/// Ensures that pod install is deemed needed on next check.
void
invalidatePodInstallOutput
(
String
d
irectory
)
{
void
invalidatePodInstallOutput
(
String
appD
irectory
)
{
final
File
manifest
=
fs
.
file
(
final
File
manifest
=
fs
.
file
(
fs
.
path
.
join
(
d
irectory
,
'ios'
,
'Pods'
,
'Manifest.lock'
),
fs
.
path
.
join
(
appD
irectory
,
'ios'
,
'Pods'
,
'Manifest.lock'
),
);
);
if
(
manifest
.
existsSync
())
if
(
manifest
.
existsSync
())
manifest
.
deleteSync
();
manifest
.
deleteSync
();
...
@@ -154,22 +155,23 @@ class CocoaPods {
...
@@ -154,22 +155,23 @@ class CocoaPods {
// 2. The podfile.lock doesn't exist
// 2. The podfile.lock doesn't exist
// 3. The Pods/Manifest.lock doesn't exist (It is deleted when plugins change)
// 3. The Pods/Manifest.lock doesn't exist (It is deleted when plugins change)
// 4. The podfile.lock doesn't match Pods/Manifest.lock.
// 4. The podfile.lock doesn't match Pods/Manifest.lock.
bool
_shouldRunPodInstall
(
String
appDir
,
bool
flutterPodChanged
)
{
bool
_shouldRunPodInstall
(
Directory
appIosDirectory
,
bool
flutterPodChanged
)
{
if
(
flutterPodChanged
)
if
(
flutterPodChanged
)
return
true
;
return
true
;
// Check if podfile.lock and Pods/Manifest.lock exist and match.
// Check if podfile.lock and Pods/Manifest.lock exist and match.
final
File
podfileLockFile
=
fs
.
file
(
fs
.
path
.
join
(
appDir
,
'Podfile.lock'
));
final
File
podfileLockFile
=
appIosDirectory
.
childFile
(
'Podfile.lock'
);
final
File
manifestLockFile
=
fs
.
file
(
fs
.
path
.
join
(
appDir
,
'Pods'
,
'Manifest.lock'
));
final
File
manifestLockFile
=
appIosDirectory
.
childFile
(
fs
.
path
.
join
(
'Pods'
,
'Manifest.lock'
));
return
!
podfileLockFile
.
existsSync
()
return
!
podfileLockFile
.
existsSync
()
||
!
manifestLockFile
.
existsSync
()
||
!
manifestLockFile
.
existsSync
()
||
podfileLockFile
.
readAsStringSync
()
!=
manifestLockFile
.
readAsStringSync
();
||
podfileLockFile
.
readAsStringSync
()
!=
manifestLockFile
.
readAsStringSync
();
}
}
Future
<
Null
>
_runPodInstall
(
Directory
bundle
,
String
engineDirectory
)
async
{
Future
<
Null
>
_runPodInstall
(
Directory
appIosDirectory
,
String
engineDirectory
)
async
{
final
Status
status
=
logger
.
startProgress
(
'Running pod install...'
,
expectSlowOperation:
true
);
final
Status
status
=
logger
.
startProgress
(
'Running pod install...'
,
expectSlowOperation:
true
);
final
ProcessResult
result
=
await
processManager
.
run
(
final
ProcessResult
result
=
await
processManager
.
run
(
<
String
>[
'pod'
,
'install'
,
'--verbose'
],
<
String
>[
'pod'
,
'install'
,
'--verbose'
],
workingDirectory:
bundle
.
path
,
workingDirectory:
appIosDirectory
.
path
,
environment:
<
String
,
String
>{
environment:
<
String
,
String
>{
// For backward compatibility with previously created Podfile only.
// For backward compatibility with previously created Podfile only.
'FLUTTER_FRAMEWORK_DIR'
:
engineDirectory
,
'FLUTTER_FRAMEWORK_DIR'
:
engineDirectory
,
...
@@ -190,6 +192,7 @@ class CocoaPods {
...
@@ -190,6 +192,7 @@ class CocoaPods {
}
}
}
}
if
(
result
.
exitCode
!=
0
)
{
if
(
result
.
exitCode
!=
0
)
{
invalidatePodInstallOutput
(
appIosDirectory
.
parent
.
path
);
_diagnosePodInstallFailure
(
result
);
_diagnosePodInstallFailure
(
result
);
throwToolExit
(
'Error running pod install'
);
throwToolExit
(
'Error running pod install'
);
}
}
...
...
packages/flutter_tools/lib/src/ios/mac.dart
View file @
f7f1685c
...
@@ -268,7 +268,7 @@ Future<XcodeBuildResult> buildXcodeProject({
...
@@ -268,7 +268,7 @@ Future<XcodeBuildResult> buildXcodeProject({
if
(
hasPlugins
())
{
if
(
hasPlugins
())
{
final
String
currentGeneratedXcconfig
=
readGeneratedXcconfig
(
app
.
appDirectory
);
final
String
currentGeneratedXcconfig
=
readGeneratedXcconfig
(
app
.
appDirectory
);
await
cocoaPods
.
processPods
(
await
cocoaPods
.
processPods
(
appIosDir:
appDirectory
,
appIosDir
ectory
:
appDirectory
,
iosEngineDir:
flutterFrameworkDir
(
buildInfo
.
mode
),
iosEngineDir:
flutterFrameworkDir
(
buildInfo
.
mode
),
isSwift:
app
.
isSwift
,
isSwift:
app
.
isSwift
,
flutterPodChanged:
(
previousGeneratedXcconfig
!=
currentGeneratedXcconfig
),
flutterPodChanged:
(
previousGeneratedXcconfig
!=
currentGeneratedXcconfig
),
...
...
packages/flutter_tools/test/ios/cocoapods_test.dart
View file @
f7f1685c
...
@@ -129,7 +129,7 @@ void main() {
...
@@ -129,7 +129,7 @@ void main() {
projectUnderTest
.
childFile
(
'Podfile'
).
createSync
();
projectUnderTest
.
childFile
(
'Podfile'
).
createSync
();
cocoaPodsUnderTest
=
const
TestCocoaPods
(
false
);
cocoaPodsUnderTest
=
const
TestCocoaPods
(
false
);
await
cocoaPodsUnderTest
.
processPods
(
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
iosEngineDir:
'engine/path'
,
);
);
verifyNever
(
mockProcessManager
.
run
(
verifyNever
(
mockProcessManager
.
run
(
...
@@ -148,7 +148,7 @@ void main() {
...
@@ -148,7 +148,7 @@ void main() {
cocoaPodsUnderTest
=
const
TestCocoaPods
(
true
);
cocoaPodsUnderTest
=
const
TestCocoaPods
(
true
);
try
{
try
{
await
cocoaPodsUnderTest
.
processPods
(
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
iosEngineDir:
'engine/path'
,
);
);
fail
(
'ToolExit expected'
);
fail
(
'ToolExit expected'
);
...
@@ -198,7 +198,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
...
@@ -198,7 +198,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
));
));
try
{
try
{
await
cocoaPodsUnderTest
.
processPods
(
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
iosEngineDir:
'engine/path'
,
);
);
fail
(
'ToolExit expected'
);
fail
(
'ToolExit expected'
);
...
@@ -222,7 +222,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
...
@@ -222,7 +222,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Existing lock file.'
);
..
writeAsString
(
'Existing lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
false
,
flutterPodChanged:
false
,
);
);
...
@@ -244,7 +244,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
...
@@ -244,7 +244,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
()
..
createSync
()
..
writeAsString
(
'Existing lock file.'
);
..
writeAsString
(
'Existing lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
false
,
flutterPodChanged:
false
,
);
);
...
@@ -272,7 +272,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
...
@@ -272,7 +272,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Different lock file.'
);
..
writeAsString
(
'Different lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
false
,
flutterPodChanged:
false
,
);
);
...
@@ -300,7 +300,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
...
@@ -300,7 +300,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Existing lock file.'
);
..
writeAsString
(
'Existing lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
true
,
flutterPodChanged:
true
,
);
);
...
@@ -328,7 +328,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
...
@@ -328,7 +328,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Existing lock file.'
);
..
writeAsString
(
'Existing lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
false
,
flutterPodChanged:
false
,
);
);
...
@@ -341,6 +341,41 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
...
@@ -341,6 +341,41 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
FileSystem:
()
=>
fs
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
mockProcessManager
,
ProcessManager:
()
=>
mockProcessManager
,
});
});
testUsingContext
(
'a failed pod install deletes Pods/Manifest.lock'
,
()
async
{
projectUnderTest
.
childFile
(
'Podfile'
)
..
createSync
()
..
writeAsString
(
'Existing Podfile'
);
projectUnderTest
.
childFile
(
'Podfile.lock'
)
..
createSync
()
..
writeAsString
(
'Existing lock file.'
);
projectUnderTest
.
childFile
(
'Pods/Manifest.lock'
)
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Existing lock file.'
);
when
(
mockProcessManager
.
run
(
<
String
>[
'pod'
,
'install'
,
'--verbose'
],
workingDirectory:
'project/ios'
,
environment:
<
String
,
String
>{
'FLUTTER_FRAMEWORK_DIR'
:
'engine/path'
,
'COCOAPODS_DISABLE_STATS'
:
'true'
,
},
)).
thenReturn
(
new
ProcessResult
(
1
,
1
,
'fails for some reason'
,
''
));
try
{
await
cocoaPodsUnderTest
.
processPods
(
appIosDirectory:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
true
,
);
fail
(
'Tool throw expected when pod install fails'
);
}
on
ToolExit
{
expect
(
projectUnderTest
.
childFile
(
'Pods/Manifest.lock'
).
existsSync
(),
isFalse
);
}
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
mockProcessManager
,
});
});
});
}
}
...
...
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