Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS build fails with: "Xcode couldn't find any iOS App Development provisioning profiles matching..." #49

Closed
MiroLiebschner opened this issue Jul 6, 2022 · 20 comments
Labels
help wanted Community help is needed

Comments

@MiroLiebschner
Copy link

MiroLiebschner commented Jul 6, 2022

The pipeline fails at the iOS build step. This is the error output: Error (Xcode): No profiles for 'com.addiscaTraining' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.addiscaTraining'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.

My export options file:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>generateAppStoreInformation</key>
	<false/>
	<key>manageAppVersionAndBuildNumber</key>
	<true/>
	 <key>provisioningProfiles</key>
    <dict>
        <key>com.addiscaTraining</key>
        <string>iOS_Profile.mobileprovision</string>
	<key>method</key>
	<string>app-store</string>
	<key>signingStyle</key>
	<string>manual</string>
	<key>stripSwiftSymbols</key>
	<true/>
	<key>teamID</key>
	<string>$(teamId)</string>
	<key>uploadBitcode</key>
	<false/>
	<key>uploadSymbols</key>
	<true/>
</dict>
</plist>

and my pipeline was created with the help of this medium article.
This is my pipeline:

  - master

pool:
  vmImage: macOS-12

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: FlutterCommand@0
      inputs:
        projectDirectory: '.'
        arguments: 'pub get'
    - task: FlutterCommand@0
      inputs:
       projectDirectory: '.'
       arguments: 'pub run build_runner build'     

    - 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: 'myCertPwd'
        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
        iosCodesign: false
        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'

Any help is highly appreciated, trying to get this to work for 2 days now :D

@hey24sheep
Copy link
Owner

This is a very common yet frustrating error. For some reason the provisioning profiles are not linked to the build on XCode and they fail during CI/CD. Give this , this and this a thorough read. Try to build locally once with XCode and remove and then re-apply the provisioning again in the settings.

It's mostly a try and error kind of a problem. I remember, I had this error a few years back and I had to re-create profiles and re-apply everything from the start. The issue is basically with Apple here. Let me know if you solve it by closing this issue.

@hey24sheep hey24sheep added the stale-inactive No response, considering this issue stale and inactive. Issue will be closed in a week. label Aug 12, 2022
@mannam95
Copy link

mannam95 commented Oct 1, 2022

This is a very common yet frustrating error. For some reason the provisioning profiles are not linked to the build on XCode and they fail during CI/CD. Give this , this and this a thorough read. Try to build locally once with XCode and remove and then re-apply the provisioning again in the settings.

It's mostly a try and error kind of a problem. I remember, I had this error a few years back and I had to re-create profiles and re-apply everything from the start. The issue is basically with Apple here. Let me know if you solve it by closing this issue.

Unfortunately, it doesn't work for me. I think there is a problem with the azure mac agent or mac os related problem.

I have tested on codemagic and everything works without any error.

@bperreault
Copy link

Just chiming in that I've also tried those steps and have no success. I get the same error. My setup and environment is very similar.

@hey24sheep
Copy link
Owner

I see, I am so confused. It works for our deployments. I will re-open this issue, if anyone from the community can shed some light. I do not have a Mac so, I cannot test anything much.

@hey24sheep hey24sheep added help wanted Community help is needed and removed stale-inactive No response, considering this issue stale and inactive. Issue will be closed in a week. labels Oct 3, 2022
@bperreault
Copy link

This is the pool named in my azure-pipelines.yml

pool:
  vmImage: 'macos-latest'

Which one do you use? I will try anything at this point.

@mannam95
Copy link

mannam95 commented Oct 3, 2022

This is the pool named in my azure-pipelines.yml

pool:
  vmImage: 'macos-latest'

Which one do you use? I will try anything at this point.

I have tried with macos-latest and macos-12. No luck.

Maybe @hey24sheep can you share your ExportOptions.plist by hiding any sensitive info?

@hey24sheep
Copy link
Owner

I do not have access to the DevOps anymore (I am looking for better jobs) so I do not know the settings. I can confirm one thing, we use flutter build ios.

I can recommend one thing, Try local hosted agent? Check if that works, if anyone can.

I can give you these details about the builds I setup in my org are as follows: (These worked before I was left from DevOps, few months back)

export_option.plist looks like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>method</key>
	<string>app-store</string>
	<key>provisioningProfiles</key>
	<dict>
		<key>co.organization.app</key>
		<string>Organization iOS Distribution</string>
	</dict>
</dict>
</plist>

1 - add Flutter install

2 - pod repo update

After that these steps follow

To generate IOS

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

To install Apple Cert

steps:
- task: InstallAppleCertificate@2
  displayName: 'Install an Apple certificate'
  inputs:
    certSecureFile: 'xyz_distribution.p12'
    certPwd: xyz
    setUpPartitionIdACLForPrivateKey: false

To install Apple Provisioning Profile

steps:
- task: InstallAppleProvisioningProfile@1
  displayName: 'Install an Apple provisioning profile'
  inputs:
    provProfileSecureFile: 'your_Distribution.mobileprovision'

To bump bundle version

/usr/libexec/Plistbuddy -c "Set CFBundleVersion $BUILD_BUILDNUMBER" Info.plist

To generate Archive

xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner archive -sdk iphoneos -configuration Release-development -archivePath Runner CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="iPhone Distribution: XYZ(ABC)" PROVISIONING_PROFILE= XYZ-GUID-HERE
PROVISIONING_PROFILE_SPECIFIER="SPECIFIER HERE"

To generate IPA

xcodebuild -exportArchive -archivePath Runner.xcarchive -exportPath Runner -exportOptionsPlist ios/export_options.plist

(if any) The only issues related to Provisioning Profiles got solved by deleting and recreating profiles and then re-linking them in XCode and uploading the same new profiles to Azure Devops. I know this build system is old but this is all I can give for IOS. I hope it can help you people.

If your apps are building locally on XCode or Flutter on Mac. Then something is definitely wrong with Azure or how it is interacting with this extension. Looking at a higher look (if you read the code), this extension just wraps the 'Flutter CLI' in fancy UI for Azure. I wish I can help more but this is all I got right now.

I have added 'HelpWanted', if someone from the community is kind enough to shed some light or solution.

@hey24sheep
Copy link
Owner

You can also have a look here. but, I know this isn't working for some of you.

@humanolaranja
Copy link

I'm facing the same issue, here are my pipeline steps:

- task: Hey24sheep.flutter.flutter-install.FlutterInstall@0
  displayName: 'Flutter Install'
  inputs:
    version: custom
    customVersion: 3.3.4

- task: Hey24sheep.flutter.flutter-command.FlutterCommand@0
  displayName: 'pub get'
  inputs:
    arguments: 'pub get '

- task: CocoaPods@0
  displayName: 'pod install'
  inputs:
    workingDirectory: ios
    forceRepoUpdate: true

- task: InstallAppleCertificate@2
  displayName: 'Install an Apple certificate '
  inputs:
    certSecureFile: iosbuild.p12
    setUpPartitionIdACLForPrivateKey: false

- task: InstallAppleProvisioningProfile@1
  displayName: 'Install an Apple provisioning profile'
  inputs:
    provProfileSecureFile: '${{parameters.profile}}.mobileprovision'

- task: Hey24sheep.flutter.flutter-build.FlutterBuild@0
  displayName: 'build ios'
  inputs:
    target: 'ipa'
    projectDirectory: '.'
    buildFlavour: '${{parameters.ambiente}}'
    iosCodesign: true
    additionalArguments: '--obfuscate --split-debug-info=$(Build.SourcesDirectory)/build'

Output:
image

@hey24sheep
Copy link
Owner

Are these builds working on local or other CI/CD? I have shared my pipeline/workflow above, is any of that helpful?

As I stated above, I have no access to the DevOps server or a Mac. I can only ask community to help here, sorry.

@humanolaranja
Copy link

Azure DevOps Pipelines CI/CD

I'm trying some of this suggestions, I'll keep you informed
In first time I was trying to use iosCodesign to true with profile install before the build

@humanolaranja
Copy link

The only way to solve this is using the xcode task too

1 - Install Apple Certificate
2 - Install an Apple provisioning profile
3 - Build with flutter and iosCodesign: false
4 - Generate ipa with xcode

My yaml:

- task: InstallAppleCertificate@2
  displayName: 'Install an Apple certificate'
  inputs:
    certSecureFile: iosbuild.p12
    setUpPartitionIdACLForPrivateKey: false

- task: InstallAppleProvisioningProfile@1
  displayName: 'Install an Apple provisioning profile'
  inputs:
    provProfileSecureFile: '${{parameters.profile}}.mobileprovision'

- task: Hey24sheep.flutter.flutter-build.FlutterBuild@0
  displayName: 'flutter build ios'
  inputs:
    target: 'ios'
    projectDirectory: '.'
    buildFlavour: '${{parameters.ambiente}}'
    iosCodesign: false
    exportOptionsPlist: 'ios/exportOptions.plist'
    extraArgs: '--release --obfuscate --split-debug-info=$(Build.SourcesDirectory)/build'

