Search code examples
iosxcodecordovaionic-frameworkazure-pipelines

Cordova: Azure Devops Pipeline Xcode build failed: Pods-Name does not support provisioning profiles. Pods-Name does not support provisioning profiles


Error:

Pods-Name does not support provisioning profiles. Pods-Name does not support provisioning profiles, but provisioning profile MobileAppProvisioning has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'Pods-Name' from project 'Pods')

  • Xcode: 12.4
  • Cordova CLI: 10.0.0
  • cordova-ios: 6.2.0

I build the ios app using the Ionic Cordova framework and build and deploy using Azure pipelines(CI). so, I have the following tasks in my Azure pipeline:

  • npm install
  • install cocoapod
  • cordova platform add ios
  • cordova build ios
  • installing apple certificates
  • Xcode build - throws the error when ARCHIVE with Above mentioned error
  • Copy file to artifacts
  • Publish artefacts

I have searched online for this and the solution is to change the Podfile and add the below code:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
            config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
            config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
        end
    end
end

But, As Azure pipeline generates the ios project dynamically when I run the command Cordova platform add ios and Pod file generates dynamically.

so, How to modify the Podfile in Azure pipeline to update the Podfile and resolve the error?


Solution

  • Cordova does not add support for iOS orientation by default, but you can get there by adding build hooks.

    To make this working, I followed these steps:

    Add the following to your config.xml file:

    <platform name="ios">
            <hook src="iosAfterPlatformAdd.js" type="after_platform_add" />
    </platform>
    

    Create a file named iosAfterPlatformAdd.js in the top-level directory and copy the below code in the file:

    const fs = require("fs");
    const execSync = require("child_process").execSync;
    console.log('iosAfterPlatformAdd hook called');
    
    execSync(`cd platforms/ios && pod deintegrate && cd ../../`, {
      stdio: "inherit"
    });
    
    const searchString = 'use_frameworks!';
    const fileName = './platforms/ios/Podfile';
    const appendText = `${searchString}
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
          config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
          config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
        end
      end
    end`;
    
    try {
      const data = fs.readFileSync(fileName, { encoding: 'utf8', flag: 'r' });
      let content = data.replace(searchString, appendText);
      const updatedData = fs.writeFileSync(fileName, content);
      console.log('Podfile', content);
    } catch (err) {
      console.error(err)
    }
    
    execSync("pod install --project-directory='./platforms/ios/'", {
      stdio: "inherit"
    });
    execSync("pod update --project-directory='./platforms/ios/'", {
      stdio: "inherit"
    });
    

    From the command line, run the below commands to change the Podfile automatically:

    cordova platform rm ios
    
    cordova platform add ios
    

    You should see the added lines in the Podfile file at this point. then the Archive and resolved the issue.