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

Add deployment target #205

Merged
merged 8 commits into from
Dec 26, 2017
Merged

Add deployment target #205

merged 8 commits into from
Dec 26, 2017

Conversation

yonaskolb
Copy link
Owner

@yonaskolb yonaskolb commented Dec 22, 2017

This changes how platform versions are applied.

  • removed all platform versions from the setting presets. This lets Xcode determine the latest version
  • added options.platformVersions to set project level versions
  • added target.platformVersion to set application specific version
options:
  platformVersions:
    watchOS: 3.0
    tvOS: 11.0
targets:
  App_iOS:
    type: application
    platform: iOS
    platformVersion: 10.0

These new options just apply default build settings, any any custom settings will still override this.

This is technically a breaking change, as those projects relying on the old default versions set in the setting presets will now have the latest platform version, which for example upgrade iOS 10 to iOS 11.1 (depending on Xcode version)

EDIT: renamed to deploymentTarget

@yonaskolb
Copy link
Owner Author

yonaskolb commented Dec 22, 2017

Is sdkVersion a better name than platformVersion

@alvarhansen
Copy link
Contributor

I think platformVersion is ok. sdkVersion should be avoided as it may create confusion with SDKROOT build setting.

SDKROOT = iphoneos11.2;
IPHONEOS_DEPLOYMENT_TARGET = 11.2;

@yonaskolb
Copy link
Owner Author

yonaskolb commented Dec 22, 2017

@allu22 Yeah fair enough. Another possible name would be deploymentTarget to match Xcode's UI terminology.

Also the properties on options.settingPresets could potentially just live directly on options with names like iOSVersion (or iOSDeploymentTarget). That means it's a bit cleaner if a spec just has one platform

@yonaskolb yonaskolb force-pushed the platform_version branch 2 times, most recently from 55763fb to 1379733 Compare December 22, 2017 10:55
@@ -51,7 +52,7 @@ public struct ProjectSpec {
}
}

public init(carthageBuildPath: String? = nil, createIntermediateGroups: Bool = false, bundleIdPrefix: String? = nil, settingPresets: SettingPresets = .all, developmentLanguage: String? = nil, indentWidth: Int? = nil, tabWidth: Int? = nil, usesTabs: Bool? = nil, xcodeVersion: String? = nil) {
public init(carthageBuildPath: String? = nil, createIntermediateGroups: Bool = false, bundleIdPrefix: String? = nil, settingPresets: SettingPresets = .all, developmentLanguage: String? = nil, indentWidth: Int? = nil, tabWidth: Int? = nil, usesTabs: Bool? = nil, xcodeVersion: String? = nil, platformVersions: PlatformVersions = .init()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should consider adding more new-lines.
It's hard for reviewers to scroll horizontally to see what has changed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1, is there a swift format setting to do this automatically?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Will do 👍

@@ -953,6 +948,7 @@
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this on purpose?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, the TestProject spec adds this

Copy link
Collaborator

@toshi0383 toshi0383 left a comment

Choose a reason for hiding this comment

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

LGTM👌

return lhs.iOS == rhs.iOS &&
lhs.tvOS == rhs.tvOS &&
lhs.watchOS == rhs.watchOS &&
lhs.macOS == rhs.macOS
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will probably be fine but will fail for instances where you might compare "11" and "11.0" since we are dealing with string equality vs a structured representation of a semantic version

Copy link
Owner Author

Choose a reason for hiding this comment

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

That's true. We could potentially implement a proper Version type (or use a dependency, like Swift PM), but at the moment it's probably fine

Choose a reason for hiding this comment

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

I think you could copy this implementation that I made for Sake https://github.com/xcodeswift/sake/blob/master/Sources/SakefileUtils/Version.swift that has the equatable defined. That'd solve this issue easily.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done. One change I had to make was have a getter on that version type that returns an Apple deployment version, as they use 9.0 not 9.0.0

public init(jsonDictionary: JSONDictionary) throws {

func parseVersion(_ platform: String) -> String? {
if let string: String = jsonDictionary.json(atKeyPath: .key(platform)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we just have the version input type as String for simplicity?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I just wanted to support the easy format of just iOS: 11.1 without wrapping it in a string

"bundleIdPrefix": "com.test",
"createIntermediateGroups": true,
"developmentLanguage": "ja",
"platformVersions": ["iOS": 11.1, "tvOS": 10.0, "watchOS": "3.0", "macOS": "10.12" ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be good for the test to have the case where we have 3 components to the version ("10.12.1" for example)

@yonaskolb
Copy link
Owner Author

I think I will change this to deploymentTarget. Any objections?


extension Platform {

public var versionBuildSetting: String {

Choose a reason for hiding this comment

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

I think it'd be great to unit test that this map is properly done.

Copy link

@pepicrft pepicrft left a comment

Choose a reason for hiding this comment

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

Just a minor comment. Nice addition @yonaskolb

@yonaskolb yonaskolb changed the title Add platform version Add deployment target Dec 26, 2017
@yonaskolb yonaskolb merged commit 554a9d2 into master Dec 26, 2017
@yonaskolb yonaskolb deleted the platform_version branch December 26, 2017 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants