I've initially created a Flutter project with the native languages of Kotlin and Swift in Android Studio. Is there a way to change the native iOS language to Objective-C. This configuration only seems to occur on the creation of a Flutter project.
Flutter uses a flexible system that allows you to call platform-specific APIs in a language that works directly with those APIs: Kotlin or Java on Android. Swift or Objective-C on iOS. C++ on Windows.
The first release of Swift took place in 2014. It was positioned as a faster and more efficient programming language for creating iOS and macOS applications. It has become the fastest-growing programming language in history. Unlike Objective-C, Swift was built for the average developer.
Until 2014, all native iOS applications were created using Objective-C. Before the release of Swift, Objective-C was ranked 7th in the list of most popular programming languages. Some native applications are still being built using Objective-C, although Swift has become more popular for this.
You can work with types declared in Swift from within the Objective-C code in your project by importing an Xcode-generated header file. This file is an Objective-C header that declares the Swift interfaces in your target, and you can think of it as an umbrella header for your Swift code.
When declarations in an Objective-C header file refer to a Swift class or protocol that comes from the same target, importing the generated header creates a cyclical reference. To avoid this, use a forward declaration of the Swift class or protocol to reference it in an Objective-C interface.
For iOS the difference is mostly in ios/Runner.xcodeproj/project.pbxproj
and some different source code files are generated in ios/Runner
(the differences are too many to list them here)
For Android the differences are in android/build.gradle
, android/app/build.gradle
, and different source code files are generated in android/app/src/main
To switch languages you can delete the ios
and/or android
directory and run
flutter create -i swift -a kotlin .
If you made manual changes in files in these directories you need to re-apply them.
If you commit a project to Git and then switch language (as explained above), then it's easy to see what the differences are exactly.
Don't delete the ios
and android
directories. doing so makes you loose all the changes and updates in your file. just this flutter create -i swift -a kotlin .
Don't forget the dot at the end , this specifies that you want to make the changes in the current directory not create a new one.
after you run this follow the instruction and your app will have Swift support for iOS and Kotlin for android.
To make sure that you have Swift support take a look at your runner folder and see if it contains
AppDelegate.siwft
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