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
Show 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 {
Future
<
bool
>
get
isCocoaPodsInitialized
=>
fs
.
isDirectory
(
fs
.
path
.
join
(
homeDirPath
,
'.cocoapods'
,
'repos'
,
'master'
));
Future
<
Null
>
processPods
({
@required
Directory
appIosDir
,
@required
Directory
appIosDir
ectory
,
// For backward compatibility with previously created Podfile only.
@required
String
iosEngineDir
,
bool
isSwift:
false
,
bool
flutterPodChanged:
true
,
})
async
{
if
(!(
await
appIosDir
.
childFile
(
'Podfile'
).
exists
()))
{
if
(!(
await
appIosDir
ectory
.
childFile
(
'Podfile'
).
exists
()))
{
throwToolExit
(
'Podfile missing'
);
}
if
(
await
_checkPodCondition
())
{
if
(
_shouldRunPodInstall
(
appIosDir
.
path
,
flutterPodChanged
))
await
_runPodInstall
(
appIosDir
,
iosEngineDir
);
if
(
_shouldRunPodInstall
(
appIosDirectory
,
flutterPodChanged
))
{
await
_runPodInstall
(
appIosDirectory
,
iosEngineDir
);
}
}
}
...
...
@@ -100,18 +101,18 @@ class CocoaPods {
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
/// include pods configuration.
void
setupPodfile
(
String
d
irectory
)
{
void
setupPodfile
(
String
appD
irectory
)
{
if
(!
xcodeProjectInterpreter
.
canInterpretXcodeProjects
)
{
// Don't do anything for iOS when host platform doesn't support it.
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
())
{
final
bool
isSwift
=
xcodeProjectInterpreter
.
getBuildSettings
(
fs
.
path
.
join
(
d
irectory
,
'ios'
,
'Runner.xcodeproj'
),
fs
.
path
.
join
(
appD
irectory
,
'ios'
,
'Runner.xcodeproj'
),
'Runner'
,
).
containsKey
(
'SWIFT_VERSION'
);
final
File
podfileTemplate
=
fs
.
file
(
fs
.
path
.
join
(
...
...
@@ -124,12 +125,12 @@ class CocoaPods {
));
podfileTemplate
.
copySync
(
podfilePath
);
}
_addPodsDependencyToFlutterXcconfig
(
d
irectory
,
'Debug'
);
_addPodsDependencyToFlutterXcconfig
(
d
irectory
,
'Release'
);
_addPodsDependencyToFlutterXcconfig
(
appD
irectory
,
'Debug'
);
_addPodsDependencyToFlutterXcconfig
(
appD
irectory
,
'Release'
);
}
void
_addPodsDependencyToFlutterXcconfig
(
String
d
irectory
,
String
mode
)
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
d
irectory
,
'ios'
,
'Flutter'
,
'
$mode
.xcconfig'
));
void
_addPodsDependencyToFlutterXcconfig
(
String
appD
irectory
,
String
mode
)
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
appD
irectory
,
'ios'
,
'Flutter'
,
'
$mode
.xcconfig'
));
if
(
file
.
existsSync
())
{
final
String
content
=
file
.
readAsStringSync
();
final
String
include
=
'#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.
${mode
...
...
@@ -140,9 +141,9 @@ class CocoaPods {
}
/// 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
(
fs
.
path
.
join
(
d
irectory
,
'ios'
,
'Pods'
,
'Manifest.lock'
),
fs
.
path
.
join
(
appD
irectory
,
'ios'
,
'Pods'
,
'Manifest.lock'
),
);
if
(
manifest
.
existsSync
())
manifest
.
deleteSync
();
...
...
@@ -154,22 +155,23 @@ class CocoaPods {
// 2. The podfile.lock doesn't exist
// 3. The Pods/Manifest.lock doesn't exist (It is deleted when plugins change)
// 4. The podfile.lock doesn't match Pods/Manifest.lock.
bool
_shouldRunPodInstall
(
String
appDir
,
bool
flutterPodChanged
)
{
bool
_shouldRunPodInstall
(
Directory
appIosDirectory
,
bool
flutterPodChanged
)
{
if
(
flutterPodChanged
)
return
true
;
// Check if podfile.lock and Pods/Manifest.lock exist and match.
final
File
podfileLockFile
=
fs
.
file
(
fs
.
path
.
join
(
appDir
,
'Podfile.lock'
));
final
File
manifestLockFile
=
fs
.
file
(
fs
.
path
.
join
(
appDir
,
'Pods'
,
'Manifest.lock'
));
final
File
podfileLockFile
=
appIosDirectory
.
childFile
(
'Podfile.lock'
);
final
File
manifestLockFile
=
appIosDirectory
.
childFile
(
fs
.
path
.
join
(
'Pods'
,
'Manifest.lock'
));
return
!
podfileLockFile
.
existsSync
()
||
!
manifestLockFile
.
existsSync
()
||
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
ProcessResult
result
=
await
processManager
.
run
(
<
String
>[
'pod'
,
'install'
,
'--verbose'
],
workingDirectory:
bundle
.
path
,
workingDirectory:
appIosDirectory
.
path
,
environment:
<
String
,
String
>{
// For backward compatibility with previously created Podfile only.
'FLUTTER_FRAMEWORK_DIR'
:
engineDirectory
,
...
...
@@ -190,6 +192,7 @@ class CocoaPods {
}
}
if
(
result
.
exitCode
!=
0
)
{
invalidatePodInstallOutput
(
appIosDirectory
.
parent
.
path
);
_diagnosePodInstallFailure
(
result
);
throwToolExit
(
'Error running pod install'
);
}
...
...
packages/flutter_tools/lib/src/ios/mac.dart
View file @
f7f1685c
...
...
@@ -268,7 +268,7 @@ Future<XcodeBuildResult> buildXcodeProject({
if
(
hasPlugins
())
{
final
String
currentGeneratedXcconfig
=
readGeneratedXcconfig
(
app
.
appDirectory
);
await
cocoaPods
.
processPods
(
appIosDir:
appDirectory
,
appIosDir
ectory
:
appDirectory
,
iosEngineDir:
flutterFrameworkDir
(
buildInfo
.
mode
),
isSwift:
app
.
isSwift
,
flutterPodChanged:
(
previousGeneratedXcconfig
!=
currentGeneratedXcconfig
),
...
...
packages/flutter_tools/test/ios/cocoapods_test.dart
View file @
f7f1685c
...
...
@@ -129,7 +129,7 @@ void main() {
projectUnderTest
.
childFile
(
'Podfile'
).
createSync
();
cocoaPodsUnderTest
=
const
TestCocoaPods
(
false
);
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
);
verifyNever
(
mockProcessManager
.
run
(
...
...
@@ -148,7 +148,7 @@ void main() {
cocoaPodsUnderTest
=
const
TestCocoaPods
(
true
);
try
{
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
);
fail
(
'ToolExit expected'
);
...
...
@@ -198,7 +198,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
));
try
{
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
);
fail
(
'ToolExit expected'
);
...
...
@@ -222,7 +222,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Existing lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
false
,
);
...
...
@@ -244,7 +244,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
()
..
writeAsString
(
'Existing lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
false
,
);
...
...
@@ -272,7 +272,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Different lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
false
,
);
...
...
@@ -300,7 +300,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Existing lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
true
,
);
...
...
@@ -328,7 +328,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
..
createSync
(
recursive:
true
)
..
writeAsString
(
'Existing lock file.'
);
await
cocoaPodsUnderTest
.
processPods
(
appIosDir:
projectUnderTest
,
appIosDir
ectory
:
projectUnderTest
,
iosEngineDir:
'engine/path'
,
flutterPodChanged:
false
,
);
...
...
@@ -341,6 +341,41 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
FileSystem:
()
=>
fs
,
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