Open5

iOS(Flutter)でAutomatic Signingを設定しているプロジェクトにおいて、xcodebuildコマンドでビルドすると、ビルドされたアプリで「Appleでサインイン」が利用不可

ころむにーころむにー

xcodebuildのアーカイブ時にCode Signingを無効化しているために発生していた。
アーカイブ時にもCode Signingを有効にすると解消した。

flutter build ios --no-codesign
xcodebuild archive \
-    CODE_SIGNING_ALLOWED=NO 
    -workspace ./ios/Runner.xcworkspace \
    -scheme Runner \
    -configuration Release \
-    -archivePath ./build/ios/Runner.xcarchive
+    -archivePath ./build/ios/Runner.xcarchive \
+    -authenticationKeyIssuerID "${APPLE_API_ISSUER_ID}" \
+    -authenticationKeyID "${APPLE_API_KEY_ID}" \
+    -authenticationKeyPath "${APP_STORE_CONNECT_API_KEY_ABSOLUTE_PATH}"
xcodebuild -exportArchive \
    -archivePath ./build/ios/Runner.xcarchive \
    -exportPath ./build/ios/ipa \
    -exportOptionsPlist "${EXPORT_OPTIONS_PLIST_RELATIVE_PATH}" \
    -allowProvisioningUpdates \
    -authenticationKeyIssuerID "${APPLE_API_ISSUER_ID}" \
    -authenticationKeyID "${APPLE_API_KEY_ID}" \
    -authenticationKeyPath "${APP_STORE_CONNECT_API_KEY_ABSOLUTE_PATH}"
ころむにーころむにー

アーカイブの時にもCode Signingを適用すると、以下のようなエラーが出てCI/CD環境上でビルドができないようなので、この方法は見直した方がいいかもしれない。

[06:10:43]:/Users/runner/work/repository/repository/ios/Runner.xcodeproj: error: Device "Mac-1706851822826.local" isn't registered in your developer account. The device must be registered in order to be included in a provisioning profile. (in target 'Runner' from project 'Runner')
[06:10:43]:/Users/runner/work/repository/repository/ios/Runner.xcodeproj: error: No profiles for 'bundle.ID' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'bundle.ID'. (in target 'Runner' from project 'Runner')
ころむにーころむにー

最終的に以下の通りにするとAppleでサインインが利用可能になった。

  • XcodeのReleaseビルド構成で、最初からManual Signingに設定しておく
  • flutterのbuild ipaコマンドで、構成で指定されているSigning IdentityとProvisioning Profileの同じものを指定してビルドする