Create a Flutter project with Swift

浪子不回头ぞ 提交于 2020-02-26 18:28:33

问题


Flutter allows to support of Swift programming language.

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.


回答1:


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.




回答2:


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

// Update 2020

Nowadays the terminal command

flutter create --org com.yourdomain your_app_name

is enough. Swift, Kotlin, and Androidx dependencies are the default options

// end update

In the terminal in a desired directory run command

flutter create -i swift -a kotlin your_project_name

This util will create a project that you can run on iOS and on Android as well!

After you can develop it in IDE that suits for you

Full command for production can look like

flutter create --org com.yourcompany -i swift -a kotlin --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




回答3:


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



回答4:


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



来源:https://stackoverflow.com/questions/49069957/create-a-flutter-project-with-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!