24

Hi I just found out that it is possible to create Flutter project with Swift and Kotlin. However, I'm already invested in my current projects and want to recreate the ios and android as Swift and Kotlin (currently they are default to Java and ObjC).

Thanks.

Inquisitor K
  • 683
  • 1
  • 7
  • 19

4 Answers4

56

use -i and -a to create new project, like this:

flutter create -i swift -a kotlin project_name

see also:https://docs.flutter.dev/development/platform-integration/platform-channels#example-project enter image description here then replace with lib folder from old project.


update 2020.01.13
swift and kotlin are default now. you can use those command to update exist project:

cd project
flutter create .

this command will update your project. then you can merge you old code into new project, and remove old code.
make sure you backup your project before run it, and you know what are you exactly doing

dujianchi
  • 964
  • 8
  • 9
  • 6
    You can just delete the `ios/` and/or `android/` folder in your project and have them recreated using the command you suggested and then re-apply manual changes (easy if you use version control) – Günter Zöchbauer Nov 15 '18 at 06:51
  • @GünterZöchbauer I only want to recreate ios folder. please help with the command to use! – John Ravi Jun 27 '19 at 08:42
  • @John Ravi you can create a new project in other path, then copy ios folder replace old one. – dujianchi Jun 28 '19 at 08:02
  • I understand that new project should hold the same name as original project. Am I right? @dujianchi – John Ravi Jun 28 '19 at 09:29
  • 1
    @John Ravi yes, better to hold the same name as original project, because package name(android)/bundle id(ios) has relate by native project. but not absolutely. and you can create project with package name/bundle id ,like this: flutter create --org aaa.bbb prj ,then new project's package name/bundle id will be aaa.bbb.prj – dujianchi Jun 30 '19 at 06:28
  • What is the command to create android version without kotlin support? – Janaka Dec 26 '20 at 16:53
  • `flutter create -i swift -a kotlin .` within the project folder worked for me – RumbleFish Apr 14 '21 at 04:34
37

You can also run flutter create -i swift . inside your app folder, to regenerate ios folder.

I've not tested android, but I guess the same should work for it too - flutter create -a kotlin .

Igor Zboichik
  • 559
  • 5
  • 9
  • Is there a way to create a project without kotlin support? – Janaka Dec 26 '20 at 17:03
  • @Igor Zboichik The given command does work for android as well, but you are required to add your project name after "create" to create or repair the given project. – quantum apps Nov 12 '21 at 08:23
  • @Janaka just switch kotlin for java in your command. – quantum apps Nov 12 '21 at 08:24
  • 1
    If your project folder name is not a valid name though, you can specify a new name like so: `flutter create -i swift -a kotlin . --project-name=my-project-name`. You should actually place the project name that is used in the `pubspec.yaml`. – Martin Braun Jun 28 '22 at 16:27
8

I just deleted default ios and android folder in my flutter project. now in order to generate these default folder again you can use this below command :

flutter create .

Note : "." is also part of command , also make sure that your project folder name should not contain spaces or special characters which are invalid for package name.

MANISH
  • 2,883
  • 4
  • 11
  • 30
0

Generate iOS Folder

For Creating only iOS Folder into your existing Flutter project

flutter create --platforms ios swift

and output like this

Creating project swift...
  swift/ios/Runner.xcworkspace/contents.xcworkspacedata (created)
  swift/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created)
  swift/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings (created)
  swift/ios/Runner/Info.plist (created)
  swift/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png (created)
  swift/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png (created)
  swift/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md (created)
  swift/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json (created)
  swift/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png (created)
  swift/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png (created)
  swift/ios/Runner/Base.lproj/LaunchScreen.storyboard (created)
  swift/ios/Runner/Base.lproj/Main.storyboard (created)
  swift/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata (created)
  swift/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created)
  swift/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings (created)
  swift/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (created)
  swift/ios/Flutter/Debug.xcconfig (created)
  swift/ios/Flutter/Release.xcconfig (created)
  swift/ios/Flutter/AppFrameworkInfo.plist (created)
  swift/ios/.gitignore (created)
  swift/test/widget_test.dart (created)
  swift/swift.iml (created)
  swift/.gitignore (created)
  swift/.metadata (created)
  swift/pubspec.yaml (created)
  swift/README.md (created)
  swift/ios/Runner/Runner-Bridging-Header.h (created)
  swift/ios/Runner/AppDelegate.swift (created)
  swift/ios/Runner.xcodeproj/project.pbxproj (created)
  swift/lib/main.dart (created)
  swift/.idea/runConfigurations/main_dart.xml (created)
  swift/.idea/libraries/Dart_SDK.xml (created)
  swift/.idea/libraries/KotlinJavaRuntime.xml (created)
  swift/.idea/modules.xml (created)
  swift/.idea/workspace.xml (created)
Running "flutter pub get" in swift...                               4.9s
Wrote 50 files.

All done!
In order to run your application, type:

  $ cd swift
  $ flutter run

Your application code is in swift/lib/main.dart.
Vivek
  • 4,916
  • 35
  • 40