Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Provide Swift 3 examples #21

Closed
1ec5 opened this issue Jun 18, 2016 · 6 comments
Closed

Provide Swift 3 examples #21

1ec5 opened this issue Jun 18, 2016 · 6 comments
Assignees
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented Jun 18, 2016

Now that Xcode 8 is in beta, we should provide Swift 3 examples or tailor the existing Swift examples to accommodate Swift 3 syntax using #if swift(3). Here are the most obvious changes that’ll affect our examples:

// Note “Center” instead of “CenterCoordinate”
mapView.setCenter(, animated: )
MGLMapCamera(lookingAtCenter: , fromDistance: , pitch: , heading: )

// Note the _ before mapView and “imageFor” instead of “imageForAnnotation”
func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage?

// Note the lowercase f
mapView.userTrackingMode = .followWithHeading

/cc @friedbunny @tmcw

@friedbunny friedbunny self-assigned this Jun 19, 2016
@friedbunny
Copy link
Contributor

The #if swift(version) syntax is available from Swift 2.2 and I would be comfortable requiring that version — it’s what’s shipping now with Xcode 7. Let’s give that a try and see how pretty/ugly it turns out.

@1ec5
Copy link
Contributor Author

1ec5 commented Jun 19, 2016

Xcode 7.3 and above also respects the SWIFT_NAME attribute on any symbol, so we can also use it to unify both versions around a symbol name where it makes sense to: mapbox/mapbox-gl-native#5178.

@friedbunny
Copy link
Contributor

Played with this a bit over last weekend and it looks like we’re going to need to go with a separate tab for Swift 3. Internally to this project, keeping a single .swift and using #if swift(version) should still be viable.

Punting this until at least after the v3.3.0 release process is finished.

@1ec5 1ec5 added this to the ios-v3.4.0 milestone Jul 18, 2016
@1ec5
Copy link
Contributor Author

1ec5 commented Aug 30, 2016

This is a good time to start adding Swift 3 to all our examples. New projects are being written in either Swift 2.3 or Swift 3. The fewer known dependencies, the more likely a developer is going to go with Swift 3 right off the bat. If so, our examples will require them to do a lot of manual fixup, because the migrator only works on projects that started out in Swift 2.3 or earlier.

We also need to build out some time to ensure that various repositories like /api-documentation and /help can cope with two versions of Swift being presented side-by-side.

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 1, 2016

Xcode 8.2 (now in beta) will be the final release of Xcode to support Swift 2.3. If supporting two versions of Swift at once is proving to be difficult, we need to drop Swift 2.3 examples in favor of Swift 3 as soon as possible.

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 19, 2016

This happened in #35.

@1ec5 1ec5 closed this as completed Dec 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants