flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.48k stars 26.73k forks source link

Error message about code signing when running `flutter build ipa` is confusing #148370

Open andrewkolos opened 2 weeks ago

andrewkolos commented 2 weeks ago

While investigating https://github.com/flutter/flutter/issues/148277, I tried running flutter build ipa on a new Flutter app. The tool fails with this output

andrewkolos-macbookpro:hello_world andrewkolos$ flutter build ipa

Archiving com.example.helloWorld...
Automatically signing iOS for device deployment using specified development team
in Xcode project: KW457W2YCN
Running Xcode build...                                                  
Xcode archive done.                                          2.9s
Failed to build iOS app
Error (Xcode): No profiles for 'com.example.helloWorld' were found: Xcode
couldn't find any iOS App Development provisioning profiles matching
'com.example.helloWorld'. Automatic signing is disabled and unable to generate a
profile. To enable automatic signing, pass -allowProvisioningUpdates to
xcodebuild.
/Users/andrewkolos/Desktop/deleteme/hello_world/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 archiving for device.
andrewkolos-macbookpro:hello_world andrewkolos$ open ios

The noteworthy part about this is

Verify that the Bundle Identifier in your project is your signing id in Xcode
  open ios/Runner.xcworkspace

I might just be missing some prerequisite knowledge here, but does this even make sense. Aren't signing identities and bundle identifiers completely disjoint concepts?

Moving on, I was able to get past this issue by opening the workspace, selecting the Runner project, selecting the Signing & Capabilities tab, and then choosing a valid Team under the Signing section.

Before: image

After: image

Interestingly, if I select None as the Team and run flutter build ipa, I get a much better error message that more or less describes the solution I had to figure out on my own:

andrewkolos-macbookpro:hello_world andrewkolos$ flutter build ipa

Archiving com.example.helloWorld...
Developer identity "Apple Development: andrewrkolos@gmail.com (9RH9RQHBKD)"
selected for iOS code signing
Running Xcode build...                                                  
Xcode archive done.                                          2.9s
Failed to build iOS app
Error (Xcode): No Account for Team "KW457W2YCN". Add a new account in Accounts
settings or verify that your accounts have valid credentials.
/Users/andrewkolos/Desktop/deleteme/hello_world/ios/Runner.xcodeproj

Error (Xcode): No profiles for 'com.example.helloWorld' were found: Xcode
couldn't find any iOS App Development provisioning profiles matching
'com.example.helloWorld'.
/Users/andrewkolos/Desktop/deleteme/hello_world/ios/Runner.xcodeproj

════════════════════════════════════════════════════════════════════════════════
Building a deployable iOS app requires a selected Development Team with a 
Provisioning Profile. Please ensure that a Development Team is selected 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 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

For more information, please visit:
  https://flutter.dev/docs/get-started/install/macos#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════
Encountered error while archiving for device.

I would have expected these instructions to have been included in the output from my first attempt to run flutter build ipa.