Blog post: How to expose (some) symbols from your #Swift library directly to #ObjC via headers.
This was a topic of conversation I had here some time ago, but I never put it together as a blog post. I hope you can use this in your own projects!
https://www.humancode.us/2023/08/09/objc-headers-swift-implementations.html
#swift #objc #ios #macos #programming
@el_gaucho If you like to create/use the backend in C and #ObjC (use @objfw), then you will be able to use #ObjC for the frontend. Either using #AppKit #UIKit on Apple devices or using #ObjGTK on other Posix devices as soon as I manage to complete it. As long you may want to look at @vala_lang which provides C bindings for many #FLOSS libraries and more if you create VAPIs yourself.
#objc #appkit #uikit #objgtk #floss
Really need to get back to @elementary at some point. It‘s beauty is a huge motivation to work on @GTK and #ObjC, also because #ObjGTK just feels like it belongs there.
I’m getting pretty fluent at writing #Swift these days, but I still miss writing in #ObjC. I banged out a command-line tool in ObjC and it was glorious. I love the laid-back nature of the language, its verbosity that makes the code immediately readable, and its not-super-eagerness to get everything fixed up at compile time.
Would I recommend ObjC over Swift for new projects? No. I think most people will create better programs in Swift than ObjC. But I do miss those good old days. The Delegate pattern with optional methods is *still* exceedingly powerful and IMO yet to be surpassed with callbacks, builders, or what-have-you. The ability to cheat and directly examine the runtime without too much type safety in LLDB is extremely refreshing too.
Anyway, back to Swift.
honestly, fucking #swiftlang is amazing!, it interops with #objc, and ofc, C, now they are paving the road to interop with #cplusplus, neat!, dunno why wasn’t took the backend world yet, sad, :/
https://forums.swift.org/t/accepted-a-vision-for-using-c-from-swift/65274
What's coming with mulle-objc (this post and several following):
https://www.mulle-kybernetik.com/weblog/2023/mulle_objc_0_22_1_1release.html
#objectivec #objc #programmingThatDoesntSuck
#objectivec #objc #programmingthatdoesntsuck
@ademalsasa @probono @gugurumbe Well, #ravynOS is an idea. I doubt there is any chance to create a working OS with such little manpower. Non the less #macOS and #GNUstep are completely #ObjC based. The main frameworks are not a feature that could be merged in on a later point. Many of the features of #MacOSX and #iOS were possible only due to the dynamic nature of #ObjC (and #Swift nowadays).
#ravynos #macos #gnustep #objc #macosx #ios #swift
@ademalsasa @gugurumbe I think there was a GNUstep release for evaluating it, but @probono dropped it in favour of Qt tech. So helloSystem is not about *step or #ObjC now.
If you want to get closer to that look at #Darling (https://www.darlinghq.org) or #ravynOS (https://airyx.org) or #Nextspace (https://trunkmaster.github.io).
#objc #darling #ravynos #nextspace
Time for an #ObjC #ObjectiveC question: Can I use lightweight generics to parameterize a *class* rather than a *class pointer*?
i.e. can I do…
@interface Foo<C>
- (instancetype)initWithClass:(C)aClass;
- (C *)instanceOfClass;
@end
As you know I spent a lot of time the past weeks figuring out how to expose #Swift classes and other types to #ObjC, allowing more-or-less type-checked, free bridging between the two languages.
I have now summarized what I’ve learned in a sample project you can check out here: https://github.com/dave-humancode/SwiftImplementations
tl;dr: a small set of macros and coding conventions allow *some* Swift symbols to be visible from ObjC.
Does exporting #ObjC compatibility headers simply not work with nested classes?
For instance, if I have the following #Swift classes:
@objc(MyOut) public class Out {
@objc(MyIn) public class In {}
}
The compatibility header will declare a MyOut interface mapping to Out (right), and a MyIn interface mapping to In (wrong: should be Out.In).
This makes it impossible to declare an objc method that takes a MyIn * to be called from Swift with an Out.In object.
https://developer.apple.com/documentation/swift/importing-swift-into-objective-c