Expo SDK 37から46へ鬼のUpgrading作業(というかリプレイス作業)

いろいろ浦島太郎状態なので、キャッチアップ
migrate手順
The cleanest way to migrate your project is to initialize a new project with the bare workflow template and slowly migrate your existing project over.
新しくprojectつくってそこにコードを移しっていったほうがいいよ
了解!

eas っていうのができてる
今はこっちを使ってbuildしたりdeploy(app storeにupload)したりするらしい
nodeのバージョンも古い(12.16.1)し、レポジトリを新しく作って移行するか..

npm i -g expo-cli
を実行して expo-cli をインストール
npx create-expo-app my-app
でプロジェクトの作成

cd my-app
npm run ios
したら XCodeをインストールしてねって言われたのでインストールする
(端末も新しいからそこからインストールしなければ)

react-native-elements
は @rneui/themed @rneui/base
になっている

firebase もV9から仕様が変わっている

expo-linking
が expo から別パッケージに切り出されていたので
npm i expo-linking
を行う

それは Bare workflow にしたからか

iOS Bundling failed 725ms
While trying to resolve module `idb` from file `/Users/...node_modules/@firebase/app/dist/esm/index.esm2017.js`, the package `/Users/.../node_modules/idb/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/.../node_modules/idb/build/index.cjs`. Indeed, none of these files exist:
* .../node_modules/idb/build/index.cjs(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
* .../node_modules/idb/build/index.cjs/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
というエラーが発生
metro.config.js
を作成して設定を記述すると解消した

期待通りに iOS シミュレーターで動くようになった🎉
鬼のUpgradingって言っちゃったけど、画面3つぐらいしかない趣味のアプリだからたいした作業量ではなかった🙈

デプロイをEASで行ってみる
npm install -g eas-cli
eas login
eas build:configure
eas build

app.json
がないまま上記のコマンドを実行したが、build完了後によしなに app.json
が作成された
app name や bundler version などを調整したかったので app.json
を以前のものとあわせて修正して、再度build を行った

buildが完了して .ipa
ファイルが作成されたので、 eas submit
をやってみる

ASC API key を使って expoがapp store connect にアクセスできるようにする

error
ERROR ITMS-90186: "Invalid Pre-Release Train. The train version '1.0.0' is closed for new build submissions"
なるほど、versionを上げないといけない

app.json
を編集して再buildする必要がありそう?

eas submit
できて test flight からアプリを配信できるようになった
なったけど、なぜかアプリを開くとクラッシュしてしまう

クラッシュレポート見てもよくわからんな...
Last Exception Backtrace:
0 CoreFoundation 0x1804ad0fc __exceptionPreprocess + 220 (NSException.m:200)
1 libobjc.A.dylib 0x198cfdd64 objc_exception_throw + 60 (objc-exception.mm:565)
2 XXXXX 0x1005f1328 RCTFatal + 668 (RCTAssert.m:147)
3 XXXXX 0x100671a50 -[RCTExceptionsManager reportFatal:stack:exceptionId:extraDataAsJSON:] + 532 (RCTExceptionsManager.mm:77)
4 XXXXX 0x100672390 -[RCTExceptionsManager reportException:] + 1476 (RCTExceptionsManager.mm:147)
5 CoreFoundation 0x1804363a4 __invoking___ + 148
6 CoreFoundation 0x180453b74 -[NSInvocation invoke] + 468 (NSForwarding.m:3378)
7 CoreFoundation 0x18048a9d4 -[NSInvocation invokeWithTarget:] + 80 (NSForwarding.m:3475)
8 XXXXX 0x100623f38 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 460 (RCTModuleMethod.mm:584)
9 XXXXX 0x10062652c facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 540 (RCTNativeModule.mm:183)
10 XXXXX 0x10062615c operator() + 68 (RCTNativeModule.mm:104)
11 XXXXX 0x10062615c invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 112 (RCTNativeModule.mm:95)
12 libdispatch.dylib 0x18011d924 _dispatch_call_block_and_release + 32 (init.c:1517)
13 libdispatch.dylib 0x18011f670 _dispatch_client_callout + 20 (object.m:560)
14 libdispatch.dylib 0x180126df4 _dispatch_lane_serial_drain + 672 (inline_internal.h:2601)
15 libdispatch.dylib 0x180127968 _dispatch_lane_invoke + 392 (queue.c:3937)
16 libdispatch.dylib 0x1801321b8 _dispatch_workloop_worker_thread + 656 (queue.c:6727)
17 libsystem_pthread.dylib 0x1f0f3f0f4 _pthread_wqthread + 288 (pthread.c:2599)
18 libsystem_pthread.dylib 0x1f0f3ee94 start_wqthread + 8
Thread 8 Crashed:
0 libsystem_kernel.dylib 0x00000001b7a0d964 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001f0f45378 pthread_kill + 268 (pthread.c:1668)
2 libsystem_c.dylib 0x000000018b378f50 abort + 164 (abort.c:118)
3 libc++abi.dylib 0x0000000198e05bc4 abort_message + 132 (abort_message.cpp:78)
4 libc++abi.dylib 0x0000000198df6fd8 demangling_terminate_handler() + 332 (cxa_default_handlers.cpp:71)
5 libobjc.A.dylib 0x0000000198d03e34 _objc_terminate() + 144 (objc-exception.mm:701)
6 libc++abi.dylib 0x0000000198e04f58 std::__terminate(void (*)()) + 20 (cxa_handlers.cpp:59)
7 libc++abi.dylib 0x0000000198e04ef4 std::terminate() + 64 (cxa_handlers.cpp:88)
8 libdispatch.dylib 0x000000018011f684 _dispatch_client_callout + 40 (object.m:563)
9 libdispatch.dylib 0x0000000180126df4 _dispatch_lane_serial_drain + 672 (inline_internal.h:2601)
10 libdispatch.dylib 0x0000000180127968 _dispatch_lane_invoke + 392 (queue.c:3937)
11 libdispatch.dylib 0x00000001801321b8 _dispatch_workloop_worker_thread + 656 (queue.c:6727)
12 libsystem_pthread.dylib 0x00000001f0f3f0f4 _pthread_wqthread + 288 (pthread.c:2599)
13 libsystem_pthread.dylib 0x00000001f0f3ee94 start_wqthread + 8

Sentryを入れてみることにする

ちょっと関係ないけど ios の buildNumber
勝手にincrementするように設定

Sentryもうまく設定できないなー
イベントが来ない

ちょっと泥臭いけど、最初から画面をひとつひとつ追加して都度都度 build して実機で確認する作戦にする

react navigation の使い方が変わったのかも 👀

うーん、変わってなかったのかもだけど、
Stack Navigator
を使うなら expo install react-native-gesture-handler
してそれを App.js で import しないといけなかったらしい
当初はやっていたみたいだけど、それを忘れていた

Note: If you are building for Android or iOS, do not skip this step, or your app may crash in production even if it works fine in development. This is not applicable to other platforms.
たぶんこれに引っかかっていた

あ、この依存ライブラリをinstallしていなかった、これが原因かな?
expo install react-native-screens react-native-safe-area-context

これだった...解明できてよかった
これはversion up のせいではなく、普通に依存libraryのinstallを忘れていたせい...

ガチャガチャやりすぎてライブラリのバージョン依存関係がめちゃくちゃになってしまった
expo install
を使うこと!
たぶん最初に実装してたときはやってたんだけど忘れていて npm install
していた

依存関係がめちゃくちゃになってしまったら
expo doctor --fix-dependencies
するとよいことも学んだ