- task: Xcode@5
  displayName: 'Xcode Archive iOS'
  inputs:
    actions: 'archive'
    configuration: ${{parameters.config}}
    xcWorkspacePath: 'ios/Runner.xcworkspace'
    scheme: '${{parameters.ambiente}}'
    packageApp: true
    signingOption: 'manual'
    signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
    provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'

APPLE_CERTIFICATE_SIGNING_IDENTITY and APPLE_CERTIFICATE_SIGNING_IDENTITY are auto generated by step 1 and 2.

@ElaineBSchwaner
Copy link

@humanolaranja - Could you show us your ios/exportOptions.plist?

Thank you

@humanolaranja
Copy link

humanolaranja commented Jan 3, 2023

@ElaineBSchwaner

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>uploadBitcode</key>
	<true/>
	<key>compileBitcode</key>
	<true/>
	<key>uploadSymbols</key>
	<true/>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>********</string>
    <key>method</key>
    <string>app-store</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>signingCertificate</key>
    <string>Apple Distribution: **** S.A. (********)</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com.****.dev</key>
        <string>Azure DEV</string>
        <key>com.****.qas</key>
        <string>Azure QA</string>
        <key>com.****</key>
        <string>Azure PROD</string>
    </dict>
</dict>
</plist>

@ElaineBSchwaner
Copy link

Thank you @humanolaranja!

What is configuration: ${{parameters.config}} ?

@ElaineBSchwaner
Copy link

@MiroLiebschner Hi, Miro. Could you fix it?
Thank you

@humanolaranja
Copy link

Thank you @humanolaranja!

What is configuration: ${{parameters.config}} ?

The build configuration
image

@hey24sheep hey24sheep added the stale-inactive No response, considering this issue stale and inactive. Issue will be closed in a week. label Feb 10, 2023
@Adam-Langley
Copy link
Contributor

Adam-Langley commented Feb 13, 2023

Thank you @humanolaranja

For anyone still interested, I have another solution that may be better suited for some - it's certainly simpler and more robust for me.
The goal is to disable all signing other than what is defined in the "exportOptions.plist" file.

The key issue appears to be that the compile stage of the xcode task is code signing with what is configured in the pbxproj (even though "iosCodeSign=false") and that signature is then overwritten by the signing that occurs during the IPA export step. It means that you have to be careful to make sure that your xcode project is set up to work both on your dev machine, and during the various flavours of your CI builds (adhoc, appstore, etc) - threading the needle if you will.

So, all we need to do is disable the first codesign so that during CI, only the 'exportOptions.plist' file matters.
You can disable that by adding the following variables to your pipeline like this

  - job: iOSJob
    displayName: iOS
    variables:
      # FYI: Did you know, all Azure Pipeline variables are added to the build system environment?
      # The following variables will prevent Xcode from code-signing during build.
      # This is necessary, because we do not want to CI builds to be sensitive to code-signing settings configured by 
      # developers during development.
      # The 'exportOptions' will ultimately handle the code signing with the correct cert/prov profile.
      FLUTTER_XCODE_CODE_SIGN_IDENTITY: ""
      FLUTTER_XCODE_CODE_SIGNING_REQUIRED: NO 

Note:
Any variables prefixed with "FLUTTER_XCODE_" are picked up by the flutter build tool, and added to the xcodebuild command - after stripping the prefix of course.

The exportOptionsPlist: 'ios/exportOptions.plist' will still do the code signing that you have declared.

With this, I can have my "debug" xcode project use automatic signing to allow direct USB deployment and debugging on my device or simulator, but when built by CI, it will skip the code signing during compilation, and sign as per my exportOptions.plist - Ad-Hoc cert/prov-profile for my staging/QA builds, and AppStore cert/prov-profile for my finalised production builds.

It's also nice to know that I can mess about with my signing settings in the xcode project without having any effect on CI whatsoever.

@abdu292
Copy link

abdu292 commented Feb 16, 2023

@humanolaranja This worked for me as well. Thanks a bunch for sharing. This is very much appreciated.

@hey24sheep hey24sheep removed the stale-inactive No response, considering this issue stale and inactive. Issue will be closed in a week. label Feb 28, 2023
@hey24sheep
Copy link
Owner

I am assuming this issue is solved, I am closing this issue. Please, feel free to reopen in case it is not yet solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Community help is needed
Projects
None yet
Development

No branches or pull requests

8 participants