Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging Objective-C project to Swift; what's the best method?

I want to migrate our large Objective-C-based iOS project to Swift. So what's the best way: Import Swift files into Objective-C, or import the Objective-C project into a fresh new Swift project? What will be the fastest ?

Thanks

like image 465
ExPl0siF Avatar asked Apr 19 '17 13:04

ExPl0siF


2 Answers

After time I spent of the project migration to the Swift I can say that it is no silver bullet in this question. It is really depending on the flow that is set-app in the team that you are working.

From my point of view and experience you should take existing project and start to write all new logic using Swift and in parallel try to rewrite business lawyers of the application in the modern way. For example network layer, database layer. In this way you reduce regression of the application and receive controlled migration flow.

Pros:

  • New logic will be in Swift.
  • Step by step migration will balance regression.
  • Suport of legacy code that impossible to rewrite to Swift
  • Writing code in Swift way (Protocols, Function, Generics, Structures)

Cons:

  • Time
  • Regression of the app
  • Quite big rewriting of the code.
like image 156
Oleg Gordiichuk Avatar answered Sep 23 '22 20:09

Oleg Gordiichuk


If you are starting a fresh project with the aim to only use Swift in the future, then I would create a new Swift project and then link to your Objective-C framework. This is what we did where I work, and slowly over time we have been deleting from the Objective-C project anything that is not being used. This may not be quicker than importing everything into the same project, but will give your code some separation from the old Objective-C code.

like image 29
totiDev Avatar answered Sep 21 '22 20:09

totiDev