All Articles

[Flutter]Makefileのすすめ

Flutterのバージョンを管理するために、fvmというパッケージ管理ライブラリを使用しています。

そのため、全てのコマンドに fvmという接頭語を入力が煩わしく感じます。

fvm flutter clean
fmv flutter pub get

そこで、 Makefileというものを活用します。

プロジェクトルート直下にMakefileを作成します。 例えば、Makefileにこのように記載すると、

.PHONY: clean
clean:
	fvm flutter clean

ターミナルでmake cleanと入力し実行すると、 fvm flutter cleanが実行されます。

2行続けて書くこともできます。

.PHONY: ios-release-install
ios-release-install :
	fvm flutter build ios --no-sound-null-safety
	fvm flutter install

Makefile便利ですね。 PHONYという文字は特にわかっていません。私はフォ兄さんと呼んでいます。

A phony target is one that is not really the name of a file; rather it is just a name for a recipe to be executed when you make an explicit request. There are two reasons to use a phony target: to avoid a conflict with a file of the same name, and to improve performance.

参照

Published May 25, 2021

Flutterでスマホアプリ開発しています