forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Xcode 15 build failure due to DT_TOOLCHAIN_DIR (#132803)
Starting in Xcode 15, when building macOS, DT_TOOLCHAIN_DIR cannot be used to evaluate LD_RUNPATH_SEARCH_PATHS or LIBRARY_SEARCH_PATHS. `xcodebuild` error message recommend using TOOLCHAIN_DIR instead. Since Xcode 15 isn't in CI, I tested it in a one-off `led` test: * [Pre-fix failure](https://luci-milo.appspot.com/raw/build/logs.chromium.org/flutter/led/vashworth_google.com/04e485a0b152a0720f5e561266f7a6e4fb64fc76227fcacc95b67486ae2771e7/+/build.proto) * [Post-fix success](https://luci-milo.appspot.com/raw/build/logs.chromium.org/flutter/led/vashworth_google.com/d454a3e181e1a97692bdc1fcc197738fe04e4acf1cb20026fd040fd78513f3b0/+/build.proto) Fixes flutter/flutter#132755.
- Loading branch information
Showing
4 changed files
with
222 additions
and
3 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
62 changes: 62 additions & 0 deletions
62
packages/flutter_tools/lib/src/migrations/cocoapods_toolchain_directory_migration.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,62 @@ | ||
// 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'; | ||
|
||
/// Starting in Xcode 15, when building macOS, DT_TOOLCHAIN_DIR cannot be used | ||
/// to evaluate LD_RUNPATH_SEARCH_PATHS or LIBRARY_SEARCH_PATHS. `xcodebuild` | ||
/// error message recommend using TOOLCHAIN_DIR instead. | ||
/// | ||
/// This has been fixed upstream in CocoaPods, but migrate a copy of their | ||
/// workaround so users don't need to update. | ||
class CocoaPodsToolchainDirectoryMigration extends ProjectMigrator { | ||
CocoaPodsToolchainDirectoryMigration( | ||
XcodeBasedProject project, | ||
XcodeProjectInterpreter xcodeProjectInterpreter, | ||
super.logger, | ||
) : _podRunnerTargetSupportFiles = project.podRunnerTargetSupportFiles, | ||
_xcodeProjectInterpreter = xcodeProjectInterpreter; | ||
|
||
final Directory _podRunnerTargetSupportFiles; | ||
final XcodeProjectInterpreter _xcodeProjectInterpreter; | ||
|
||
@override | ||
void migrate() { | ||
if (!_podRunnerTargetSupportFiles.existsSync()) { | ||
logger.printTrace('CocoaPods Pods-Runner Target Support Files not found, skipping TOOLCHAIN_DIR workaround.'); | ||
return; | ||
} | ||
|
||
final Version? version = _xcodeProjectInterpreter.version; | ||
|
||
// If Xcode not installed or less than 15, skip this migration. | ||
if (version == null || version < Version(15, 0, 0)) { | ||
logger.printTrace('Detected Xcode version is $version, below 15.0, skipping TOOLCHAIN_DIR workaround.'); | ||
return; | ||
} | ||
|
||
final List<FileSystemEntity> files = _podRunnerTargetSupportFiles.listSync(); | ||
for (final FileSystemEntity file in files) { | ||
if (file.basename.endsWith('xcconfig') && file is File) { | ||
processFileLines(file); | ||
} | ||
} | ||
} | ||
|
||
@override | ||
String? migrateLine(String line) { | ||
final String trimmedString = line.trim(); | ||
if (trimmedString.startsWith('LD_RUNPATH_SEARCH_PATHS') || trimmedString.startsWith('LIBRARY_SEARCH_PATHS')) { | ||
const String originalReadLinkLine = r'{DT_TOOLCHAIN_DIR}'; | ||
const String replacementReadLinkLine = r'{TOOLCHAIN_DIR}'; | ||
|
||
return line.replaceAll(originalReadLinkLine, replacementReadLinkLine); | ||
} | ||
return line; | ||
} | ||
} |
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