Discontinue Objective-C compatibility
1ec5 opened this issue · 4 comments
We’re discontinuing support for applications written purely in Objective-C to use the iOS navigation SDK. The same change will take place in the iOS navigation SDK: mapbox/mapbox-navigation-ios#2231. Applications written in Objective-C will need to implement compatibility shims in Swift to continue to interoperate with this library.
Since #47, we’ve half-heartedly supported Objective-C by ensuring bridgeability of key APIs, but there are many gaps in coverage, and the public API in Objective-C feels like a translation from another language. A renewed focus on Swift will eliminate a major source of technical debt. We’ll be able to write more idiomatic, less error-prone Swift code without compromising the developer experience in both languages.
Discontinuing Objective-C support will have the following immediate impacts on the codebase:
@objc
attributes andMB
class prefixes will disappear.- Methods whose sole purpose is to bridge to Objective-C will disappear.
- Enumeration declarations will move from Objective-C headers to Swift files.
- The CMapboxDirections target will be removed from the SPM distribution.
- References to Objective-C compatibility will be removed from readmes and jazzy guides.
We’ll hopefully be able to take advantage of some Swift language features in the process:
- Convert value classes to structures or enumerations with associated types.
- Convert abstract classes to protocols with default implementations.
- Move global constants under structures and classes.
- Replace magic default values with optionals.
- Replace NSCoding with Codable.
/cc @mapbox/navigation-ios
mapbox/mapbox-speech-swift#31 removes Objective-C support as well.
If your application is written in Objective-C, the changes in v1.0.0-alpha.1 don’t mean you have to rewrite your application in Swift, though you’re certainly free to do so. But you would at a minimum need to write a compatibility shim around the parts of MapboxDirections’ public API that your application uses. If you use the navigation SDK, mapbox/mapbox-navigation-ios#2231 (comment) has an example compatibility shim that you can adapt for your needs.