Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Swift support for existing project in flutter

I want to know if there is a way to enable swift support for flutter project. I only enabled Kotlin support while creating the project. I need to enable Swift too. Is there a command I can execute or any setting in flutter plugin for Android studio where I can enable or is there is an option to enable in Xcode?

This is what I want to do but for existing Flutter project

This is what I want to do but for existing Flutter project

like image 749
Shashi Kiran Avatar asked Sep 09 '18 12:09

Shashi Kiran


People also ask

Can I use Flutter with Xcode?

This article highlights the use of Flutter within the application Xcode. Flutter is a useful framework to utilize when developing both Android and iOS apps. Projects can be easily started within IDE's such as Visual Studio Code, Android Studio, and IntelliJ.


2 Answers

  1. Delete existing ios folder from root of flutter project.
  2. Run this command flutter create -i swift .

This command will create only ios directory with swift support.

like image 137
Jawand Singh Avatar answered Oct 04 '22 05:10

Jawand Singh


Well, I search the same thing now, also I enable the kotlin support... so, how to enable swift or kotlin support for a existing proyect?

  1. For swift support, you need to move your ios folder to outside of your project folder, for kotlin move outside the android folder, also check your package name in your manifest, or your PRODUCT_BUNDLE_IDENTIFIER

  2. Run the below flutter command in your terminal on root folder of your proyect (I'm using com.custom_name.my_proyect for the package name of this example)

    • -i swift is for swift
    • -a kotlin is for kotlin.
    • --org is to set the first two words of your package, in this case com.custom_name
    • --project-name is to set the last word of your package in this case my_proyect

You can use only switf/kotlin or both, (Don't forget the period '.' at the end of the command)

    flutter create -i swift -a kotlin --org com.custom_name --project-name my_proyect . 
  1. *Apply again your previous custom changes on the ios folder (E.g: info.plist, custom splash screen, etc.), now in Runner folder you don't have main.m and AppDelegate.h files, instead you have only the AppDelegate.swift file in swift language, so if you need to put API_KEYs there, the code is different.

  2. *If you apply -a kotlin line, is the same logic that swift in your android folder, so your MainActivy.java file is now a MainActivity.kt file in kotlin language, and you need to apply again your previous custom changes in Android folder (E.g: build.gradle, res folder, android_manifest, etc.).

like image 37
Hector Aguero Avatar answered Oct 04 '22 06:10

Hector Aguero