What are the cases in which I should still use Objective-C instead of Swift?
Asked on 07/30/2024
1 search
While Swift is a powerful and modern language, there are still some cases where you might consider using Objective-C instead:
-
Legacy Codebases: If you are working on a project with a significant amount of existing Objective-C code, it might be more practical to continue using Objective-C, especially if the codebase is stable and well-tested.
-
Interoperability with C/C++: Although Swift has good interoperability with C and C++, there might be scenarios where the integration is more straightforward in Objective-C. For example, certain C++ features and libraries might be easier to use directly in Objective-C.
-
Performance Considerations: In some performance-critical applications, you might find that certain low-level optimizations are easier to achieve in Objective-C. For instance, managing memory manually can sometimes be more efficient than relying on Swift's Automatic Reference Counting (ARC).
-
Dynamic Features: Objective-C's runtime is highly dynamic, allowing for features like method swizzling, dynamic method resolution, and more. If your application relies heavily on these dynamic features, Objective-C might be a better fit.
-
Third-Party Libraries: Some third-party libraries and frameworks are still written in Objective-C. While you can use these libraries in Swift, you might find it easier to work with them directly in Objective-C.
For more details on Swift's performance and interoperability, you can refer to the sessions from WWDC:
These sessions provide insights into Swift's capabilities and how it compares to Objective-C in various scenarios.

Platforms State of the Union
Discover the newest advancements on Apple platforms.

Explore Swift performance
Discover how Swift balances abstraction and performance. Learn what elements of performance to consider and how the Swift optimizer affects them. Explore the different features of Swift and how they’re implemented to further understand the tradeoffs available that can impact performance.

SwiftUI essentials
Join us on a tour of SwiftUI, Apple’s declarative user interface framework. Learn essential concepts for building apps in SwiftUI, like views, state variables, and layout. Discover the breadth of APIs for building fully featured experiences and crafting unique custom components. Whether you’re brand new to SwiftUI or an experienced developer, you’ll learn how to take advantage of what SwiftUI has to offer when building great apps.