4 ms·
I’m not an iOS/Mac developer, but aren’t Swift-only APIs common these days? How would this binding work in such cases, if at all?
by tambourine_man 3y ago
I’m not an iOS/Mac developer, but aren’t Swift-only APIs common these days?
How would this binding work in such cases, if at all?
- tarentel 3y agoSwiftUI related things might be the only swift-only API apple is actively working on as far as I know. If there's another one I don't remember it. Almost everything they release will be accessible in obj-c.
- Klonoar 3y agoThey've slowly started doing Swift-only pieces - e.g, App Intents are also Swift-only, WatchKit complications (I believe), CryptoKit (https://developer.apple.com/documentation/cryptokit/ https://developer.apple.com/documentation/cryptokit/), etc. (It's not a big blocker to still be tied to Objective-C IMO; I'm mostly just responding to the "might be the only swift-only API apple is actively working on" line.)
- jshier 3y agoNearly all "new" frameworks have been Swift-only over the last few years. Like you mention, CryptoKit and widgets, but also Combine, the entirety of SwiftUI, and even smaller things like the ProximityReader framework they released with iOS 15.4. They're even rewriting Foundation using Swift while exposing an Obj-C compatible ABI. Of course, any new API in frameworks which are already Obj-C are usually written in Obj-C and exposed to Swift. This means new Obj-C code will be written for years to come.
- flohofwoe 3y agoAs far as I'm aware only visionOS has some Swift-only frameworks. All the actually important frameworks for macOS and iOS development are still callable from ObjC.
- akmarinov 3y agoThere’s a whole bunch of frameworks that are Swift only like SwiftUI, WidgetKit, SwiftData, MusicKit, SharePlay, DeviceActivity and others and can’t be called from ObjC
- meepmorp 3y agoBut you can write Swift code that can be called from objc, right? Could you write a wrapper/shim in Swift for "object c" that you'd then call using the method outlined in the article?
- akmarinov 3y agoYou can yeah. With Apple’s older frameworks, you could use either though. It just shows that they’re gradually moving away from ObjC
- andrekandre 3y ago> Swift code that can be called from objc, right? Could you write a wrapper/shim in Swift for "object c" you could, but there are some things that are harder to represent such as structs and complex enums (since everything "objective" in obj-c is a reference), or even async/await based api's (perhaps with lots of black-based wrappers?)