hey24sheep/azure-flutter-tasks

iOS Example

marc-wilson opened this issue ยท 6 comments

I see that there is an Android example within the azure-pipelines.yml file. Could we get an iOS equivillant?

Hi, I do not have a mac machine. It is hard to create a yml file for iOS. IOS uses a lot of other 3rd party tasks along with Flutter. We use a very old Flutter version so I do not know how IPA build works.

Here is a sample ios build config. After this step there are a few more steps of using Apple provising install and Apple cert install task

steps:
- task: Hey24sheep.flutter.flutter-build.FlutterBuild@0
  displayName: 'Flutter Build ios'
  inputs:
    target: ios
    projectDirectory: <your project>
    buildFlavour: <flavour>
    buildNumber: '$(Build.BuildNumber)'
    buildName: '$(buildTimeStamp)'
    entryPoint: 'lib/main_dev.dart'
    iosCodesign: false
    extraArgs: '--no-tree-shake-icons'

We build archive using this command
xcodebuild -exportArchive -archivePath Runner.xcarchive -exportPath Runner -exportOptionsPlist ios/export_dev.plist

I would really appreciate if anyone from the community can add a PR or a comment here for a nice clean yml config.

I have created a simple pipeline that works for iOS (with additional configuration steps) -> https://xeladu.medium.com/building-flutter-apps-with-azure-devops-eaf9ae7ad158?sk=dcdc007ae2c4fab7942ec5108f189c9a

Here is a working pipeline for iOS and Android:

trigger:
  - master

pool:
  vmImage: macOS-11

stages:
- stage: AndroidStage
  dependsOn: []
  displayName: Android
  jobs:

  - job: AndroidJob
    displayName: Android
    steps: 

    - task: DownloadSecureFile@1
      name: keyprop
      displayName: Download key properties file
      inputs:
        secureFile: 'key.properties'

    - task: DownloadSecureFile@1
      name: key
      displayName: Download signing key
      inputs:
        secureFile: 'key.jks'

    - task: Bash@3
      displayName: Copy config files
      inputs:
        targetType: 'inline'
        script: |
          cp $(keyprop.secureFilePath) $(Build.SourcesDirectory)/android/key.properties
          cp $(key.secureFilePath) $(Build.SourcesDirectory)/android/app/key.jks
          
          echo "key.properties copied to $(Build.SourcesDirectory)/android/key.properties"
          echo "key.jks copied to $(Build.SourcesDirectory)/android/app/key.jks"

    - task: FlutterInstall@0
      displayName: "Install Flutter SDK"
      inputs:
        mode: 'auto'
        channel: 'stable'
        version: 'latest'

    - task: FlutterBuild@0
      displayName: "Build application"
      inputs:
        target: 'aab'
        projectDirectory: '$(Build.SourcesDirectory)'

    - task: FlutterTest@0
      displayName: "Run unit tests"
      inputs:
        generateCodeCoverageReport: true
        projectDirectory: '$(Build.SourcesDirectory)'

    - task: CopyFiles@2
      displayName: "Copy app to staging directory"
      inputs:
        sourceFolder: '$(Agent.BuildDirectory)'
        contents: '**/bundle/**'
        targetFolder: '$(Build.StagingDirectory)'
        flattenFolders: true

    - task: PublishBuildArtifacts@1
      displayName: "Publish AAB file"
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'AAB'
        publishLocation: 'Container'

- stage: iOSStage
  dependsOn: []
  displayName: iOS
  jobs:
 
  - job: iOSJob
    displayName: iOS
    steps: 
          
    - task: InstallAppleCertificate@2
      displayName: Install certificate
      inputs:
        certSecureFile: 'iosKey'
        certPwd: 'yourPwd'
        keychain: 'temp'
    
    - task: InstallAppleProvisioningProfile@1
      displayName: Install provisioning file
      inputs:
        provisioningProfileLocation: 'secureFiles'
        provProfileSecureFile: 'ios_Profile.mobileprovision'
        
    - task: FlutterInstall@0
      displayName: "Install Flutter SDK"
      inputs:
        mode: 'auto'
        channel: 'stable'
        version: 'latest'

    - task: FlutterBuild@0
      displayName: "Build application"
      inputs:
        target: ipa
        projectDirectory: '$(Build.SourcesDirectory)'
        exportOptionsPlist: 'ios/exportOptions.plist'

    - task: FlutterTest@0
      displayName: "Run unit tests"
      inputs:
        generateCodeCoverageReport: true
        projectDirectory: '$(Build.SourcesDirectory)'

    - task: CopyFiles@2
      displayName: "Copy app to staging directory"
      inputs:
        sourceFolder: '$(Agent.BuildDirectory)'
        contents: '**/ipa/*.ipa'
        targetFolder: '$(Build.StagingDirectory)'
        flattenFolders: true

    - task: PublishBuildArtifacts@1
      displayName: "Publish IPA file"
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'IPA'
        publishLocation: 'Container'

@xeladu Hi, thank you for a great Medium guide and a clean yaml file. I have added the same to the readme FAQs as well as created a wiki for the same.

I will close this issue in response to a latest Medium article regarding setup

Could be even more complete if we had the key.properties and the build gradle file for this wiki :)

@vincentcastagna I do not have a sample config files as I'm no longer working on a Flutter project as or now. But public contributions are always welcomed and much appreciated ๐Ÿ˜„

@vincentcastagna Here is a guide how to create your key.properties file for Android and adapt the gradle file.