Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add readlink -f flag to CocoaPods script to workaround Xcode 14.3 iss…
- Loading branch information
Showing
5 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/flutter_tools/lib/src/migrations/cocoapods_script_symlink.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters