简体   繁体   中英

Create a Flutter project with Swift

Flutter allows to support of Swift programming language.

“创建新的 Flutter 项目”中的“包括对 iOS 代码的 Swift 支持”

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

在此处输入图像描述

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

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

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.

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

the best option will be to open your ios folder in xcode and add and edit your code there

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