Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Pipeline in Azure DevOps

I am trying to build my flutter iOS App but I don't know how to get the ipa file.

pool:
  name: Default
  demands: xcode

steps:
- task: aloisdeniel.flutter.flutter-install.FlutterInstall@0
  displayName: 'Flutter Install'

- task: aloisdeniel.flutter.flutter-build.FlutterBuild@0
  displayName: 'Flutter Build ios'
  inputs:
    target: ios
    projectDirectory: 'src/Apps/platypus_app'
    buildName: '$(Build.BuildNumber)'
    entryPoint: 'lib/main_staging.dart'
    iosCodesign: false

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: 'src/Apps/platypus_app/build/ios'
    TargetFolder: '$(build.artifactstagingdirectory)'

- task: InstallAppleCertificate@2
  displayName: 'Install an Apple certificate'
  inputs:
    certSecureFile: 'ZooKeeper_Certs.p12'
    certPwd: ZooK33periOSKeyStore

- task: PublishPipelineArtifact@1
  displayName: 'Publish Pipeline Artifact'
  inputs:
    targetPath: '$(build.artifactstagingdirectory)'
    artifact: 'platypus_drop'

This pipeline builds but I get the following output:

enter image description here

There is no .ipa file so I think there is another step I have to do, but I am no iOS dev.

like image 435
DirtyNative Avatar asked Jun 11 '20 21:06

DirtyNative


People also ask

What is Azure App Center?

It brings together multiple services commonly used by mobile developers, including build, test, distribute, monitoring, diagnostics , etc., into one single integrated cloud solution.

How do I build a flutter project in Azure DevOps?

Flutter build task for Azure DevOps. Installation can be done using Visual Studio MarketPlace. Source code can be found on Github. Add the tasks to your build definition. Installs the Flutter SDK onto the running agent if not already installed.

What is Azure pipeline in flutter?

Azure Pipelines combines continuous integration (CI) and continuous delivery (CD) to test and build your code and ship it to any target constantly and consistently. Today we gonna use Azure Pipelines to help us achieve full automated deployment flow for our Flutter applications. So without further ado let’s dive into the tutorial

How to add Xcode task in flutter pipeline?

Add Xcode task after flutter task in your pipeline. Set the packageApp attribute to true. Set the exportPath attribute. The path you set for exportPath attribute is where the .ipa will be generated.

Can I use flutter in App Center?

However, there are some workarounds to get support for Flutter in App Center. You must first install the Azure Pipelines Flutter extension to distribute Flutter apps using App Center Distribute and Azure Pipelines. It is also a good idea to setup a service connection for App Center in Azure Pipelines, you can read more about that here.


2 Answers

You will need xCode task to generate .ipa file. See document here.

Add Xcode task after flutter task in your pipeline. Set the packageApp attribute to true. Set the exportPath attribute. The path you set for exportPath attribute is where the .ipa will be generated. See below example:

- task: Xcode@5
  inputs:
    actions: 'archive' 
    sdk: '$(sdk)'
    scheme: '$(scheme)'
    configuration: '$(configuration)'
    xcodeVersion: 'default' # Options: default, 10, 9, 8, specifyPath
    archivePath: 'src/Apps/platypus_app/build/ios/Runner.xcarchive'
    exportPath: 'src/Apps/platypus_app/build/ios'
    packageApp: true
    xcWorkspacePath: src/Apps/platypus_app/build/ios/Runner.xcworkspace
    signingOption: 'nosign'

Another workaround is to use a bash task to run xcodebuild command to generate .ipa file in your pipeline. See below example:

The .ipa file will be exported to the folder specified for -exportPath attribute

- task: Bash@3
    displayName: 'Create ipa package'
    inputs:
      targetType: 'inline'
      script: |
        xcodebuild -workspace ios/Runner.xcworkspace -scheme prod -sdk iphoneos -configuration Release-prod archive -archivePath build/ios/Runner.xcarchive
        xcodebuild -exportArchive -archivePath build/ios/Runner.xcarchive -exportOptionsPlist ci/ExportOptions.plist -exportPath build/ios/App.ipa

Please check out this thread for more information.

like image 188
Levi Lu-MSFT Avatar answered Nov 10 '22 23:11

Levi Lu-MSFT


You need to include the ExportOptions.plist file with flutter build ipa and you will get an ipa output in build/ios/ipa/your_app.ipa

- task: Bash@3
  displayName: "Build flutter iOS release"
  inputs:
    targetType: inline
    script: |
      flutter build ipa --release --build-name=1.0 --build-number 1 --export-options-plist=path/to/exportOptions.plist

Read here for more details: https://flutter.dev/docs/deployment/ios#create-a-build-archive

like image 42
Pierre Avatar answered Nov 10 '22 21:11

Pierre