Skip to content

Commit bc3ec50

Browse files
michaelversusMichalis Karagiorgos
andauthored
fix: support for shellScript in the Xcode 16 format (#1018)
* fix #921 * fix wrong indentation * improve formatting for Either.swift * remove Either and avoid introducing a breaking change for PBXShellScriptBuildPhase --------- Co-authored-by: Michalis Karagiorgos <[email protected]>
1 parent e45e4d7 commit bc3ec50

File tree

6 files changed

+45
-44
lines changed

6 files changed

+45
-44
lines changed

Fixtures/Xcode16ProjectReferenceOrder/Test.xcodeproj/project.pbxproj

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 56;
6+
objectVersion = 90;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -48,15 +48,13 @@
4848
/* Begin PBXCopyFilesBuildPhase section */
4949
BF31C3A479ECD7CBA0640A2F /* Embed Frameworks */ = {
5050
isa = PBXCopyFilesBuildPhase;
51-
buildActionMask = 2147483647;
5251
dstPath = "";
53-
dstSubfolderSpec = 10;
52+
dstSubfolder = Frameworks;
5453
files = (
5554
C2317A164A6A4F635FE4CCD7 /* Framework1.framework in Embed Frameworks */,
5655
3108C05C7B0C4FD6AC077294 /* Framework2.framework in Embed Frameworks */,
5756
);
5857
name = "Embed Frameworks";
59-
runOnlyForDeploymentPostprocessing = 0;
6058
};
6159
/* End PBXCopyFilesBuildPhase section */
6260

@@ -67,18 +65,15 @@
6765
6D728BF5C49E97251DA378AE /* Framework2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Framework2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6866
87A3E8A0727A99EE88ED4E64 /* Framework1.xcodeproj */ = {isa = PBXFileReference; explicitFileType = "wrapper.pb-project"; includeInIndex = 0; name = Framework1.xcodeproj; path = ../Framework1/Framework1.xcodeproj; sourceTree = SOURCE_ROOT; };
6967
E203E65EDD1A90FCBAA42C9E /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
70-
F09268C492FF78A6C82868C6 /* App-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "App-Info.plist"; sourceTree = "<group>"; };
7168
/* End PBXFileReference section */
7269

7370
/* Begin PBXFrameworksBuildPhase section */
7471
B27C7CF4B617049554976EFD /* Frameworks */ = {
7572
isa = PBXFrameworksBuildPhase;
76-
buildActionMask = 2147483647;
7773
files = (
7874
5D8C48ABB7D5D013DDBD67AA /* Framework1.framework in Frameworks */,
7975
C57CB036110A3D5DCC9E437A /* Framework2.framework in Frameworks */,
8076
);
81-
runOnlyForDeploymentPostprocessing = 0;
8277
};
8378
/* End PBXFrameworksBuildPhase section */
8479

@@ -100,14 +95,6 @@
10095
name = Products;
10196
sourceTree = "<group>";
10297
};
103-
20C83B4860AC239B5E5FDF3C /* InfoPlists */ = {
104-
isa = PBXGroup;
105-
children = (
106-
F09268C492FF78A6C82868C6 /* App-Info.plist */,
107-
);
108-
path = InfoPlists;
109-
sourceTree = "<group>";
110-
};
11198
30CD57449DD0BAD1F51809C3 /* Products */ = {
11299
isa = PBXGroup;
113100
children = (
@@ -160,6 +147,7 @@
160147
F1BC716AD69EACCBD2A2DDBC /* Resources */,
161148
BF31C3A479ECD7CBA0640A2F /* Embed Frameworks */,
162149
B27C7CF4B617049554976EFD /* Frameworks */,
150+
0579081E2ED74460006A6AFB /* custom script */,
163151
);
164152
buildRules = (
165153
);
@@ -168,8 +156,6 @@
168156
CD591349E38A6A3EB5AA81DD /* PBXTargetDependency */,
169157
);
170158
name = App;
171-
packageProductDependencies = (
172-
);
173159
productName = App;
174160
productReference = E203E65EDD1A90FCBAA42C9E /* App.app */;
175161
productType = "com.apple.product-type.application";
@@ -181,16 +167,17 @@
181167
isa = PBXProject;
182168
attributes = {
183169
BuildIndependentTargetsInParallel = YES;
170+
LastUpgradeCheck = 1640;
184171
};
185172
buildConfigurationList = C94346B8B75719D8319921C2 /* Build configuration list for PBXProject "Test" */;
186-
compatibilityVersion = "Xcode 14.0";
187173
developmentRegion = en;
188174
hasScannedForEncodings = 0;
189175
knownRegions = (
190176
Base,
191177
en,
192178
);
193179
mainGroup = 0767F0D2E9F7C0B23673A1B1;
180+
preferredProjectObjectVersion = 90;
194181
productRefGroup = 73B13978C93862E5AD69BCC8 /* Products */;
195182
projectDirPath = "";
196183
projectReferences = (
@@ -230,21 +217,31 @@
230217
/* Begin PBXResourcesBuildPhase section */
231218
F1BC716AD69EACCBD2A2DDBC /* Resources */ = {
232219
isa = PBXResourcesBuildPhase;
233-
buildActionMask = 2147483647;
234220
files = (
235221
);
236-
runOnlyForDeploymentPostprocessing = 0;
237222
};
238223
/* End PBXResourcesBuildPhase section */
239224

225+
/* Begin PBXShellScriptBuildPhase section */
226+
0579081E2ED74460006A6AFB /* custom script */ = {
227+
isa = PBXShellScriptBuildPhase;
228+
name = "custom script";
229+
shellPath = /bin/sh;
230+
shellScript = (
231+
"# comment",
232+
"ls -la",
233+
"ls -la",
234+
"",
235+
);
236+
};
237+
/* End PBXShellScriptBuildPhase section */
238+
240239
/* Begin PBXSourcesBuildPhase section */
241240
2053EE4C6238D6C3AEB2ADB3 /* Sources */ = {
242241
isa = PBXSourcesBuildPhase;
243-
buildActionMask = 2147483647;
244242
files = (
245243
D2AE54DED6608D5B956A5E45 /* AppDelegate.swift in Sources */,
246244
);
247-
runOnlyForDeploymentPostprocessing = 0;
248245
};
249246
/* End PBXSourcesBuildPhase section */
250247

@@ -262,7 +259,7 @@
262259
/* End PBXTargetDependency section */
263260

264261
/* Begin XCBuildConfiguration section */
265-
0B98A64D6F621FDCEEA0CE44 /* Debug */ = {
262+
0B98A64D6F621FDCEEA0CE44 /* Debug configuration for PBXNativeTarget "App" */ = {
266263
isa = XCBuildConfiguration;
267264
buildSettings = {
268265
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
@@ -287,7 +284,7 @@
287284
};
288285
name = Debug;
289286
};
290-
58BAFCCFAE3AD62113BBEDEF /* Debug */ = {
287+
58BAFCCFAE3AD62113BBEDEF /* Debug configuration for PBXProject "Test" */ = {
291288
isa = XCBuildConfiguration;
292289
buildSettings = {
293290
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -326,6 +323,7 @@
326323
DEBUG_INFORMATION_FORMAT = dwarf;
327324
ENABLE_STRICT_OBJC_MSGSEND = YES;
328325
ENABLE_TESTABILITY = YES;
326+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
329327
GCC_C_LANGUAGE_STANDARD = gnu11;
330328
GCC_DYNAMIC_NO_PIC = NO;
331329
GCC_NO_COMMON_BLOCKS = YES;
@@ -346,7 +344,7 @@
346344
};
347345
name = Debug;
348346
};
349-
5904C1CCA86A83838723C772 /* Release */ = {
347+
5904C1CCA86A83838723C772 /* Release configuration for PBXProject "Test" */ = {
350348
isa = XCBuildConfiguration;
351349
buildSettings = {
352350
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -385,6 +383,7 @@
385383
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
386384
ENABLE_NS_ASSERTIONS = NO;
387385
ENABLE_STRICT_OBJC_MSGSEND = YES;
386+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
388387
GCC_C_LANGUAGE_STANDARD = gnu11;
389388
GCC_NO_COMMON_BLOCKS = YES;
390389
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -399,7 +398,7 @@
399398
};
400399
name = Release;
401400
};
402-
5E15950A8DD3B82ED1ED7849 /* Release */ = {
401+
5E15950A8DD3B82ED1ED7849 /* Release configuration for PBXNativeTarget "App" */ = {
403402
isa = XCBuildConfiguration;
404403
buildSettings = {
405404
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
@@ -429,19 +428,17 @@
429428
BAA38452720711B406475F28 /* Build configuration list for PBXNativeTarget "App" */ = {
430429
isa = XCConfigurationList;
431430
buildConfigurations = (
432-
0B98A64D6F621FDCEEA0CE44 /* Debug */,
433-
5E15950A8DD3B82ED1ED7849 /* Release */,
431+
0B98A64D6F621FDCEEA0CE44 /* Debug configuration for PBXNativeTarget "App" */,
432+
5E15950A8DD3B82ED1ED7849 /* Release configuration for PBXNativeTarget "App" */,
434433
);
435-
defaultConfigurationIsVisible = 0;
436434
defaultConfigurationName = Release;
437435
};
438436
C94346B8B75719D8319921C2 /* Build configuration list for PBXProject "Test" */ = {
439437
isa = XCConfigurationList;
440438
buildConfigurations = (
441-
58BAFCCFAE3AD62113BBEDEF /* Debug */,
442-
5904C1CCA86A83838723C772 /* Release */,
439+
58BAFCCFAE3AD62113BBEDEF /* Debug configuration for PBXProject "Test" */,
440+
5904C1CCA86A83838723C772 /* Release configuration for PBXProject "Test" */,
443441
);
444-
defaultConfigurationIsVisible = 0;
445442
defaultConfigurationName = Release;
446443
};
447444
/* End XCConfigurationList section */

Fixtures/Xcode16ProjectReferenceOrder/Test.xcodeproj/xcshareddata/xcschemes/App.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1010"
3+
LastUpgradeVersion = "1640"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Sources/XcodeProj/Objects/BuildPhase/PBXShellScriptBuildPhase.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ public final class PBXShellScriptBuildPhase: PBXBuildPhase {
9494
inputPaths = try (container.decodeIfPresent(.inputPaths)) ?? []
9595
outputPaths = try (container.decodeIfPresent(.outputPaths)) ?? []
9696
shellPath = try container.decodeIfPresent(.shellPath)
97-
shellScript = try container.decodeIfPresent(.shellScript)
97+
// Xcode 16.0 introduced a new format for shellScript, so we need to handle both cases.
98+
if let scriptArray = try? container.decodeIfPresent([String].self, forKey: .shellScript) {
99+
shellScript = scriptArray.joined(separator: "\n")
100+
} else {
101+
shellScript = try container.decodeIfPresent(.shellScript)
102+
}
98103
showEnvVarsInLog = try container.decodeIntBoolIfPresent(.showEnvVarsInLog) ?? true
99104
alwaysOutOfDate = try container.decodeIntBoolIfPresent(.alwaysOutOfDate) ?? false
100105
dependencyFile = try container.decodeIfPresent(.dependencyFile)

Tests/XcodeProjTests/Objects/BuildPhase/PBXShellScriptBuildPhaseTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,4 @@ final class PBXShellScriptBuildPhaseTests: XCTestCase {
7373

7474
XCTAssertNotEqual(noDiscovery, discovery)
7575
}
76-
77-
private func testDictionary() -> [String: Any] {
78-
[
79-
"files": ["files"],
80-
"inputPaths": ["input"],
81-
"outputPaths": ["output"],
82-
"shellPath": "shellPath",
83-
"shellScript": "shellScript",
84-
]
85-
}
8676
}

Tests/XcodeProjTests/Objects/Project/PBXProjEncoderTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@
554554
private func loadProjectWithWrongProjectReferencesOrder() throws {
555555
proj = try PBXProj(data: projectWithWrongProjectReferencesOrder())
556556
}
557+
558+
private func loadProjectWithShellScriptBuildPhase() throws {
559+
proj = try PBXProj(data: projectWithCustomShellScript())
560+
}
557561
}
558562

559563
// MARK: - Line validations

Tests/XcodeProjTests/Tests/Fixtures.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ func projectWithWrongProjectReferencesOrder() throws -> Data {
5050
let iosProjectWithProjectReferences = fixturesPath() + "Xcode16ProjectReferenceOrder/Wrong.xcodeproj/project.pbxproj"
5151
return try Data(contentsOf: iosProjectWithProjectReferences.url)
5252
}
53+
54+
func projectWithCustomShellScript() throws -> Data {
55+
let iosProjectWithShellScript = fixturesPath() + "Xcode16ProjectReferenceOrder/Test.xcodeproj/project.pbxproj"
56+
return try Data(contentsOf: iosProjectWithShellScript.url)
57+
}

0 commit comments

Comments
 (0)