Skip to content

Support flutter build ipa with manual signing and provisioning profiles #106612

@michelesandroni

Description

@michelesandroni

Steps to Reproduce:

  • on a MacBook M1, install vs code, flutter 3.0.2
  • in vs code, create a new application project
  • open the 'ios' project in xcode
  • set the target's destination to any iOS Device (arm64, armv7)
  • go to Targets > Runner > Signing & Capabilities
  • turn OFF "Automatically manage signing"
  • assign an existing Bundle Identifier
  • assign an existing Provisioning Profile
  • go back to VS code and run the following in terminal:
    flutter build ipa
  • if you get an error "gen_snapshot_armv7 cannot be opened because the developer cannot be verified", click cancel, open the Settings application and go to Security & Privacy, then click "Allow Anyway" next to "gen_snapshot_armv7"
  • after fixing the "gen_snapshot_armv7" error re-run:
    flutter build ipa
  • at this point the xcode build should start in the terminal, displaying the various phases (compiling, linking, signing) followed by archive generation and ipa generation, which should fail.

Expected results: flutter should generate an ipa file.

Actual results:

Archiving com.<COMPANY-REMOVED>.<APP-NAME-REMOVED> ...
Automatically signing iOS for device deployment using specified development team in Xcode project: <TEAM-NAME-REMOVED>
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         7.0s
Xcode archive done.                                         24.8s
Built /Users/m1/Desktop/flutter_application_1/build/ios/archive/Runner.xcarchive.

💪 Building with sound null safety 💪

Building App Store IPA...                                           3.5s
Encountered error while creating the IPA:
error: exportArchive: "Runner.app" requires a provisioning profile.

Try distributing the app in Xcode: "open /Users/m1/Desktop/flutter_application_1/build/ios/archive/Runner.xcarchive"

Note:
I'm using manual signing because the actual app I'm working on uses the receive_sharing_intent package, which requires certain capabilities such as App Groups (required for the Share Extension to work) and Push Notifications (to avoid the warning email from Apple when submitting for app store publishing).
These capabilities in turn require the relative features enabled in the provisioning profile, which for some reason flutter (or xcode?) are apparently unable to handle automatically.

Manual signing is also convenient if you don't have an actual iOS device but you still want to export for the app store, otherwise xcode will throw the error "Failed to create provisioning profile. There are no devices registered in your account on the developer website.".

Workaround: I'm using the following commands which successfully generate an IPA, so I'm wondering if this could be somehow fixed and implemented in the build ipa command.
The file exportOptions.plist comes from a manual export made using xcode (not the CLI).
This means that the IPA must be exported manually from XCode at least once, to get the exportOptions.plist properly configured with certain project-specific stuff.
For example, in my real application I have a Share Extension, which is a secondary target also embedded in the IPA, with its own provisioning profile.

flutter clean
flutter build ios --release
xcodebuild -workspace $PWD/ios/Runner.xcworkspace -scheme Runner -sdk iphoneos -configuration Release archive -archivePath $PWD/build/ios/iphoneos/Runner.xcarchive
xcodebuild -exportArchive -archivePath $PWD/build/ios/iphoneos/Runner.xcarchive -exportOptionsPlist $PWD/ios/exportOptions.plist -exportPath $PWD/build/ios/iphoneos/Runner.ipa
Logs
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.0.1 21A559 darwin-arm, locale en-FR)
    • Flutter version 3.0.2 at /Users/m1/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (2 weeks ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.68.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (1 available)
    • macOS (desktop) • macos • darwin-arm64 • macOS 12.0.1 21A559 darwin-arm

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 3 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: releaseChallenges faced when attempting to productionize an appc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttercustomer: crowdAffects or could affect many people, though not necessarily a specific customer.platform-host-armBuilding on an ARM-based platformplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions