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
d4934fb6
Unverified
Commit
d4934fb6
authored
Apr 03, 2023
by
Jenn Magder
Committed by
GitHub
Apr 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add readlink -f flag to CocoaPods script to workaround Xcode 14.3 issue (#124062)
parent
d32dc712
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
223 additions
and
0 deletions
+223
-0
cocoapods.dart
packages/flutter_tools/lib/src/macos/cocoapods.dart
+9
-0
cocoapods_script_symlink.dart
...er_tools/lib/src/migrations/cocoapods_script_symlink.dart
+52
-0
xcode_project.dart
packages/flutter_tools/lib/src/xcode_project.dart
+7
-0
ios_project_migration_test.dart
...ls/test/general.shard/ios/ios_project_migration_test.dart
+105
-0
cocoapods_test.dart
...lutter_tools/test/general.shard/macos/cocoapods_test.dart
+50
-0
No files found.
packages/flutter_tools/lib/src/macos/cocoapods.dart
View file @
d4934fb6
...
...
@@ -13,10 +13,12 @@ import '../base/logger.dart';
import
'../base/os.dart'
;
import
'../base/platform.dart'
;
import
'../base/process.dart'
;
import
'../base/project_migrator.dart'
;
import
'../base/version.dart'
;
import
'../build_info.dart'
;
import
'../cache.dart'
;
import
'../ios/xcodeproj.dart'
;
import
'../migrations/cocoapods_script_symlink.dart'
;
import
'../reporting/reporting.dart'
;
import
'../xcode_project.dart'
;
...
...
@@ -166,6 +168,13 @@ class CocoaPods {
throwToolExit
(
'CocoaPods not installed or not in valid state.'
);
}
await
_runPodInstall
(
xcodeProject
,
buildMode
);
// This migrator works around a CocoaPods bug, and should be run after `pod install` is run.
final
ProjectMigration
postPodMigration
=
ProjectMigration
(<
ProjectMigrator
>[
CocoaPodsScriptReadlink
(
xcodeProject
,
_xcodeProjectInterpreter
,
_logger
),
]);
postPodMigration
.
run
();
podsProcessed
=
true
;
}
return
podsProcessed
;
...
...
packages/flutter_tools/lib/src/migrations/cocoapods_script_symlink.dart
0 → 100644
View file @
d4934fb6
// 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.
import
'../base/file_system.dart'
;
import
'../base/project_migrator.dart'
;
import
'../base/version.dart'
;
import
'../ios/xcodeproj.dart'
;
import
'../xcode_project.dart'
;
// Xcode 14.3 changed the readlink symlink behavior to be relative from the script working directory, instead of the
// relative path of the symlink. The -f flag returns the original "--canonicalize" behavior the CocoaPods script relies on.
// This has been fixed upstream in CocoaPods, but migrate a copy of their workaround so users don't need to update.
//
// See https://github.com/flutter/flutter/issues/123890#issuecomment-1494825976.
class
CocoaPodsScriptReadlink
extends
ProjectMigrator
{
CocoaPodsScriptReadlink
(
XcodeBasedProject
project
,
XcodeProjectInterpreter
xcodeProjectInterpreter
,
super
.
logger
,
)
:
_podRunnerFrameworksScript
=
project
.
podRunnerFrameworksScript
,
_xcodeProjectInterpreter
=
xcodeProjectInterpreter
;
final
File
_podRunnerFrameworksScript
;
final
XcodeProjectInterpreter
_xcodeProjectInterpreter
;
@override
void
migrate
()
{
if
(!
_podRunnerFrameworksScript
.
existsSync
())
{
logger
.
printTrace
(
'CocoaPods Pods-Runner-frameworks.sh script not found, skipping "readlink -f" workaround.'
);
return
;
}
final
Version
?
version
=
_xcodeProjectInterpreter
.
version
;
// If Xcode not installed or less than 14.3 with readlink behavior change, skip this migration.
if
(
version
==
null
||
version
<
Version
(
14
,
3
,
0
))
{
logger
.
printTrace
(
'Detected Xcode version is
$version
, below 14.3, skipping "readlink -f" workaround.'
);
return
;
}
processFileLines
(
_podRunnerFrameworksScript
);
}
@override
String
?
migrateLine
(
String
line
)
{
const
String
originalReadLinkLine
=
r'source="$(readlink "${source}")"'
;
const
String
replacementReadLinkLine
=
r'source="$(readlink -f "${source}")"'
;
return
line
.
replaceAll
(
originalReadLinkLine
,
replacementReadLinkLine
);
}
}
packages/flutter_tools/lib/src/xcode_project.dart
View file @
d4934fb6
...
...
@@ -89,6 +89,13 @@ abstract class XcodeBasedProject extends FlutterProjectPlatform {
/// The CocoaPods 'Manifest.lock'.
File
get
podManifestLock
=>
hostAppRoot
.
childDirectory
(
'Pods'
).
childFile
(
'Manifest.lock'
);
/// The CocoaPods generated 'Pods-Runner-frameworks.sh'.
File
get
podRunnerFrameworksScript
=>
hostAppRoot
.
childDirectory
(
'Pods'
)
.
childDirectory
(
'Target Support Files'
)
.
childDirectory
(
'Pods-Runner'
)
.
childFile
(
'Pods-Runner-frameworks.sh'
);
}
/// Represents the iOS sub-project of a Flutter project.
...
...
packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart
View file @
d4934fb6
...
...
@@ -6,6 +6,7 @@ import 'package:file/file.dart';
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/project_migrator.dart'
;
import
'package:flutter_tools/src/base/version.dart'
;
import
'package:flutter_tools/src/ios/migrations/host_app_info_plist_migration.dart'
;
import
'package:flutter_tools/src/ios/migrations/ios_deployment_target_migration.dart'
;
import
'package:flutter_tools/src/ios/migrations/project_base_configuration_migration.dart'
;
...
...
@@ -13,6 +14,8 @@ import 'package:flutter_tools/src/ios/migrations/project_build_location_migratio
import
'package:flutter_tools/src/ios/migrations/remove_bitcode_migration.dart'
;
import
'package:flutter_tools/src/ios/migrations/remove_framework_link_and_embedding_migration.dart'
;
import
'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.dart'
;
import
'package:flutter_tools/src/ios/xcodeproj.dart'
;
import
'package:flutter_tools/src/migrations/cocoapods_script_symlink.dart'
;
import
'package:flutter_tools/src/migrations/xcode_project_object_version_migration.dart'
;
import
'package:flutter_tools/src/migrations/xcode_script_build_phase_migration.dart'
;
import
'package:flutter_tools/src/migrations/xcode_thin_binary_build_phase_input_paths_migration.dart'
;
...
...
@@ -21,6 +24,7 @@ import 'package:flutter_tools/src/xcode_project.dart';
import
'package:test/fake.dart'
;
import
'../../src/common.dart'
;
import
'../../src/fake_process_manager.dart'
;
void
main
(
)
{
group
(
'iOS migration'
,
()
{
...
...
@@ -901,6 +905,104 @@ platform :ios, '11.0'
expect
(
'Disabling deprecated bitcode Xcode build setting'
.
allMatches
(
testLogger
.
warningText
).
length
,
1
);
});
});
group
(
'CocoaPods script readlink'
,
()
{
late
MemoryFileSystem
memoryFileSystem
;
late
BufferLogger
testLogger
;
late
FakeIosProject
project
;
late
File
podRunnerFrameworksScript
;
late
ProcessManager
processManager
;
late
XcodeProjectInterpreter
xcode143ProjectInterpreter
;
setUp
(()
{
memoryFileSystem
=
MemoryFileSystem
();
podRunnerFrameworksScript
=
memoryFileSystem
.
file
(
'Pods-Runner-frameworks.sh'
);
testLogger
=
BufferLogger
.
test
();
project
=
FakeIosProject
();
processManager
=
FakeProcessManager
.
any
();
xcode143ProjectInterpreter
=
XcodeProjectInterpreter
.
test
(
processManager:
processManager
,
version:
Version
(
14
,
3
,
0
));
project
.
podRunnerFrameworksScript
=
podRunnerFrameworksScript
;
});
testWithoutContext
(
'skipped if files are missing'
,
()
{
final
CocoaPodsScriptReadlink
iosProjectMigration
=
CocoaPodsScriptReadlink
(
project
,
xcode143ProjectInterpreter
,
testLogger
,
);
iosProjectMigration
.
migrate
();
expect
(
podRunnerFrameworksScript
.
existsSync
(),
isFalse
);
expect
(
testLogger
.
traceText
,
contains
(
'CocoaPods Pods-Runner-frameworks.sh script not found'
));
expect
(
testLogger
.
statusText
,
isEmpty
);
});
testWithoutContext
(
'skipped if nothing to upgrade'
,
()
{
const
String
contents
=
r''
'
if [ -L "
${source}
" ]; then
echo "Symlinked..."
source="
$
(readlink -f "
${source}
")"
fi'''
;
podRunnerFrameworksScript
.
writeAsStringSync
(
contents
);
final
CocoaPodsScriptReadlink
iosProjectMigration
=
CocoaPodsScriptReadlink
(
project
,
xcode143ProjectInterpreter
,
testLogger
,
);
iosProjectMigration
.
migrate
();
expect
(
podRunnerFrameworksScript
.
existsSync
(),
isTrue
);
expect
(
testLogger
.
traceText
,
isEmpty
);
expect
(
testLogger
.
statusText
,
isEmpty
);
});
testWithoutContext
(
'skipped if Xcode version below 14.3'
,
()
{
const
String
contents
=
r''
'
if [ -L "
${source}
" ]; then
echo "Symlinked..."
source="
$
(readlink "
${source}
")"
fi'''
;
podRunnerFrameworksScript
.
writeAsStringSync
(
contents
);
final
XcodeProjectInterpreter
xcode142ProjectInterpreter
=
XcodeProjectInterpreter
.
test
(
processManager:
processManager
,
version:
Version
(
14
,
2
,
0
),
);
final
CocoaPodsScriptReadlink
iosProjectMigration
=
CocoaPodsScriptReadlink
(
project
,
xcode142ProjectInterpreter
,
testLogger
,
);
iosProjectMigration
.
migrate
();
expect
(
podRunnerFrameworksScript
.
existsSync
(),
isTrue
);
expect
(
testLogger
.
traceText
,
contains
(
'Detected Xcode version is 14.2.0, below 14.3, skipping "readlink -f" workaround'
));
expect
(
testLogger
.
statusText
,
isEmpty
);
});
testWithoutContext
(
'Xcode project is migrated'
,
()
{
const
String
contents
=
r''
'
if [ -L "
${source}
" ]; then
echo "Symlinked..."
source="
$
(readlink "
${source}
")"
fi'''
;
podRunnerFrameworksScript
.
writeAsStringSync
(
contents
);
final
CocoaPodsScriptReadlink
iosProjectMigration
=
CocoaPodsScriptReadlink
(
project
,
xcode143ProjectInterpreter
,
testLogger
,
);
iosProjectMigration
.
migrate
();
expect
(
podRunnerFrameworksScript
.
readAsStringSync
(),
r''
'
if [ -L "
${source}
" ]; then
echo "Symlinked..."
source="
$
(readlink -f "
${source}
")"
fi
'''
);
expect
(
testLogger
.
statusText
,
contains
(
'Upgrading Pods-Runner-frameworks.sh'
));
});
});
});
group
(
'update Xcode script build phase'
,
()
{
...
...
@@ -1134,6 +1236,9 @@ class FakeIosProject extends Fake implements IosProject {
@override
File
podfile
=
MemoryFileSystem
.
test
().
file
(
'Podfile'
);
@override
File
podRunnerFrameworksScript
=
MemoryFileSystem
.
test
().
file
(
'podRunnerFrameworksScript'
);
}
class
FakeIOSMigrator
extends
ProjectMigrator
{
...
...
packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
View file @
d4934fb6
...
...
@@ -6,6 +6,7 @@ import 'package:file/file.dart';
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/version.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/flutter_plugins.dart'
;
...
...
@@ -740,6 +741,55 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
);
expect
(
didInstall
,
isTrue
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
expect
(
logger
.
traceText
,
contains
(
'CocoaPods Pods-Runner-frameworks.sh script not found'
));
});
testUsingContext
(
'runs CocoaPods Pod runner script migrator'
,
()
async
{
final
FlutterProject
projectUnderTest
=
setupProjectUnderTest
();
pretendPodIsInstalled
();
pretendPodVersionIs
(
'100.0.0'
);
projectUnderTest
.
ios
.
podfile
..
createSync
()
..
writeAsStringSync
(
'Existing Podfile'
);
projectUnderTest
.
ios
.
podfileLock
..
createSync
()
..
writeAsStringSync
(
'Existing lock file.'
);
projectUnderTest
.
ios
.
podManifestLock
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'Existing lock file.'
);
projectUnderTest
.
ios
.
podRunnerFrameworksScript
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
r'source="$(readlink "${source}")"'
);
fakeProcessManager
.
addCommands
(
const
<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
'pod'
,
'install'
,
'--verbose'
],
workingDirectory:
'project/ios'
,
environment:
<
String
,
String
>{
'COCOAPODS_DISABLE_STATS'
:
'true'
,
'LANG'
:
'en_US.UTF-8'
},
),
FakeCommand
(
command:
<
String
>[
'touch'
,
'project/ios/Podfile.lock'
],
),
]);
final
CocoaPods
cocoaPodsUnderTestXcode143
=
CocoaPods
(
fileSystem:
fileSystem
,
processManager:
fakeProcessManager
,
logger:
logger
,
platform:
FakePlatform
(
operatingSystem:
'macos'
),
xcodeProjectInterpreter:
XcodeProjectInterpreter
.
test
(
processManager:
fakeProcessManager
,
version:
Version
(
14
,
3
,
0
)),
usage:
usage
,
);
final
bool
didInstall
=
await
cocoaPodsUnderTestXcode143
.
processPods
(
xcodeProject:
projectUnderTest
.
ios
,
buildMode:
BuildMode
.
debug
,
);
expect
(
didInstall
,
isTrue
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
// Now has readlink -f flag.
expect
(
projectUnderTest
.
ios
.
podRunnerFrameworksScript
.
readAsStringSync
(),
contains
(
r'source="$(readlink -f "${source}")"'
));
expect
(
logger
.
statusText
,
contains
(
'Upgrading Pods-Runner-frameworks.sh'
));
});
testUsingContext
(
'runs pod install, if Podfile.lock is older than Podfile'
,
()
async
{
...
...
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