112

I installed Flutter SDK, following steps, provided from this link: Install on macOS - iOS setup.

But I am unable to create a new sample project in Xcode. I can't find a proper way to start a new project using Xcode.

Here are steps to start a new sample project but not for Xcode: Get Started: Test Drive

How to create a new Flutter project in Xcode?

I'm using Xcode 9.3 - beta 3

Valentin Vignal
  • 6,151
  • 2
  • 33
  • 73
Krunal
  • 77,632
  • 48
  • 245
  • 261

13 Answers13

203

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

flutter create --org com.yourdomain your_app_name

This command will create a Simple Counter App

If you want a more advanced template (with a ListView / DetailView / Settings / Theme switch) that follows community best practices run the command (only since the Flutter 2.5 version):

flutter create --org com.yourdomain -t skeleton your_app_name

Swift, Kotlin, and androidx dependencies are the default options

After just open the created project in Android Studio or in VSCode

Parameter

--org com.yourcompany

will form applicationId for Android:

com.yourcompany.yourappname

and iOS PRODUCT_BUNDLE_IDENTIFIER:

com.yourcompany.yourAppName

To explore all possible parameters type

flutter create --help
Andrew
  • 36,676
  • 11
  • 141
  • 113
  • 2
    It would be great if you can also post a link to where this full command is documented. Couldn't find it anywhere. – kovac Oct 26 '19 at 07:20
  • 7
    @swdon just run in the terminal 'flutter create --help' All options are there – Andrew Oct 26 '19 at 16:31
  • What is project type in `flutter create -t ` mentioned here: https://flutter.dev/docs/development/androidx-migration – mLstudent33 Nov 14 '21 at 18:33
144

There's no need to use XCode

Use the flutter create command to create a new project:

In the terminal execute flutter create my_project_name

The command creates a Flutter project directory called my_project_name that contains a simple demo app.

Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432
43

Here is in advance! Without android studio, you can create new project with some arguments (Option Migration androidX, Platform languages).

flutter create --androidx -t app --org com.companyname.packagename -a kotlin -i swift myapp

Explore Yourself by Flutter CLI

flutter create --help

  • --[no-]pub : Whether to run "flutter pub get" after the project has been created. (defaults to on)

  • --[no-]offline : When "flutter pub get" is run by the create command, this indicates whether to run it in offline mode or not. In offline mode, it will need to have all dependencies already available in the pub cache to succeed.

  • --[no-]with-driver-test : Also add a flutter_driver dependency and generate a sample 'flutter drive' test.

  • -t, --template=≶type> : Specify the type of project to create:

     [app]                (default) Generate a Flutter application.
     [package]            Generate a shareable Flutter project containing modular Dart code.
     [plugin]             Generate a shareable Flutter project containing an API in Dart code with a platform-specific
                           implementation for Android, for iOS code, or for both.
    
  • -s, --sample=≶id> : Specifies the Flutter code sample to use as the main.dart for an application. Implies --template=app. The value should be the sample ID of the desired sample from the API documentation website (http://docs.flutter.dev). An example can be found at https://master-api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html

  • --list-samples=≶path> : Specifies a JSON output file for a listing of Flutter code samples that can created with --sample.

  • --[no-]overwrite : When performing operations, overwrite existing files.

  • --description The description to use for your new Flutter project. This string ends up in the pubspec.yaml file. (defaults to "A new Flutter project.")

  • --org : The organization responsible for your new Flutter project, in reverse domain name notation. This string is used in Java package names and as prefix in the iOS bundle identifier. (defaults to "com.example")

  • --project-name : The project name for this new Flutter project. This must be a valid dart package name.

  • -i, --ios-language : [objc, swift (default)]
  • -a, --android-language : [java, kotlin (default)]
  • --[no-]androidx : Generate a project using the AndroidX support libraries

Flutter Site: AndroidX Migration

Sen Sokha
  • 1,784
  • 16
  • 16
  • 2
    @JamesChristianKaguo The option is available in version < v1.12.13. Higher version no need to add, it was set default in new version. You can look the release note https://flutter.dev/docs/development/tools/sdk/release-notes/release-notes-1.12.13 for the pull request about migration androidx; https://github.com/flutter/flutter/pull/40925. – Sen Sokha Nov 18 '20 at 07:49
15

All other answers did not show the most correct description of the arguments of the flutter create.

The argument that has no name does NOT represent the name of your project, but it mainly represents the name of the folder, in which your project will be created, and in case --project-name argument is passed, the project name will be as same as the folder.

This is mentioned in the flutter create --help:

Usage: flutter create <output directory>
--project-name The project name for this new Flutter project. This must be a valid dart package name.

So in simple examples:

Creates a new project in the current directory (notice the dot .) without creating any new folder:

flutter create --project-name project_name .

Creates a new project in a new folder (whose name is different than the project's name):

flutter create --project-name some_name some-folder-name

Creates a new project in a new folder which has the same name:

flutter create some_name

Creates a new project in the current directory, by also specifying the fully qualified package name or Id (for Android and IOS):

flutter create --project-name some_name --org com.COMPANY .

One benefit of that, is if you want to create a Flutter project directly in a folder that does not follow the same naming rules that flutter projects/packages must follow (e.g. no dashes).

Mohammed Noureldin
  • 14,913
  • 17
  • 70
  • 99
10

Yet, there is no way to create a project using Xcode Editor.

As of now, you must have to create a project using 'Terminal' app.

Here I created a sample test_project using following terminal command

flutter create test_project

And here is my Xcode Project ready with workspace.

enter image description here

Krunal
  • 77,632
  • 48
  • 245
  • 261
MobileApps
  • 136
  • 4
4

In Android Studio there is direct option to Create new flutter project

In Editors using any command shell, if you want create sample project then this is usefull, to create sample project following command is used

flutter create sample_project

if you want to explore more:

flutter create --help
H4ckOm
  • 90
  • 4
4

Creating project in different languages:

  • iOS: Swift, Android: Kotlin

    flutter create --org <com.company> -i swift -a kotlin <package_name>
    
  • iOS: Swift, Android: Java

    flutter create --org <com.company> -i swift -a java <package_name>
    
  • iOS: Objective-C, Android: Kotlin

    flutter create --org <com.company> -i objc -a kotlin <package_name>
    
  • iOS: Objective-C, Android: Java

    flutter create --org <com.company> -i objc -a java <package_name>
    
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
3

Flutter create project

flutter create "project_name" - (without quotes) creates flutter application. 7 Flutter Commands

Vijay Ram
  • 385
  • 5
  • 12
3

create without any customization --> flutter create app_name

create with androidx -> flutter create --androidx -t app_name

create with androidx and package name -> flutter create --androidx -t --org com.companyname.packagename app_name

create with kotlin support -> flutter create --androidx -t --org com.companyname.packagename -a kotlin app_name

create with swift support -> flutter create --androidx -t app --org com.companyname.packagename -a kotlin -i swift app_name

or total command is ->

flutter create --androidx -t app --org com.companyname.packagename -a kotlin -i swift myapp
Rasel Khan
  • 2,976
  • 19
  • 25
3

You can set the Package name "Organization" of your Flutter application from the beginning rather than changing it later

Instead of using this command:

`flutter create <your_app_name>`

Use this command to create a Flutter project:

flutter create --org <com.your_domain> <your_app_name>

Or

flutter create "you_app_name" --org="your_domain"
2

In Visual Studio Code, you need to setup your organization first. Go to File -> Preferences -> Settings, search for flutter create organization. Edit your settings.json file and edit "dart.flutterCreateOrganization": "com.<your_domain>", for example com.awesomeapps. It will use that when creating a new flutter project.

Then, go to:

View -> Command Palette -> Flutter: New Project

Enter a name for the project, example: hello_world

Select a folder.

enter image description here

Make sure you have installed flutter, and the flutter and dart extensions first.

live-love
  • 48,840
  • 22
  • 240
  • 204
1

You can specify what folders you to create this file on the drive

By using the directory:

C:\ cd\ press Enter

If you want to change directory

C:\E: press Enter , this should base on the drive letter.

It will appears like this

E:\

Go to your file folder and copy the address Paste it in the Cmd, where you want your project to save. and press Enter

Eg: E:\cd E:\myAppfolder

To create the flutter project

Type Flutter create your packages name

Eg: E:\myAppfolder> flutter create myFristApp press enter

Kesselly Kamara
  • 143
  • 1
  • 6
0

To create a project with respect to your company or organization, the project name, and a project related to a specific platform, use this command. flutter create --org <com.company> <project_name> --platform=android