ExpoのEASにてAmplifyを組み込んだプロジェクトのBuild

EXPOのEASでBuildができたので、今度はAmplifyを組み込んだアプリを作成してビルドしてみる。まずは今までのBuild方法でテスト。
Expo Goを使わないでスマホ上で動くアプリ作成となります。

>expo start
にてexpo goにてビルドして動くことを確認

単体でのビルドしたことろ以下のエラー
✖ Build failed

🍎 iOS build failed:
Fastlane build failed with unknown error. Please refer to the "Run fastlane" and "Xcode Logs" phases.
Fastlane errors in most cases are not printed at the end of the output, so you may not find any useful information in the last lines of output when looking for an error message.

expoのクラウドのビルド画面にて以下のエラー
xcodebuild -showBuildSettings -workspace ./helloExpo.xcworkspace -scheme helloExpo -configuration Release
51[stderr] --- xcodebuild: WARNING: Using the first of multiple matching destinations:

旧ビルドの方法にて、プロビジョニングファイルを含んでビルドする方法が分かったのでテスト
まず、Apple developerにログインして手動でプロビジョニングファイルを作成する。
上から順に必要な設定は作成しておく

CertificatesはiOS Distributionタイプで
Identifiersは今回はjp.mooya.helloExpo2とした
Devicesにテストした端末のUUIDを登録
Profilesにて、これらの情報を含んだプロビジョニングファイルを作成

最初の選択が迷うがDistribusionのAd Hocを選択

あとは、設定してある項目を順に選んでいきプロファイルを作成しダウンロードしておく。
証明書やプロビジョニングファイルには、開発時に使用するdevelopmentと、リリース時に使用するdistributionの2つの種類があります。
• development
• 自分のxcodeで開発をして、実機にインストールする時などはdevelopment
• distribution
• アプリをarchiveして配信する場合はdistribution

参考ー>iOSアプリ開発の証明書周りがよくわかっていないので自分なりに整理してみた - tanihiro.log (hatenablog.com)

expo build:ios --provisioning-profile-path ダウンロードしたファイルのパス

これでipaファイルがクラウド側で出来上がり、ダウンロードできた。

あとは、配布のためにDeployGateを使ってファイルをアップロードし該当端末にインストールしたしたところ問題なく動いた。
これで、完全にテスト端末にてネイティブアプリを動かすことが可能となった。

ビルド時に以下のようなメッセージが出るのでこちらの方法は、来年4月まででおしまいになる模様
expo build:ios will be discontinued on January 4, 2023 (340 days left).

新しいビルドのエラーを調査したところ

EAS build has access to same version of your code as it is on git. Best option would be:
• encode aws-exports.js file to base64
• add encoded value as EXPO secret env variable
• decode that env variable back to aws-exports.js during pre-install phase "eas-build-pre-install" npm script. i.e.:
"scripts":{
"eas-build-pre-install": "echo $AWS_EXPORTS | base64 -d > ./src/aws-exports.js",
...
}
貼り付け元 https://stackoverflow.com/questions/70660772/eas-build-cant-find-aws-exports

このscripstsは
Expo Application Services(EAS)でReact Nativeアプリをビルドしてみた 【CI/CD】|デザミス株式会社 U-motion 開発チーム|note

にて
package.json
のようなので、記述してビルドしたところ、アプリができました。しかしaws cognitoのサービスとつながってない(>_<)

"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"test": "jest --watchAll",
"eas-build-pre-install": "echo $AWS_EXPORTS | base64 -d > ./src/aws-exports.js"
},

どうも、easはgitを利用しているようで、aws-exports.jsは.gitignoreにて含めないようにしていることが原因か
.gitignoreの中のaws-exports.jsの前に!をつけてからビルドしてみる

ビルドできた!

まず、
npm i amazon-cognito-identity-js
とする

またaws側で.gitignoreにてaws-exports.jsを含めて外れてしまうため
ビルド前に!を前につけて含めるようにする。

結果EASのサービスのみで、aws amplifyのコードも含んだプロジェクトをビルドし端末配布で実行できるところまで成功。

この記事が気に入ったらサポートをしてみませんか?