Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to convert from Swift to objective-c [closed]

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?

like image 523
developer82 Avatar asked Nov 06 '15 10:11

developer82


People also ask

How do I import a Swift file into Objective-C?

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 .

How do I change from Objective-C to Swift?

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.

Can you use Objective-C in Swift?

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.

What is Objective-C used for?

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.


1 Answers

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.

like image 131
imnosov Avatar answered Oct 26 '22 03:10

imnosov