もくまっち開発 Week 7

これまで

Week 7 のやること

これを試すところから再開
# Uninstall the local cocoapods gem sudo gem uninstall cocoapods # Reinstall cocoapods via Homebrew brew install cocoapods

すでに Homebrew でインストールしてた
$ which pod
/opt/homebrew/bin/pod

Flutter のセットアップドキュメントがそうなってる

rosetta をインストールしたか忘れたので、下記を実行しておく
$ sudo softwareupdate --install-rosetta --agree-to-license
なんか、成功したのか失敗したのかよくわからない出力が...
By using the agreetolicense option, you are agreeing that you have run this tool with the license only option and have read and agreed to the terms.
If you do not agree, press CTRL-C and cancel this process immediately.
2024-01-21 23:12:51.904 softwareupdate[13763:1742283] Package Authoring Error: 052-14625: Package reference com.apple.pkg.RosettaUpdateAuto is missing installKBytes attribute
Install of Rosetta 2 finished successfully

成功したと思って先に進んでみる

$ sudo flutter build ios
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
📎
Building studio.protoout.miliconvalley.mochmatch for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: 9Z99MR8XP3
Warning: CocoaPods is installed but broken. Skipping pod install.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods.
To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
CocoaPods not installed or not in valid state.

CocoaPods が壊れてるって言われたので、一旦再インストールしてみる
brew reinstall ruby cocoapods

再度ビルド
sudo flutter build ios
Password:
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
📎
Building studio.protoout.miliconvalley.mochmatch for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: 9Z99MR8XP3
Warning: CocoaPods is installed but broken. Skipping pod install.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods.
To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
CocoaPods not installed or not in valid state.
結果かわらず。

ログ出してみたら原因がわかった。
$ sudo flutter build ios --verbose
(略)
[ +354 ms] /opt/homebrew/Cellar/cocoapods/1.14.3_1/libexec/gems/claide-1.1.0/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
(略)
CocoaPods は root 権限では実行できませんで、ということでした。
現状、僕の環境だとなぜか flutter コマンドが root で実行しないと書き込みエラーになるので詰んだ。

選択肢は下記。
-
flutter
コマンドをユーザー権限で実行できるように直す - GitHub Actions でのビルドに再チャレンジする

flutter コマンドをユーザー権限で実行できるように直す
エラーメッセージでググったら Xcode の設定変えたら解消するっぽいので、
先にそれを試してみる

おおおおおおおおおおおおおお
ビルド通ったあああああ
$ flutter build ios
Building studio.protoout.miliconvalley.mochmatch for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: 9Z99MR8XP3
Running Xcode build...
└─Compiling, linking and signing... 47.3s
Xcode build done. 101.8s
Built /Users/nix/ghq/github.com/protoout/mochmatch/build/ios/iphoneos/Runner.app.

$ flutter install
で接続してる実機にインストールできる

iPhone で動かしてみるとこんな感じ

もっとかかるかと思ってたけど今週のタスク完了!
- iOS アプリのビルド

タスク追加
- iOS アプリのビルド
- GitHub Actions でビルドできるようにする(iOS)
- 写真の before/after 確認

GitHub にコードをプッシュしたら JOB でエラー発生
Failed to build iOS app
Error (Xcode): No profiles for 'studio.protoout.miliconvalley.mochmatch' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'studio.protoout.miliconvalley.mochmatch'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.
/Users/runner/work/mochmatch/mochmatch/ios/Runner.xcodeproj
It appears that there was a problem signing your application prior to installation on the device.
Verify that the Bundle Identifier in your project is your signing id in Xcode
open ios/Runner.xcworkspace
Also try selecting 'Product > Build' to fix the problem.
Encountered error while building for device.

Xcode > Runnter > TARGETS/Runner > Signing & Capabilities > Signing > Automatically manage signing
をfalse
に変更

ローカルでビルドができないようになってしまったので戻した

--no-codesign
オプションをつけると解消するっぽい

flutter build ios --debug --no-codesign
でビルドしてみる

祝! GitHub Actions でも iOS ビルド通った :)

- iOS アプリのビルド
- GitHub Actions でビルドできるようにする(iOS)
- HEIC 画像の変換 & アップロード
- 写真の before/after 確認

写真の before/after も OK

- iOS アプリのビルド
- GitHub Actions でビルドできるようにする(iOS)
- HEIC 画像の変換 & アップロード
- 写真の before/after 確認

今週分のタスク完了 :)
あとは写真が横になってしまってるのを解決したら先週分も含めて完了できるぞ

元画像を jpeg → webp に圧縮してるんだけど、その過程で横になってしまってるっぽい

圧縮前は EXIF に画像方向の情報が入ってる
webp にもメタデータってあるのかな

プレビューアプリで確認したら TIFF
に回転情報が入ってた
TIFF っていうのもあるのか

WebP ファイルのほうにはなさそう

WebP にコンバートする前に、 EXIF から回転情報を基に画像を回転させておいてからコンバートする必要がありそう

rotate()を引数なしで実行することで、EXIFから読み込んだ回転情報が適用されます。
おぉ、便利だ

確かに rotate()
を追加したら、画像回転した

現状、 WebP ファイルでは回転情報が失われてしまってるので、一回 JPEG に戻す必要あるなぁ
最新データの取り込みといっしょに来週やろっと。

Week 7 もお疲れ様でした