-
Notifications
You must be signed in to change notification settings - Fork 26.7k
/
xcode_thin_binary_build_phase_input_paths_migration.dart
70 lines (60 loc) · 2.31 KB
/
xcode_thin_binary_build_phase_input_paths_migration.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// 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 '../xcode_project.dart';
// Migrate Xcode Thin Binary build phase to depend on Info.plist from build directory
// as an input file to ensure it has been created before inserting the NSBonjourServices key
// to avoid an mDNS error.
class XcodeThinBinaryBuildPhaseInputPathsMigration extends ProjectMigrator {
XcodeThinBinaryBuildPhaseInputPathsMigration(XcodeBasedProject project, super.logger)
: _xcodeProjectInfoFile = project.xcodeProjectInfoFile;
final File _xcodeProjectInfoFile;
@override
void migrate() {
if (!_xcodeProjectInfoFile.existsSync()) {
logger.printTrace('Xcode project not found, skipping script build phase dependency analysis removal.');
return;
}
final String originalProjectContents = _xcodeProjectInfoFile.readAsStringSync();
// Add Info.plist from build directory as an input file to Thin Binary build phase.
// Path for the Info.plist is ${TARGET_BUILD_DIR}/\${INFOPLIST_PATH}
// Example:
// 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
// isa = PBXShellScriptBuildPhase;
// alwaysOutOfDate = 1;
// buildActionMask = 2147483647;
// files = (
// );
// inputPaths = (
// );
String newProjectContents = originalProjectContents;
const String thinBinaryBuildPhaseOriginal = '''
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
''';
const String thinBinaryBuildPhaseReplacement = r'''
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
''';
newProjectContents = newProjectContents.replaceAll(thinBinaryBuildPhaseOriginal, thinBinaryBuildPhaseReplacement);
if (originalProjectContents != newProjectContents) {
logger.printStatus('Adding input path to Thin Binary build phase.');
_xcodeProjectInfoFile.writeAsStringSync(newProjectContents);
}
}
}