Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #179. Add currentXcodeVersion as an option. #182

Closed
Closed
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
12 changes: 9 additions & 3 deletions Sources/ProjectSpec/ProjectSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PathKit
import Yams

public struct ProjectSpec {

public var basePath: Path
public var name: String
public var targets: [Target]
Expand All @@ -20,6 +20,9 @@ public struct ProjectSpec {
public var include: [String] = []

public struct Options {
fileprivate static let defaultXcodeVersion = "0910"

public var currentXcodeVersion: String
Copy link
Owner

Choose a reason for hiding this comment

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

Can we name this just xcodeVersion. You probably just went with the old name, sure why the old property was currentXcodeVersion

Copy link
Owner

Choose a reason for hiding this comment

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

Can we also make this an optional and move the defaultXcodeVersion into XcodeGenKit. I'd prefer to keep any hardcoded values out of this module, as some people use it independently and it's really the generator that supports a certain version or not.

public var carthageBuildPath: String?
public var createIntermediateGroups: Bool
public var bundleIdPrefix: String?
Expand Down Expand Up @@ -47,7 +50,8 @@ public struct ProjectSpec {
}
}

public init(carthageBuildPath: String? = nil, createIntermediateGroups: Bool = false, bundleIdPrefix: String? = nil, settingPresets: SettingPresets = .all, developmentLanguage: String? = nil) {
public init(currentXcodeVersion: String? = nil, carthageBuildPath: String? = nil, createIntermediateGroups: Bool = false, bundleIdPrefix: String? = nil, settingPresets: SettingPresets = .all, developmentLanguage: String? = nil) {
self.currentXcodeVersion = currentXcodeVersion ?? Options.defaultXcodeVersion
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think most users of this option will know to use the XCODE_VERSION_ACTUAL format (0910) vs just specifying 9.1? Should we have some logic to accept multiple formats

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally think that’d be a matter of documentation, most users shouldn’t even need to set this, having multiple formats could be overdoing it IMHO.

Copy link
Owner

Choose a reason for hiding this comment

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

I think I agree with @rahul-malik here. If someone defines a string with a single . in it we could just join the parts and pad it out to the expected 4 digit number. This can happen in the XcodeGenKit through using an extension on ProjectSpec that also uses the default fall back as mentioned above.

self.carthageBuildPath = carthageBuildPath
self.createIntermediateGroups = createIntermediateGroups
self.bundleIdPrefix = bundleIdPrefix
Expand Down Expand Up @@ -119,7 +123,8 @@ extension ProjectSpec: Equatable {
extension ProjectSpec.Options: Equatable {

public static func == (lhs: ProjectSpec.Options, rhs: ProjectSpec.Options) -> Bool {
return lhs.carthageBuildPath == rhs.carthageBuildPath &&
return lhs.currentXcodeVersion == rhs.currentXcodeVersion &&
lhs.carthageBuildPath == rhs.carthageBuildPath &&
lhs.bundleIdPrefix == rhs.bundleIdPrefix &&
lhs.settingPresets == rhs.settingPresets &&
lhs.createIntermediateGroups == rhs.createIntermediateGroups &&
Expand Down Expand Up @@ -158,6 +163,7 @@ extension ProjectSpec {
extension ProjectSpec.Options: JSONObjectConvertible {

public init(jsonDictionary: JSONDictionary) throws {
currentXcodeVersion = jsonDictionary.json(atKeyPath: "currentXcodeVersion") ?? ProjectSpec.Options.defaultXcodeVersion
carthageBuildPath = jsonDictionary.json(atKeyPath: "carthageBuildPath")
bundleIdPrefix = jsonDictionary.json(atKeyPath: "bundleIdPrefix")
settingPresets = jsonDictionary.json(atKeyPath: "settingPresets") ?? .all
Expand Down
8 changes: 3 additions & 5 deletions Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ProjectSpec
public class PBXProjGenerator {

let spec: ProjectSpec
let currentXcodeVersion: String

let proj: PBXProj
let sourceGenerator: SourceGenerator
Expand All @@ -26,9 +25,8 @@ public class PBXProjGenerator {
var carthageBuildPath: String {
return spec.options.carthageBuildPath ?? "Carthage/Build"
}

public init(spec: ProjectSpec, currentXcodeVersion: String) {
self.currentXcodeVersion = currentXcodeVersion

public init(spec: ProjectSpec) {
self.spec = spec
proj = PBXProj(objectVersion: 46, rootObject: referenceGenerator.generate(PBXProject.self, spec.name))
sourceGenerator = SourceGenerator(spec: spec, referenceGenerator: referenceGenerator) { _ in }
Expand Down Expand Up @@ -109,7 +107,7 @@ public class PBXProjGenerator {

sortGroups(group: mainGroup)

let projectAttributes: [String: Any] = ["LastUpgradeCheck": currentXcodeVersion].merged(spec.attributes)
let projectAttributes: [String: Any] = ["LastUpgradeCheck": spec.options.currentXcodeVersion].merged(spec.attributes)
let root = PBXProject(name: spec.name,
reference: proj.rootObject,
buildConfigurationList: buildConfigList.reference,
Expand Down
5 changes: 2 additions & 3 deletions Sources/XcodeGenKit/ProjectGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ProjectSpec
public class ProjectGenerator {

let spec: ProjectSpec
let currentXcodeVersion = "0900"

public init(spec: ProjectSpec) {
self.spec = spec
Expand All @@ -24,7 +23,7 @@ public class ProjectGenerator {

public func generateProject() throws -> XcodeProj {
try spec.validate()
let pbxProjGenerator = PBXProjGenerator(spec: spec, currentXcodeVersion: currentXcodeVersion)
let pbxProjGenerator = PBXProjGenerator(spec: spec)
let pbxProject = try pbxProjGenerator.generate()
let workspace = try generateWorkspace()
let sharedData = try generateSharedData(pbxProject: pbxProject)
Expand Down Expand Up @@ -86,7 +85,7 @@ public class ProjectGenerator {
let archiveAction = XCScheme.ArchiveAction(buildConfiguration: scheme.archive?.config ?? defaultReleaseConfig.name, revealArchiveInOrganizer: true)

return XCScheme(name: scheme.name,
lastUpgradeVersion: currentXcodeVersion,
lastUpgradeVersion: spec.options.currentXcodeVersion,
version: "1.3",
buildAction: buildAction,
testAction: testAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
P_8448771205358 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0910;
};
buildConfigurationList = CL_844877120535 /* Build configuration list for PBXProject "Project" */;
compatibilityVersion = "Xcode 3.2";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Scheme LastUpgradeVersion="0900" version="1.3">
<Scheme LastUpgradeVersion="0910" version="1.3">
<AnalyzeAction buildConfiguration="Production Debug" />
<ArchiveAction buildConfiguration="Production Release" revealArchiveInOrganizer="YES" />
<TestAction selectedDebuggerIdentifier="Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier="Xcode.DebuggerFoundation.Launcher.LLDB" codeCoverageEnabled="YES" shouldUseLaunchSchemeArgsEnv="YES" buildConfiguration="Production Debug">
Expand Down