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

Support swift 5.0 #268

Merged
merged 7 commits into from
May 23, 2019
Merged

Support swift 5.0 #268

merged 7 commits into from
May 23, 2019

Conversation

kawoou
Copy link
Contributor

@kawoou kawoou commented Jan 29, 2019

  • Warning: 'index(where:)' is deprecated: renamed to 'firstIndex(where:)'
  • Add Package@swift-5.swift
  • Update podspec swift version

@djbe
Copy link
Contributor

djbe commented Jan 29, 2019

That was quick! 😆

Are there other things we can potentially migrate? There are new String protocols, and other things (see https://www.whatsnewinswift.com).

Instead of peppering the code with #if swift checks, we add backports for new functions. See the _SwiftSupport.swift file:
https://github.com/stencilproject/Stencil/blob/master/Sources/_SwiftSupport.swift

@soffes
Copy link

soffes commented Apr 4, 2019

Any word on this PR? I'd love to update to Swift 5 :)

@kawoou
Copy link
Contributor Author

kawoou commented Apr 5, 2019

@djbe I want to support #"..."# syntax for readability.
However, you must also support versions below Swift 5.
If I do, think the code will be less readable.

ex)

#if swift(<5.0)
self.format = format ?? Variable("\"yyyy-MM-dd 'at' HH:mm\"")
#else
self.format = format ?? Variable(#""yyyy-MM-dd 'at' HH:mm""#)
#endif

@kawoou kawoou force-pushed the master branch 2 times, most recently from 1a522a7 to a52991d Compare April 5, 2019 05:10
@djbe
Copy link
Contributor

djbe commented Apr 7, 2019

Is there more info about that SIL exception? Is it new in Swift 5? Radar?

@djbe
Copy link
Contributor

djbe commented Apr 7, 2019

Yeah, we won't be able to use raw strings until we drop 4.2 support 🤷‍♂️

@kawoou
Copy link
Contributor Author

kawoou commented Apr 10, 2019

@djbe Compile-time keywords(like #file) are expected to cause problems due to type inference errors during static dispatch.

Before: Throw SIL Exception (https://travis-ci.org/stencilproject/Stencil/jobs/508764850)

let path = Path(#file) + ".."  + "fixtures" + "huge.html"

After:

let basePath: String = #file //< Specify type
let path = Path(basePath) + ".."  + "fixtures" + "huge.html"

@djbe
Copy link
Contributor

djbe commented Apr 10, 2019

Would this work then?

let path = Path(#file as String) + ".."  + "fixtures" + "huge.html"

@keith
Copy link

keith commented Apr 10, 2019

This changed fixed PathKit https://github.com/kylef/PathKit/pull/69/files#diff-663087ac5b85edfc8e4ff1dd83b915abL12

Copy link
Contributor

@djbe djbe left a comment

Choose a reason for hiding this comment

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

Looks good to me. Unless there's any more feedback, I'll merge this tonight.

@djbe djbe merged commit e516ca9 into stencilproject:master May 23, 2019
@soffes
Copy link

soffes commented May 23, 2019

Awesome! Thanks so much for your effort on this!

Mind tagging a release with Swift 5 support?

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.

4 participants