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

Viewed 6857

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 "xxx.xxxx@xxx.com" # 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.

1 Answers
Related