Flutter 버전을 편리하게 바꿔가며 사용할 수 있도록 fvm을 설치하는 방법을 간단히 정리
macOS 환경에서 Homebrew를 이용한 설치 방법
$ brew search fvm
기본적으로 brew search fvm로 검색해도 fvm이 존재하지 않음
brew tap 명령어를 이용해 fvm을 제공하는 Github Repository를 수동으로 추가해야 함
brew tap <user>/homebrew-<repository> 형태라고 생각하면 되며,
https://github.com/leoafarias/homebrew-fvm로부터 제공하는 패키지를 search, install 할 수 있게 됨
$ brew tap leoafarias/fvm
brew install leoafarias/fvm/fvm
위와 같이 설치하면 됨
$ dart pub global activate fvm
brew로 fvm을 설치하면 자동으로 dart까지 설치됨
위 명령어를 통해 fvm 활성화, 이후 fvm 명령어 사용 가능
$ fvm releases
...
Jan 5 23 │ 3.7.0-1.3.pre
Jan 11 23 │ 3.7.0-1.4.pre
--------------------------------------
Jan 23 23 │ 3.7.0-1.5.pre beta
--------------------------------------
Jan 24 23 │ 3.7.0
Feb 1 23 │ 3.7.1
Feb 8 23 │ 3.7.2
--------------------------------------
Feb 9 23 │ 3.7.3 stable
--------------------------------------
$ fvm install 3.7.3
Flutter "3.7.3" is not installed.
Installing version: 3.7.3...
Cloning into '/Users/x/fvm/versions/3.7.3'...
remote: Enumerating objects: 425276, done.
remote: Counting objects: 100% (122/122), done.
remote: Compressing objects: 100% (91/91), done.
Receiving objects: 23% (99449/425276), 83.36 MiB | 17.48 MiB/s
$ fvm use 3.7.3 --force
위 명령어 실행 이후 fvm flutter로 수행되는 모든 명령어가 3.7.3 버전으로 설정됨
$ fvm use 3.7.3
새 Flutter 프로젝트를 만들고 해당 디렉토리로 이동한 뒤, fvm use <version> 명령어를 통해 사용할 버전 선택 가능
$ fvm use 3.7.3
Not a Flutter project. Run this FVM command at the root of a Flutter project or use --force to bypass this.
Flutter 프로젝트 디렉토리가 아닌 경우 위와 같은 오류 메세지 표시됨
$ fvm list
Cache Directory: /Users/unknown/fvm/versions
3.7.3
$ fvm flutter --version
Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9944297138 (6 days ago) • 2023-02-08 15:46:04 -0800
Engine • revision 248290d6d5
Tools • Dart 2.19.2 • DevTools 2.20.1
$ fvm flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.3, on macOS 13.2 22D49 darwin-arm64, locale en-KR)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
다양한 Flutter SDK 버전이 공존하기 때문에 위처럼 fvm flutter doctor 형태로 fvm을 앞에 붙여 사용 가능