-
Notifications
You must be signed in to change notification settings - Fork 313
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
Make compatible with swift 4.1 #1271
Conversation
MapboxCoreNavigation/sequence.swift
Outdated
import Foundation | ||
|
||
extension Sequence where Element: Hashable { | ||
func compatibleFlatMap<ElementOfResult>(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not crazy about the name here -- is there another way we can define/extend compactMap
to delegate to flatMap
where compactMap
doesn't exist?
MapboxCoreNavigation/sequence.swift
Outdated
|
||
extension Sequence where Element: Hashable { | ||
func compatibleFlatMap<ElementOfResult>(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] { | ||
#if swift(>=4.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not crazy about using static version checks -- as an old ObjC'er, I prefer to check for API availability. Just my 2¢, but if we address my other comment we will be effectively doing that, so...
I was under the impression that Xcode 9.3 had a backward incompatible project structure 🤔 If that's the case, I think we should postpone this migration. |
Perhaps there is a new format, but it doesn't appear that this PR migrates us to it. In any event I don't think we should merge this as-is -- I would prefer a shim which doesn't introduce new API |
@frederoni is right, from the release notes:
We should hold on any xcode proj updates and just focus on swift 4.1 build time warnings. |
db8d3d4
to
a1cf398
Compare
Removed xcode proj 9.3 changes. |
@akitchen I think I made this as least intrusive as possible in 612a7e0. Going forward, we'd always use compactMap, and it'd port backwards nicely in swift 4.0 without a new API. Let me know what you think. Noting, I grabbed this from https://bugs.swift.org/browse/SR-6970 |
MapboxCoreNavigation/sequence.swift
Outdated
import Foundation | ||
|
||
extension Sequence where Element: Hashable { | ||
#if !swift(>=4.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strangely, #if swift(<4.1)
does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's silly, but 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file name have a capital S ?
This looks good to me. We can iterate from here if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename that file with a capital S and we're good to go
This gentle upgrades the project to xcode 9.3 and swift 4.1. In swift 4.1,
flatMap
was renamed tocompanctMap
. To allow previous versions of swift to build, I added an extension that uses the appropriate function.This also updates the project settings presented to me in xcode 9.3. Unsure about a few of them./cc @mapbox/navigation-ios