Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Flutter project with Swift

Flutter allows to support of Swift programming language.

"Include Swift support for iOS code" in "Create New Flutter Project"

How can I integrate my Swift code file with Flutter project in Android Studio.

enter image description here

There is no option to add/create a Swift file (in New menu) in Android Studio.

like image 748
Krunal Avatar asked Mar 02 '18 13:03

Krunal


3 Answers

Creating project in:

iOS: Swift, Android: Kotlin

flutter create -i swift -a kotlin package_name

iOS: Swift, Android: Java

flutter create -i swift -a java package_name

iOS: Objective-C, Android: Kotlin

flutter create -i objc -a kotlin package_name

iOS: Objective-C, Android: Java

flutter create -i objc -a java package_name

Note:

Using above commands, you'll see the company name created is example, so to add your company name, simply add --org com.company right after flutter create like:

flutter create --org com.company -i swift -a kotlin package_name
like image 152
CopsOnRoad Avatar answered Oct 23 '22 13:10

CopsOnRoad


I think a better way is to create Flutter project by command line:

// Update 2021

In the terminal in a desired directory run command

flutter create --org com.yourdomain your_app_name

Swift, Kotlin, and Androidx dependencies are the default options

After you can develop it in IDE that suits for you

Full command for production can look like

flutter create --org com.yourcompany --description 'Your App Description' your_app_name

Params

--org com.yourcompany

will form applicationId for Android:

com.yourcompany.yourappname

and iOS PRODUCT_BUNDLE_IDENTIFIER:

com.yourcompany.yourAppName

parameter

--description 'Your App Description' 

sets package description in our pubspec.yaml

like image 37
Andrew Avatar answered Oct 23 '22 13:10

Andrew


Flutter uses Dart language.

Android - Java/Kotlin , iOS - Objc/Swift could be used to write plugins and platform dependent code. More details https://flutter.io/developing-packages/

When Flutter creates new project, it generates 2 native projects (iOS and Android), that would be able to run compiled Flutter project. Languages are selected via menu you posted. Check ios and android folders in created project.

like image 10
German Saprykin Avatar answered Oct 23 '22 11:10

German Saprykin