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

Rename default templates to swift2 #47

Merged
merged 12 commits into from
May 17, 2017
19 changes: 11 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
### Breaking Changes

* Templates are now organized in subdirectories for each command.
[@djbe](https://github.com/djbe)
[David Jennes](https://github.com/djbe)
[#13](https://github.com/SwiftGen/templates/issues/13)
* Update templates to use the Stencil built-in `join` filter instead of our own.
[@djbe](https://github.com/djbe)
[David Jennes](https://github.com/djbe)
[#22](https://github.com/SwiftGen/templates/issues/22)
* Many deprecated templates have been removed, and others have been renamed to reflect new behaviours. We've prepared a migration guide which you can find here: [Documentation/MigrationGuide](https://github.com/SwiftGen/templates/blob/master/Documentation/MigrationGuide.md).
[David Jennes](https://github.com/djbe)
[#47](https://github.com/SwiftGen/templates/issues/47)

### New Features

Expand Down Expand Up @@ -73,7 +76,7 @@ _The templates tagged with this version are the ones embedded in SwiftGen 4.2._

* Initial tagging of templates as part of being split in their own repository.
* Templates are now linted and unit-tested, to ensure the code generated compiles properly.
[@djbe](https://github.com/djbe)
[David Jennes](https://github.com/djbe)
[#5](https://github.com/SwiftGen/templates/issues/5)
[#6](https://github.com/SwiftGen/templates/issues/6)
[#15](https://github.com/SwiftGen/templates/pull/15)
Expand All @@ -82,11 +85,11 @@ _The templates tagged with this version are the ones embedded in SwiftGen 4.2._
### Bug Fixes

* Use `escapeReservedKeywords` in all templates — to ensure compilation even for scenes named with a reserved keyword.
[@djbe](https://github.com/djbe)
[David Jennes](https://github.com/djbe)
[#3](https://github.com/SwiftGen/templates/issues/3)
[#14](https://github.com/SwiftGen/templates/pull/14)
* Storyboards templates don't `import` your app module anymore, removing that annoying warning.
[@djbe](https://github.com/djbe)
[David Jennes](https://github.com/djbe)
[#19](https://github.com/SwiftGen/templates/pull/19)
* It works by checking the environment variable `PRODUCT_MODULE_NAME`, which is automatically injected by Xcode if you run `swiftgen` as part of a Script Build Phase in your Xcode project.
* If you don't use `swiftgen` in a Script Build Phase of your Xcode project but manually in the terminal, you can instead use `swiftgen storyboards --param module=YourAppModuleName …` when invoking SwiftGen to inject it manually instead.
Expand All @@ -95,14 +98,14 @@ _The templates tagged with this version are the ones embedded in SwiftGen 4.2._

* Use an explicit bundle parameter to support frameworks for all templates.
[@NachoSoto](https://github.com/NachoSoto)
[@djbe](https://github.com/djbe)
[David Jennes](https://github.com/djbe)
[SwiftGen/SwiftGen#255](https://github.com/SwiftGen/SwiftGen/pull/255)
[#17](https://github.com/SwiftGen/templates/pull/17)
* Use `enum` instead of `struct` for namespacing in all templates.
[@djbe](https://github.com/djbe)
[David Jennes](https://github.com/djbe)
[#7](https://github.com/SwiftGen/templates/issues/7)
* Reworked templates to get rid of deprecated Stencil variables.
[@djbe](https://github.com/djbe)
[David Jennes](https://github.com/djbe)
[#8](https://github.com/SwiftGen/templates/issues/8)
[#9](https://github.com/SwiftGen/templates/issues/9)

Expand Down
54 changes: 54 additions & 0 deletions Documentation/MigrationGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Deprecated templates in 2.0 (SwiftGen 5.0) ##

The two general themes for this version are:

- Templates now reside in the subfolder corresponding to their subcommand (`colors`, `fonts`, ...) intead of the filename being prefixed with it.
- The `default` template doesn't exist anymore, templates now specify which swift version they support.

Below is a list of renamed and removed templates, grouped by subcommand. If your template isn't listed, you don't need to do anything.

### Colors ###

| Old | New | Reason |
| --- | --- | ------ |
| default | swift2 | |
| rawvalues | **deleted** | Seldomly used |

### Fonts ###

| Old | New | Reason |
| --- | --- | ------ |
| default | swift2 | |

### Images ###

| Old | New | Reason |
| --- | --- | ------ |
| all-values | **deleted** | The other templates by default now generate an `allValues` static constant |
| default | **deleted** | Deprecated by `dot-syntax` (now called `swift2`) |
| dot-syntax | swift2 | |
| dot-syntax-swift3 | swift3 | |
| swift3 | **deleted** | Deprecated by `dot-syntax-swift3` (now called `swift3`) |

### Storyboards ###

| Old | New | Reason |
| --- | --- | ------ |
| default | swift2 | |
| lowercase | **deleted** | No longer needed since we prefix classes with their module |
| osx-default | macOS-swift2 | |
| osx-lowercase | **deleted** | No longer needed since we prefix classes with their module |
| osx-swift3 | macOS-swift3 | |
| uppercase | **deleted** | No longer needed since we prefix classes with their module |

### Strings ###

| Old | New | Reason |
| --- | --- | ------ |
| default | flat-swift2 | |
| dot-syntax | structured-swift2 | |
| dot-syntax-swift3 | structured-swift3 | |
| genstrings | **deleted** | Seldomly used |
| no-comments-swift3 | **deleted ** | The other templates now support a `noComments` parameter |
| structured | **deleted** | Deprecated by `dot-syntax` (now called `structured-swift2/3`) |
| swift3 | flat-swift3 | |
54 changes: 0 additions & 54 deletions Documentation/colors/rawvalue.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

| Name | Description |
| --------- | ----------------- |
| File name | colors-default.stencil |
| Invocation example | `swiftgen colors -t default …` |
| File name | colors/swift2.stencil |
| Invocation example | `swiftgen colors -t swift2 …` |
| Language | Swift 2 |
| Author | Olivier Halligon |

Expand All @@ -14,7 +14,7 @@

## Customization

You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName>=<newValue>`

| Parameter Name | Default Value | Description |
| -------------- | ------------- | ----------- |
Expand All @@ -35,7 +35,7 @@ enum ColorName {
}
```

[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Colors/default-context-defaults.swift)
[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Colors/swift2-context-defaults.swift)

## Usage example

Expand Down
4 changes: 2 additions & 2 deletions Documentation/colors/swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Name | Description |
| --------- | ----------------- |
| File name | colors-swift3.stencil |
| File name | colors/swift3.stencil |
| Invocation example | `swiftgen colors -t swift3 …` |
| Language | Swift 3 |
| Author | Olivier Halligon |
Expand All @@ -14,7 +14,7 @@

## Customization

You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName>=<newValue>`

| Parameter Name | Default Value | Description |
| -------------- | ------------- | ----------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

| Name | Description |
| --------- | ----------------- |
| File name | fonts-default.stencil |
| Invocation example | `swiftgen fonts -t default …` |
| File name | fonts/swift2.stencil |
| Invocation example | `swiftgen fonts -t swift2 …` |
| Language | Swift 2 |
| Author | Olivier Halligon |

Expand All @@ -13,7 +13,7 @@

## Customization

You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName>=<newValue>`

| Parameter Name | Default Value | Description |
| -------------- | ------------- | ----------- |
Expand All @@ -34,7 +34,7 @@ enum FontFamily {
}
```

[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Fonts/default-context-defaults.swift)
[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Fonts/swift2-context-defaults.swift)

## Usage example

Expand Down
4 changes: 2 additions & 2 deletions Documentation/fonts/swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Name | Description |
| --------- | ----------------- |
| File name | fonts-swift3.stencil |
| File name | fonts/swift3.stencil |
| Invocation example | `swiftgen fonts -t swift3 …` |
| Language | Swift 3 |
| Author | Olivier Halligon |
Expand All @@ -13,7 +13,7 @@

## Customization

You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName>=<newValue>`

| Parameter Name | Default Value | Description |
| -------------- | ------------- | ----------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

| Name | Description |
| --------- | ----------------- |
| File name | images-dot-syntax.stencil |
| Invocation example | `swiftgen images -t dot-syntax …` |
| File name | images/swift2.stencil |
| Invocation example | `swiftgen images -t swift2 …` |
| Language | Swift 2 |
| Author | Olivier Halligon |

Expand All @@ -15,11 +15,12 @@ It also takes into account any namespacing folder in your Assets Catalogs (i.e.

## Customization

You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName>=<newValue>`

| Parameter Name | Default Value | Description |
| -------------- | ------------- | ----------- |
| `enumName` | `Asset` | Allows you to change the name of the generated `enum` containing all image names. |
| `noAllValues` | N/A | Setting this parameter will disable generation of the `allValues` constant. |

## Generated Code

Expand All @@ -35,7 +36,7 @@ enum Asset {
}
```

[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Images/dot-syntax-context-defaults.swift)
[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Images/swift2-context-defaults.swift)

## Usage example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

| Name | Description |
| --------- | ----------------- |
| File name | images-dot-syntax-swift3.stencil |
| Invocation example | `swiftgen images -t dot-syntax-swift3 …` |
| File name | images/swift3.stencil |
| Invocation example | `swiftgen images -t swift3 …` |
| Language | Swift 3 |
| Author | Olivier Halligon |

Expand All @@ -15,11 +15,12 @@ It also takes into account any namespacing folder in your Assets Catalogs (i.e.

## Customization

You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName>=<newValue>`
Copy link
Collaborator

@AliSoftware AliSoftware May 17, 2017

Choose a reason for hiding this comment

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

Should we repeat there that people can also just use --param <paramName> for boolean parameters, especially since this template use one (noAllValues)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah, I'd make a separate PR changing those lines to point to the StencilSwiftKit docs (or new SwiftGen docs) explaining how to customise templates.

Copy link
Member Author

Choose a reason for hiding this comment

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


| Parameter Name | Default Value | Description |
| -------------- | ------------- | ----------- |
| `enumName` | `Asset` | Allows you to change the name of the generated `enum` containing all image names. |
| `noAllValues` | N/A | Setting this parameter will disable generation of the `allValues` constant. |

## Generated Code

Expand All @@ -35,7 +36,7 @@ enum Asset {
}
```

[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift)
[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Images/swift3-context-defaults.swift)

## Usage example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

| Name | Description |
| --------- | ----------------- |
| File name | storyboards-osx-default.stencil |
| Invocation example | `swiftgen storyboards -t osx-default …` |
| File name | storyboards/macOS-swift2.stencil |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Those documentation files themselves should be renamed macOS-swift2.md, etc. right?

Copy link
Member Author

Choose a reason for hiding this comment

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

jup forgot that

| Invocation example | `swiftgen storyboards -t macOS-swift2 …` |
| Language | Swift 2 |
| Author | Olivier Halligon |

Expand All @@ -14,7 +14,7 @@

## Customization

You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName>=<newValue>`

| Parameter Name | Default Value | Description |
| -------------- | ------------- | ----------- |
Expand Down Expand Up @@ -60,7 +60,7 @@ enum StoryboardSegue {
}
```

[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Storyboards-macOS/default-context-all.swift)
[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Storyboards-macOS/swift2-context-all.swift)

## Usage example

Expand Down
6 changes: 3 additions & 3 deletions Documentation/storyboards/osx-swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

| Name | Description |
| --------- | ----------------- |
| File name | storyboards-osx-swift3.stencil |
| Invocation example | `swiftgen storyboards -t osx-swift3 …` |
| File name | storyboards/macOS-swift3.stencil |
| Invocation example | `swiftgen storyboards -t macOS-swift3 …` |
| Language | Swift 3 |
| Author | Olivier Halligon |

Expand All @@ -14,7 +14,7 @@

## Customization

You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName>=<newValue>`

| Parameter Name | Default Value | Description |
| -------------- | ------------- | ----------- |
Expand Down
Loading