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
9 changes: 8 additions & 1 deletion Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ Note that target names can also be changed by adding a `name` property to a targ
- [ ] **indentWidth**: **Int** - If this is specified, the Xcode project will override the user's setting for indent width in number of spaces.
- [ ] **tabWidth**: **Int** - If this is specified, the Xcode project will override the user's setting for indent width in number of spaces.
- [ ] **xcodeVersion**: **String** - The version of Xcode. This defaults to the latest version periodically. You can specify it in the format `0910` or `9.1`
- [ ] **projectFormat**: **String** - The version of Xcode project. By default this is set to `xcode16_0`
- `xcode16_3`: Xcode 16.3
- `xcode16_0`: Xcode 16.0
- `xcode15_3`: Xcode 15.3
- `xcode15_0`: Xcode 15.0
- `xcode14_0`: Xcode 14.0

- [ ] **deploymentTarget**: **[[Platform](#platform): String]** - A project wide deployment target can be specified for each platform otherwise the default SDK version in Xcode will be used. This will be overridden by any custom build settings that set the deployment target eg `IPHONEOS_DEPLOYMENT_TARGET`. Target specific deployment targets can also be set with [Target](#target).deploymentTarget.
- [ ] **disabledValidations**: **[String]** - A list of validations that can be disabled if they're too strict for your use case. By default this is set to an empty array. Currently these are the available options:
- `missingConfigs`: Disable errors for configurations in yaml files that don't exist in the project itself. This can be useful if you include the same yaml file in different projects
Expand All @@ -156,7 +163,7 @@ Note that target names can also be changed by adding a `name` property to a targ
- [ ] **defaultSourceDirectoryType**: **String** - When a [Target source](#target-source) doesn't specify a type and is a directory, this is the type that will be used. If nothing is specified for either then `group` will be used.
- `group` (default)
- `folder`
- `syncedFolder`
- `syncedFolder`: Can be used starting from **projectFormat** `xcode16_0`

```yaml
options:
Expand Down
5 changes: 5 additions & 0 deletions Sources/ProjectSpec/SpecOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public struct SpecOptions: Equatable {
public var tabWidth: UInt?
public var indentWidth: UInt?
public var xcodeVersion: String?
public var projectFormat: String?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yonaskolb I'm not sure about type
Maybe is better to move ProjectFormat to ProjectSpec and parse it here?

public var deploymentTarget: DeploymentTarget
public var defaultConfig: String?
public var transitivelyLinkDependencies: Bool
Expand Down Expand Up @@ -88,6 +89,7 @@ public struct SpecOptions: Equatable {
tabWidth: UInt? = nil,
usesTabs: Bool? = nil,
xcodeVersion: String? = nil,
projectFormat: String? = nil,
deploymentTarget: DeploymentTarget = .init(),
disabledValidations: [ValidationType] = [],
defaultConfig: String? = nil,
Expand Down Expand Up @@ -115,6 +117,7 @@ public struct SpecOptions: Equatable {
self.indentWidth = indentWidth
self.usesTabs = usesTabs
self.xcodeVersion = xcodeVersion
self.projectFormat = projectFormat
self.deploymentTarget = deploymentTarget
self.disabledValidations = disabledValidations
self.defaultConfig = defaultConfig
Expand Down Expand Up @@ -148,6 +151,7 @@ extension SpecOptions: JSONObjectConvertible {
developmentLanguage = jsonDictionary.json(atKeyPath: "developmentLanguage")
usesTabs = jsonDictionary.json(atKeyPath: "usesTabs")
xcodeVersion = jsonDictionary.json(atKeyPath: "xcodeVersion")
projectFormat = jsonDictionary.json(atKeyPath: "projectFormat")
indentWidth = (jsonDictionary.json(atKeyPath: "indentWidth") as Int?).flatMap(UInt.init)
tabWidth = (jsonDictionary.json(atKeyPath: "tabWidth") as Int?).flatMap(UInt.init)
deploymentTarget = jsonDictionary.json(atKeyPath: "deploymentTarget") ?? DeploymentTarget()
Expand Down Expand Up @@ -186,6 +190,7 @@ extension SpecOptions: JSONEncodable {
"developmentLanguage": developmentLanguage,
"usesTabs": usesTabs,
"xcodeVersion": xcodeVersion,
"projectFormat": projectFormat,
"indentWidth": indentWidth.flatMap { Int($0) },
"tabWidth": tabWidth.flatMap { Int($0) },
"defaultConfig": defaultConfig,
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class PBXProjGenerator {
name: project.name,
buildConfigurationList: buildConfigList,
compatibilityVersion: project.compatibilityVersion,
preferredProjectObjectVersion: Int(project.objectVersion),
preferredProjectObjectVersion: project.preferredProjectObjectVersion.map { Int($0) },
minimizedProjectReferenceProxies: project.minimizedProjectReferenceProxies,
mainGroup: mainGroup,
developmentRegion: developmentRegion
Expand Down
37 changes: 37 additions & 0 deletions Sources/XcodeGenKit/ProjectFormat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public extension ProjectFormat {
static let `default`: ProjectFormat = .xcode16_0
}

public enum ProjectFormat: String {
case xcode16_3
case xcode16_0
case xcode15_3
case xcode15_0
case xcode14_0

public var objectVersion: UInt {
switch self {
case .xcode16_3: 90
case .xcode16_0: 77
case .xcode15_3: 63
case .xcode15_0: 60
case .xcode14_0: 56
}
}

public var preferredProjectObjectVersion: UInt? {
switch self {
case .xcode16_3, .xcode16_0: objectVersion
case .xcode15_3, .xcode15_0, .xcode14_0: nil
}
}

public var compatibilityVersion: String? {
switch self {
case .xcode16_3, .xcode16_0: nil
case .xcode15_3: "Xcode 15.3"
case .xcode15_0: "Xcode 15.0"
case .xcode14_0: "Xcode 14.0"
}
}
}
14 changes: 11 additions & 3 deletions Sources/XcodeGenKit/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@ extension Project {
XCodeVersion.parse(options.xcodeVersion ?? "14.3")
}

public var projectFormat: ProjectFormat {
options.projectFormat.flatMap(ProjectFormat.init) ?? .default
}

var schemeVersion: String {
"1.7"
}

var compatibilityVersion: String {
"Xcode 14.0"
var compatibilityVersion: String? {
projectFormat.compatibilityVersion
}

var objectVersion: UInt {
77
projectFormat.objectVersion
}

var preferredProjectObjectVersion: UInt? {
projectFormat.preferredProjectObjectVersion
}

var minimizedProjectReferenceProxies: Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@
LastUpgradeCheck = 1430;
};
buildConfigurationList = D91E14E36EC0B415578456F2 /* Build configuration list for PBXProject "Project" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down
1 change: 0 additions & 1 deletion Tests/Fixtures/SPM/SPM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
LastUpgradeCheck = 1430;
};
buildConfigurationList = 425866ADA259DB93FC4AF1E3 /* Build configuration list for PBXProject "SPM" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
LastUpgradeCheck = 1430;
};
buildConfigurationList = 3DFC1105373EDB6483D4BC5D /* Build configuration list for PBXProject "AnotherProject" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2447,7 +2447,6 @@
);
};
buildConfigurationList = D91E14E36EC0B415578456F2 /* Build configuration list for PBXProject "Project" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
LastUpgradeCheck = 1430;
};
buildConfigurationList = E903F6E8184E2A86CEC31778 /* Build configuration list for PBXProject "TestProject" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down