-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
183 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,3 +186,7 @@ tmp/ | |
XcodeProj.framework.zip | ||
|
||
!Fixtures/**/xcuserdata/ | ||
|
||
Derived/ | ||
*.xcworkspace/ | ||
*.xcodeproj/ |
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,2 @@ | ||
[tools] | ||
tuist = "4.21.2" |
55 changes: 55 additions & 0 deletions
55
Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet.swift
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,55 @@ | ||
import Foundation | ||
|
||
|
||
/// Class representing an element that may contain other elements. | ||
public class PBXFileSystemSynchronizedBuildFileExceptionSet: PBXObject { | ||
Check warning on line 5 in Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet.swift GitHub Actions / Swiftlint
Check warning on line 5 in Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet.swift GitHub Actions / Swiftlint
|
||
|
||
// MARK: - Attributes | ||
|
||
/// A list of relative paths to children subfolders for which exceptions are applied. | ||
public var membershipExceptions: [String]? | ||
|
||
var targetReference: PBXObjectReference | ||
|
||
public var target: PBXTarget! { | ||
get { | ||
targetReference.getObject() as? PBXTarget | ||
} | ||
set { | ||
targetReference = newValue.reference | ||
} | ||
} | ||
|
||
// MARK: - Init | ||
|
||
public init(target: PBXTarget, membershipExceptions: [String]) { | ||
self.targetReference = target.reference | ||
self.membershipExceptions = membershipExceptions | ||
super.init() | ||
} | ||
|
||
// MARK: - Decodable | ||
|
||
fileprivate enum CodingKeys: String, CodingKey { | ||
case target | ||
case membershipExceptions | ||
} | ||
|
||
public required init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let referenceRepository = decoder.context.objectReferenceRepository | ||
let objects = decoder.context.objects | ||
let targetReference: String = try container.decode(.target) | ||
self.targetReference = referenceRepository.getOrCreate(reference: targetReference, objects: objects) | ||
self.membershipExceptions = try container.decodeIfPresent(.membershipExceptions) | ||
try super.init(from: decoder) | ||
} | ||
|
||
// MARK: - Equatable | ||
|
||
override func isEqual(to object: Any?) -> Bool { | ||
guard let rhs = object as? PBXFrameworksBuildPhase else { return false } | ||
return isEqual(to: rhs) | ||
} | ||
|
||
} |
106 changes: 102 additions & 4 deletions
106
Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedRootGroup.swift
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 |
---|---|---|
@@ -1,8 +1,106 @@ | ||
import Foundation | ||
import PathKit | ||
|
||
public class PBXFileSystemSynchronizedRootGroup: PBXFileElement {} | ||
public class PBXFileSystemSynchronizedRootGroup: PBXFileElement { | ||
|
||
/// It maps relative paths inside the synchronized root group to a particular file type. | ||
/// If a path doesn't have a particular file type specified, Xcode defaults to the default file type | ||
/// based on the extension of the file. | ||
public var explicitFileTypes: [String: String] | ||
|
||
/// Returns the references of the exceptions. | ||
var exceptionsReferences: [PBXObjectReference] | ||
|
||
/** 6CEC6EEA2C4BAE2D005DD0F8 /* Test */ = {isa = | ||
PBXFileSystemSynchronizedRootGroup; | ||
explicitFileTypes = {}; explicitFolders = (); path = Test; sourceTree = "<group>"; }; */ | ||
/// It returns a list of exception objects that override the configuration for some children | ||
/// in the synchronized root group. | ||
public var exceptions: [PBXFileSystemSynchronizedBuildFileExceptionSet] { | ||
set { | ||
exceptionsReferences = newValue.references() | ||
} | ||
get { | ||
exceptionsReferences.objects() | ||
} | ||
} | ||
|
||
/// A list of relative paths to children folder whose configuration is overriden. | ||
public var explicitFolders: [String] | ||
|
||
/// Initializes the file element with its properties. | ||
/// | ||
/// - Parameters: | ||
/// - sourceTree: file source tree. | ||
/// - path: object relative path from `sourceTree`, if different than `name`. | ||
/// - name: object name. | ||
/// - includeInIndex: should the IDE index the object? | ||
/// - usesTabs: object uses tabs. | ||
/// - indentWidth: the number of positions to indent blocks of code | ||
/// - tabWidth: the visual width of tab characters | ||
/// - wrapsLines: should the IDE wrap lines when editing the object? | ||
/// - explicitFileTypes: It maps relative paths inside the synchronized root group to a particular file type. | ||
/// - exceptions: It returns a list of exception objects that override the configuration for some children in the synchronized root group. | ||
/// - explicitFolders: A list of relative paths to children folder whose configuration is overriden. | ||
public init(sourceTree: PBXSourceTree? = nil, | ||
path: String? = nil, | ||
name: String? = nil, | ||
includeInIndex: Bool? = nil, | ||
usesTabs: Bool? = nil, | ||
indentWidth: UInt? = nil, | ||
tabWidth: UInt? = nil, | ||
wrapsLines: Bool? = nil, | ||
explicitFileTypes: [String: String] = [:], | ||
exceptions: [PBXFileSystemSynchronizedBuildFileExceptionSet] = [], | ||
explicitFolders: [String] = []) { | ||
self.explicitFileTypes = explicitFileTypes | ||
self.exceptionsReferences = exceptions.references() | ||
self.explicitFolders = explicitFolders | ||
super.init(sourceTree: sourceTree, | ||
path: path, | ||
name: name, | ||
includeInIndex: includeInIndex, | ||
usesTabs: usesTabs, | ||
indentWidth: indentWidth, | ||
tabWidth: tabWidth, | ||
wrapsLines: wrapsLines) | ||
} | ||
|
||
// MARK: - Decodable | ||
|
||
fileprivate enum CodingKeys: String, CodingKey { | ||
case explicitFileTypes | ||
case exceptions | ||
case explicitFolders | ||
} | ||
|
||
public required init(from decoder: Decoder) throws { | ||
let objects = decoder.context.objects | ||
let objectReferenceRepository = decoder.context.objectReferenceRepository | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
self.explicitFileTypes = (try container.decodeIfPresent(.explicitFileTypes)) ?? [:] | ||
let exceptionsReferences: [String] = (try container.decodeIfPresent(.exceptions)) ?? [] | ||
self.exceptionsReferences = exceptionsReferences.map { objectReferenceRepository.getOrCreate(reference: $0, objects: objects) } | ||
self.explicitFolders = (try container.decodeIfPresent(.explicitFolders)) ?? [] | ||
try super.init(from: decoder) | ||
} | ||
|
||
// MARK: - PlistSerializable | ||
|
||
override func plistKeyAndValue(proj: PBXProj, reference: String) throws -> (key: CommentedString, value: PlistValue) { | ||
var dictionary: [CommentedString: PlistValue] = try super.plistKeyAndValue(proj: proj, reference: reference).value.dictionary ?? [:] | ||
dictionary["isa"] = .string(CommentedString(type(of: self).isa)) | ||
dictionary["exceptions"] = .array(self.exceptionsReferences.map({ exceptionReference in | ||
return .string(CommentedString(exceptionReference.value, comment: "PBXFileSystemSynchronizedBuildFileExceptionSet")) | ||
})) | ||
dictionary["explicitFileTypes"] = .dictionary(Dictionary(uniqueKeysWithValues: self.explicitFileTypes.map({ (relativePath, fileType) in | ||
return (CommentedString(relativePath), .string(CommentedString(fileType))) | ||
}))) | ||
dictionary["explicitFolders"] = .array(explicitFolders.map({ .string(CommentedString($0)) })) | ||
return (key: CommentedString(reference, | ||
comment: name ?? path), | ||
value: .dictionary(dictionary)) | ||
} | ||
|
||
override func isEqual(to object: Any?) -> Bool { | ||
guard let rhs = object as? PBXFrameworksBuildPhase else { return false } | ||
return isEqual(to: rhs) | ||
} | ||
} |
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