stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.33k stars 221 forks source link

Feat: Add support for Swift 4.0 #258

Closed Andrew-Lees11 closed 5 years ago

Andrew-Lees11 commented 5 years ago

I am part of the Kitura team and we would like to update to the latest version of Stencil, however since we support Swift 4.0 and so are unable to use the latest version unless Stencil also supports Swift 4.0.

This pull requests adds support for Swift 4.0 by

Swift 4.0.3 builds have also been added to travis to check for future Swift 4.0 is supported in future builds.

These changes allow Stencil to compile and run on Swift 4.0 while still compiling with no build warnings for Swift 4.1

djbe commented 5 years ago

I agree that we should define compactMap for older swift versions, and maybe we should do this in a _SwiftSupport.swift file, where we can collect all these backwards compat. fixes.

The == can also be implemented there.

Andrew-Lees11 commented 5 years ago

Hey Thank you for the quick review. As suggested I have moved all the changes into a single file. This extends Collection to so future compact maps and index should work for Swift 4.0 as well.

djbe commented 5 years ago

Note for those wondering: the file should be named _SwiftSupport so that it's the first to compile, otherwise Swift doesn't always find the extensions.

djones6 commented 5 years ago

@djbe Could this be tagged so that SwiftPM can pick up this fix?