Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 90;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -48,15 +48,13 @@
/* Begin PBXCopyFilesBuildPhase section */
BF31C3A479ECD7CBA0640A2F /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
dstSubfolder = Frameworks;
files = (
C2317A164A6A4F635FE4CCD7 /* Framework1.framework in Embed Frameworks */,
3108C05C7B0C4FD6AC077294 /* Framework2.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

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

/* Begin PBXFrameworksBuildPhase section */
B27C7CF4B617049554976EFD /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5D8C48ABB7D5D013DDBD67AA /* Framework1.framework in Frameworks */,
C57CB036110A3D5DCC9E437A /* Framework2.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

Expand All @@ -100,14 +95,6 @@
name = Products;
sourceTree = "<group>";
};
20C83B4860AC239B5E5FDF3C /* InfoPlists */ = {
isa = PBXGroup;
children = (
F09268C492FF78A6C82868C6 /* App-Info.plist */,
);
path = InfoPlists;
sourceTree = "<group>";
};
30CD57449DD0BAD1F51809C3 /* Products */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -160,6 +147,7 @@
F1BC716AD69EACCBD2A2DDBC /* Resources */,
BF31C3A479ECD7CBA0640A2F /* Embed Frameworks */,
B27C7CF4B617049554976EFD /* Frameworks */,
0579081E2ED74460006A6AFB /* custom script */,
);
buildRules = (
);
Expand All @@ -168,8 +156,6 @@
CD591349E38A6A3EB5AA81DD /* PBXTargetDependency */,
);
name = App;
packageProductDependencies = (
);
productName = App;
productReference = E203E65EDD1A90FCBAA42C9E /* App.app */;
productType = "com.apple.product-type.application";
Expand All @@ -181,16 +167,17 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1640;
};
buildConfigurationList = C94346B8B75719D8319921C2 /* Build configuration list for PBXProject "Test" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Base,
en,
);
mainGroup = 0767F0D2E9F7C0B23673A1B1;
preferredProjectObjectVersion = 90;
productRefGroup = 73B13978C93862E5AD69BCC8 /* Products */;
projectDirPath = "";
projectReferences = (
Expand Down Expand Up @@ -230,21 +217,31 @@
/* Begin PBXResourcesBuildPhase section */
F1BC716AD69EACCBD2A2DDBC /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
0579081E2ED74460006A6AFB /* custom script */ = {
isa = PBXShellScriptBuildPhase;
name = "custom script";
shellPath = /bin/sh;
shellScript = (
"# comment",
"ls -la",
"ls -la",
"",
);
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
2053EE4C6238D6C3AEB2ADB3 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D2AE54DED6608D5B956A5E45 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

Expand All @@ -262,7 +259,7 @@
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
0B98A64D6F621FDCEEA0CE44 /* Debug */ = {
0B98A64D6F621FDCEEA0CE44 /* Debug configuration for PBXNativeTarget "App" */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
Expand All @@ -287,7 +284,7 @@
};
name = Debug;
};
58BAFCCFAE3AD62113BBEDEF /* Debug */ = {
58BAFCCFAE3AD62113BBEDEF /* Debug configuration for PBXProject "Test" */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
Expand Down Expand Up @@ -326,6 +323,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -346,7 +344,7 @@
};
name = Debug;
};
5904C1CCA86A83838723C772 /* Release */ = {
5904C1CCA86A83838723C772 /* Release configuration for PBXProject "Test" */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
Expand Down Expand Up @@ -385,6 +383,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -399,7 +398,7 @@
};
name = Release;
};
5E15950A8DD3B82ED1ED7849 /* Release */ = {
5E15950A8DD3B82ED1ED7849 /* Release configuration for PBXNativeTarget "App" */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
Expand Down Expand Up @@ -429,19 +428,17 @@
BAA38452720711B406475F28 /* Build configuration list for PBXNativeTarget "App" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0B98A64D6F621FDCEEA0CE44 /* Debug */,
5E15950A8DD3B82ED1ED7849 /* Release */,
0B98A64D6F621FDCEEA0CE44 /* Debug configuration for PBXNativeTarget "App" */,
5E15950A8DD3B82ED1ED7849 /* Release configuration for PBXNativeTarget "App" */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C94346B8B75719D8319921C2 /* Build configuration list for PBXProject "Test" */ = {
isa = XCConfigurationList;
buildConfigurations = (
58BAFCCFAE3AD62113BBEDEF /* Debug */,
5904C1CCA86A83838723C772 /* Release */,
58BAFCCFAE3AD62113BBEDEF /* Debug configuration for PBXProject "Test" */,
5904C1CCA86A83838723C772 /* Release configuration for PBXProject "Test" */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public final class PBXShellScriptBuildPhase: PBXBuildPhase {
public var shellPath: String?

/// Shell script.
public var shellScript: String?
public var shellScript: Either<String, [String]>?

/// Show environment variables in the logs.
public var showEnvVarsInLog: Bool
Expand Down Expand Up @@ -54,7 +54,7 @@ public final class PBXShellScriptBuildPhase: PBXBuildPhase {
inputFileListPaths: [String]? = nil,
outputFileListPaths: [String]? = nil,
shellPath: String = "/bin/sh",
shellScript: String? = nil,
shellScript: Either<String, [String]>? = nil,
buildActionMask: UInt = defaultBuildActionMask,
runOnlyForDeploymentPostprocessing: Bool = false,
showEnvVarsInLog: Bool = true,
Expand Down Expand Up @@ -122,7 +122,7 @@ extension PBXShellScriptBuildPhase: PlistSerializable {
}
dictionary["outputPaths"] = .array(outputPaths.map { .string(CommentedString($0)) })
if let shellScript {
dictionary["shellScript"] = .string(CommentedString(shellScript))
dictionary["shellScript"] = .string(CommentedString(shellScript.toString()))
}
if let dependencyFile {
dictionary["dependencyFile"] = .string(CommentedString(dependencyFile))
Expand Down
31 changes: 31 additions & 0 deletions Sources/XcodeProj/Utils/Either.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Foundation

public enum Either<L, R> {
case left(L)
case right(R)
}

extension Either: Decodable where L: Decodable, R: Decodable {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let leftValue = try? container.decode(L.self) {
self = .left(leftValue)
} else {
let rightValue = try container.decode(R.self)
self = .right(rightValue)
}
}
}

extension Either where L == String, R == [String] {
public func toString() -> String {
switch self {
case .left(let string):
string
case .right(let stringArray):
stringArray.joined(separator: "\n")
}
}
}

extension Either: Equatable where L: Equatable, R: Equatable {}
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,4 @@ final class PBXShellScriptBuildPhaseTests: XCTestCase {

XCTAssertNotEqual(noDiscovery, discovery)
}

private func testDictionary() -> [String: Any] {
[
"files": ["files"],
"inputPaths": ["input"],
"outputPaths": ["output"],
"shellPath": "shellPath",
"shellScript": "shellScript",
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@
private func loadProjectWithWrongProjectReferencesOrder() throws {
proj = try PBXProj(data: projectWithWrongProjectReferencesOrder())
}

private func loadProjectWithShellScriptBuildPhase() throws {
proj = try PBXProj(data: projectWithCustomShellScript())
}
}

// MARK: - Line validations
Expand Down
5 changes: 5 additions & 0 deletions Tests/XcodeProjTests/Tests/Fixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ func projectWithWrongProjectReferencesOrder() throws -> Data {
let iosProjectWithProjectReferences = fixturesPath() + "Xcode16ProjectReferenceOrder/Wrong.xcodeproj/project.pbxproj"
return try Data(contentsOf: iosProjectWithProjectReferences.url)
}

func projectWithCustomShellScript() throws -> Data {
let iosProjectWithShellScript = fixturesPath() + "Xcode16ProjectReferenceOrder/Test.xcodeproj/project.pbxproj"
return try Data(contentsOf: iosProjectWithShellScript.url)
}