🐙

【Flutter】急にflutter runできなくなった(Xcodeからは実機ビルドできる)

2023/04/13に公開

環境

Flutter 3.7.8 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 90c64ed42b (3 weeks ago) • 2023-03-21 11:27:08 -0500
Engine • revision 9aa7816315
Tools • Dart 2.19.5 • DevTools 2.20.1

XcodeはAutomatically manage signingはオン

はじめに

いつもどおりflutter runしてiPhoneで実機ビルドしようとしたらsigningのエラーが出た

════════════════════════════════════════════════════════════════════════════════
No Provisioning Profile was found for your project's Bundle Identifier or your
device. You can create a new Provisioning Profile for your project in Xcode for
your team by:
  1- Open the Flutter project's Xcode target with
       open ios/Runner.xcworkspace
  2- Select the 'Runner' project in the navigator then the 'Runner' target
     in the project settings
  3- Make sure a 'Development Team' is selected.
     - For Xcode 10, look under General > Signing > Team.
     - For Xcode 11 and newer, look under Signing & Capabilities > Team.
     You may need to:
         - Log in with your Apple ID in Xcode first
         - Ensure you have a valid unique Bundle ID
         - Register your device with your Apple Developer Account
         - Let Xcode automatically provision a profile for your app
  4- Build or run your project again

It's also possible that a previously installed app with the same Bundle
Identifier was signed with a different certificate.

For more information, please visit:
  https://flutter.dev/setup/#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════

また同じエラーにはまらないように議事録として残しておきます。

結論から言うと

flutter cleanで治りました

やったこと

Provisioning Profileを削除

https://qiita.com/aitaro/items/540fe83c3fe1f7c7c620
エラーをググって一番上に出てきた、この記事を参考にして、過去のProvisioning Profileをすべて削除しても治らず

Podfileの更新

iosフォルダの中のpodfile.lockを削除し、pod install --repo-updateしても治らず

Signingを変更

XcodeのSigningのteamとBundle Identifierを変えても治らず

flutter clean

flutter cleanで治りました

調べていくと同じような事象で困っている人がいました
https://zenn.dev/nir_takemi/articles/9b40086f477a8b

直前にたくさんの修正対応をpullしたことや、flutterのversion up対応をしてたので、ゴミが残ってしまったみたい🤔?
解決後に発見したけど、ビルドエラーしたら、まずはcleanするのが良いとのことらしいです👀

そういえばビルドできなくなる前、↓な感じで落ちたなと思いました。
それのせいでゴミが溜まってうまく行かなくなったんだろうなと思いました。

*** First throw call stack:
(0x189e51a24 0x183245958 0x1988ef014 0x1988eecd4 0x1aee11c58 0x1aee11a7c 0x190d67850 0x190d687c8 0x190d3fad8 0x190d4cd48 0x190d4d514 0x1d28bcb14 0x1d28bc67c)
libc++abi: terminating with uncaught exception of type NSException
* thread #59, queue = 'com.apple.root.default-qos', stop reason = signal SIGABRT
    frame #0: 0x00000001c37b2274 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x1c37b2274 <+8>:  b.lo   0x1c37b2290               ; <+36>
    0x1c37b2278 <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1c37b227c <+16>: mov    x29, sp
    0x1c37b2280 <+20>: bl     0x1c37adc54               ; cerror_nocancel
Target 0: (Runner) stopped.
Lost connection to device.

結論

ビルドエラーしたらまずflutter clean

参考

https://zenn.dev/nir_takemi/articles/9b40086f477a8b
https://qiita.com/aitaro/items/540fe83c3fe1f7c7c620

Discussion