Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically set the Signing Team on IOS cordova project?

I am trying to automate the build/deployment of my hybdrid mobile application in Jenkins using fastlane. I use ionic (v3.3.0) and cordova (v7.0.1) for the source. I use fastlane v2.36.0 and Xcode is version 8.3.2.

The command I run in the jenkins job

yarn
ionic cordova prepare
fastlane ios build

The fastlane/FastFile

platform :ios do
  before_all do
  end

  ios_project_path = "platforms/ios/awesomeproject.xcodeproj"

  desc "Build for IOS"
  lane :build do
    increment_build_number(
      xcodeproj: ios_project_path,
      build_number: ENV["BUILD_NUMBER"]
    )

    # Recreate schemes to ensure a smooth transition from cordova to gym
    recreate_schemes(project: ios_project_path)

    update_project_team(
      path: ios_project_path,
      teamid: "TEAMID"
    )

    #update_provisioning_profile_specifier(xcodeproj: ios_project_path)


      gym(scheme: "awesomeproject",
          configuration: "Debug",
          clean: true,
          project: ios_project_path,
          output_directory: "target")
  end
end

The fastlane/Appfile

package_name "com.xxx.awesomeapp"

app_identifier "com.xxx.awesomeapp" # The bundle identifier of your app
apple_id "[email protected]" # Your Apple email address

team_id "TEAMID" # Developer Portal Team ID

The command fastlane ios build is failing on the gym instruction with the error

Code signing is required for product type 'Application' in SDK 'iOS 10.3'

The detailed error in the fastlane log is

Check dependencies Signing for "awesomeproject" requires a development team. Select a development team in the project editor. Code signing is required for product type 'Application' in SDK 'iOS 10.3'

The xcode project generated by Cordova has the Automatic signing activated but it is missing the Signing Team. The workaround I used so far is to manually select the Team with Xcode the first time the platform/ios folder is generated. But if I remove the platform folder generated by cordova, I need to redo the selection of the team in XCode.

Is there a way to select with Cordova or any fastlane plugin the Signing team? I am open to use any solution, script. So my build will be fully automated. The update_project_team instruction is not working.

like image 747
La Chamelle Avatar asked Jun 05 '17 11:06

La Chamelle


People also ask

What is the latest version of Cordova iOS?

Cordova iOS 6.2. 0 Released! We are happy to announce that we have just released Cordova iOS 6.2.


1 Answers

Create a file called build.json in the root directory of your project, with the Team ID and provisioning profile GUID you want to use to sign the app:

build.json:

{
  "ios": {
    "debug": {
      "codeSignIdentity": "iPhone Developer",
      "provisioningProfile": "{your development profile}",
      "developmentTeam": "{your Team ID}",
      "packageType": "development"
    },
    "release": {
      "codeSignIdentity": "iPhone Distribution",
      "provisioningProfile": "{your distribution profile}",
      "developmentTeam": "{your Team ID}",
      "packageType": "app-store"
    }
  }
}

Then, when you build using the Cordova CLI, these signing credentials will be used.

Note: according to the Cordova documentation the above syntax is deprecated for Xcode 8 and iOS 10, and the provisioning profile GUID is no longer needed. However, I've been unable to get it working without specifying the provisioning profile using Cordova v7.0.1.

like image 133
DaveAlden Avatar answered Sep 28 '22 09:09

DaveAlden