简体   繁体   中英

iOS app that has both Objective-c and Swift - pros & cons

I work with an App that's 100% Objective-C and I'd like to start transitioning over to include Swift. Due to the size of the codebase, it's unrealistic that I'll have a 100% Swift app anytime soon.

As soon as a swift file is added, I noticed that the app size increases because now, the app needs to the include Swift run-time.

How else does things change? As soon as you include a Swift file, what is the process that the compiler and linker undergoes to ship a binary that is now multiple language & related frameworks?

Are there any other caveats in transitioning into a mixed language world in a somewhat large codebase?

In my experience, it works surprisingly well. It is advisable however, to wait to Xcode 7 / Swift 2.0 / Objective-C with generics support as that will eliminate a round of updates, allow you to interop from Objective-C with more elegant Swift code, and eliminate the Swift RT linking concern now that they have stabilized the runtime.

Aside from that, both compilers need to run, Swift first, Objective-C second, the swiftc compiler can be pretty fast or really really slow, depending on what innocent and otherwise legal Swift code that you write (this is also true of a Swift-only app of course).

Getting started, you need to read the interop guide, learn how the bridging header works, and are then mostly on your way. I would say that having a mixed app is actually a blessing as you are not pressed to learn and do everything at once. Opinions will vary of course, but this is mine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM