I know most of the questions are about converting from objective-c to swift, but I'm looking for a tool that can convert a swift code to objective-c. When searching all I find is objective-c to swift.
Yes - I know I can put swift code inside objective-c project with a bridge-header - that's not what I'm looking for.
I need a tool that converts swift code to objective-c code. Is there such thing?
Import Swift code into Objective-C within the same framework: Under Build Settings, in Packaging, make sure the Defines Module setting for that framework target is set to Yes. Import the Swift code from that framework target into any Objective-C .
Create a Swift class for your corresponding Objective-C . m and . h files by choosing File > New > File > (iOS, watchOS, tvOS, or macOS) > Source > Swift File. You can use the same or a different name than your Objective-C class.
You can use Objective-C and Swift files together in a single project, no matter which language the project used originally. This makes creating mixed-language app and framework targets as straightforward as creating an app or framework target written in a single language.
Objective-C is the primary programming language you use when writing software for OS X and iOS. It's a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime.
There is no such tools for converting Swift code to Objective-C. There are some reasons. One is because Objective-C is a semantic subset of Swift, i. e. Objective-C doesn't have any equivalent of some fundamental features of Swift such as Generics, Algebraic data types, Pattern matching and other. Theoretically it is possible to make, but generated Objective-C code should be boilerplate and inefficient.
It is recommended to migrate your codebase to Swift to avoid technical debt there are many tools which can be used to convert Objective-C to Swift.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With