Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Fix swift 3 named colors issue on Xcode 8 #76

Merged
merged 7 commits into from
Aug 21, 2017

Conversation

djbe
Copy link
Member

@djbe djbe commented Aug 21, 2017

@AliSoftware
Copy link
Collaborator

Might be worth making the typealias name customisable via a param so that in case other name collision occurs (someone already declared a type name Color in their own code before starting to integrate SwiftGen in their project for example) they could change it easily

  • typealias {{param.coloralias|default:"AssetColorTypeAlias"}} for xcassets templates
  • {{param.coloralias|default:"Color"}} for the colors templates

wdyt?

@@ -1,14 +1,16 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

{% if catalogs %}
{% set colorAlias %}{{param.colorAliasName|default:"AssetColorTypeAlias"}}{% endset %}
{% set imageAlias %}{{param.imageAliasName|default:"Image"}}{% endset %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Such a shame that these two aliases don't end up to be similar (but I know, would be breaking because typealias Image was already existing before :-/ )

typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias AssetColorTypeAlias = UIColor
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use the occasion of this test case to also customise the color & image typealias names in addition to the enumName being customised to XCTColorAsset (same for all *-customname.swift test & expected of course). This way we're sure we didn't forget to replace some hardcoded Color identifier with {{colorAlias}} at some point.

@AliSoftware AliSoftware merged commit 5c1a506 into master Aug 21, 2017
@AliSoftware AliSoftware deleted the fix/swift3-named-colors branch August 21, 2017 14:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants