Flutter 개발환경 구성하기

정규호·2024년 10월 7일
0

Flutter OS System

Some Flutter components require the Rosetta 2 translation process on Macs running Apple silicon. To run all Flutter components on Apple silicon, install Rosetta 2.

sudo softwareupdate --install-rosetta --agree-to-license

Development tools

Download and install the following packages.

Xcode 15 to debug and compile native Swift or ObjectiveC code. The Xcode installation includes Git 2.27 or later to manage source code.

CocoaPods 1.15 to compile enable Flutter plugins in your native apps.
% sudo gem install cocoapods

ERROR:  Error installing cocoapods:
	The last version of drb (>= 0) to support your Ruby & RubyGems was 2.0.6. Try installing it with `gem install drb -v 2.0.6` and then running the current command again
	drb requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210.
    
% brew install cocoapods

...


% pod --version
1.15.2

[Pod error] sudo gem install cocoapods 실행 시 에러 (해결법 포함)

Download then install Flutter
Download then install Flutter

% unzip ~/Downloads/flutter_macos_arm64_3.24.3-stable.zip \
       -d ~/development/     

Add Flutter to your PATH
1. Launch your preferred text editor.

  1. If it exists, open the Zsh environmental variable file ~/.zshenv in your text editor. If it doesn't, create ~/.zshenv.

  2. Copy the following line and paste it at the end of your ~/.zshenv file.

% vi ~/.zshrc

export PATH=$HOME/developments/flutter/bin:$PATH

% source ~/.zshrc
% which flutter
/Users/username/developments/flutter/bin/flutter

Configure iOS development

  1. Open the App Store and sign in.

  2. Search for Xcode.

Click Install.

  1. The Xcode installer takes up 6+ GB of storage. The download might take some time.

  2. To configure the command-line tools to use the installed version of Xcode, use the following commands.

% sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch'

Use this path for the latest version of Xcode. If you need to use a different version, specify that path instead.

  1. Sign the Xcode license agreement.
% sudo xcodebuild -license

Configure your iOS simulator

  1. To install the iOS Simulator, run the following command.
% xcodebuild -downloadPlatform iOS
  1. To start the Simulator, run the following command:
% open -a Simulator

Configure Android development

To create Android apps with Flutter, verify that the following Android components have been installed.

Android SDK Platform, API 35.0.1
Android SDK Command-line Tools
Android SDK Build-Tools
Android SDK Platform-Tools
Android Emulator

Download android studio

Install Android SDK Command-line Tools

Install java first => OpenJDK

% brew update
% brew install openjdk

Set Up Environment Variables
Add the following lines to your ~/.zshrc (or ~/.bash_profile if you're using bash):

sudo ln -sfn $(brew --prefix openjdk)/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

% source ~/.zshrc
% java -version
% javac -version

Check if the Android Command Line Tools is installed already

% sdkmanager --version              

Install via Android Studio recommanded


Install via Download and manually, not recommen

Download the Android Command Line Tools

Android Studio Download page.

Extract the ZIP File:

Open Finder and navigate to your Downloads folder.
Double-click the ZIP file to extract it.
You'll get a folder named cmdline-tools.

Move the Command Line Tools to a Permanent Location

Create a directory for the Android SDK. A common location is in your home directory:

% mkdir -p ~/Library/Android/sdk

Create the cmdline-tools directory inside the SDK directory:

% mkdir -p ~/Library/Android/sdk/cmdline-tools

Move the extracted cmdline-tools folder into the new directory and rename it to latest:

mv ~/Downloads/cmdline-tools ~/Library/Android/sdk/cmdline-tools/latest

Set Up Environment Variables

%  vi ~/.zshrc

# add to it
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools

% source ~/.zshrc

Install SDK Components Using sdkmanager

Accept Licenses

yes | sdkmanager --licenses

Update the SDK Manager

sdkmanager --update

Agree to Android licenses

% flutter doctor --android-licenses

Check your development setup

% flutter doctor

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 3.24.3, on macOS 14.4.0 23E214 darwin-arm64, locale en)
[] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[!] Chrome - develop for the web
[!] Xcode - develop for iOS and macOS (Xcode not installed)
[] Android Studio (version 2024.1)
[] VS Code (version 1.93)
[] Connected device (1 available)
[] Network resources


! Doctor found issues in 2 categories.
profile
The Man Who Lift

0개의 댓글