JFortYork
JFortYork

Reputation: 147

Fastlane build error - No Team Found in Archive, Use the Signing & Capabilities editor to assign a team to the targets and build a new archive

I'm inexperienced with Ruby/Fastlane, but I'm trying to get a specific lane (ie. called enterprise_dev_ist) to build our project successfully.

I'm trying to get the project to build in our development environment which requires Automatic Code Signing. I'm not sure what exactly I need to change to get this to work, but the fastlane build is failing at the gym step with this error:

First Error

+ xcodebuild -exportArchive -exportOptionsPlist /var/folders/9c/95cv7y6s6r3g8r5jg4djrrn40000gp/T/gym_config20241114-41947-sdk2te.plist -archivePath ./build/Newton.xcarchive -exportPath /var/folders/9c/95cv7y6s6r3g8r5jg4djrrn40000gp/T/gym_output20241114-41947-5hhila CODE_SIGN_STYLE=Automatic MOB_ENV=IST0 SKIP_BUILD_ARCHIVE=true -skipPackagePluginValidation -skipMacroValidation
2024-11-14 11:22:10.617 xcodebuild[49209:810095] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path "/var/folders/9c/95cv7y6s6r3g8r5jg4djrrn40000gp/T/RBCLaunch_2024-11-14_11-22-10.613.xcdistributionlogs".
2024-11-14 11:22:11.110 xcodebuild[49209:810095] [MT] IDEDistribution: Command line name "ad-hoc" is deprecated. Use "release-testing" instead.
error: exportArchive: No Team Found in Archive

Error Domain=IDEDistributionAnalyzeArchiveStepErrorDomain Code=0 "No Team Found in Archive" UserInfo={NSLocalizedDescription=No Team Found in Archive, NSLocalizedRecoverySuggestion=Use the Signing & Capabilities editor to assign a team to the targets and build a new archive.}

** EXPORT FAILED **
[11:22:11]: Exit status: 70

Additional error:

[11:22:11]: Called from Fastfile at line 475
[11:22:11]: ```
[11:22:11]:     473:        case options[:lane_name]
[11:22:11]:     474:          when 'enterprise_dev_ist'
[11:22:11]:  => 475:                gym(build_only_options.merge(build_only_package_options))
[11:22:11]:     476:          when 'enterprise_dist_ist'
[11:22:11]:     477:                ist_build_options = build_only_options.merge(archive_package_options)
[11:22:11]: ```
[11:22:11]: Error packaging up the application

I can't paste more code here as it's confidential, but will try to provide as much information as I can.

What am I missing to get this to work?

Here's some code in the Fastfile:

  lane :enterprise_dev_ist do |options|
    build_and_archive_with_automatic_signing(options.merge(lane_name: 'enterprise_dev_ist'))
  end

Here is the build_and_archive_with_automatic_signing function:

private_lane :build_and_archive_with_automatic_signing do |options|
  
    # Read configuration file
    config = YAML.load(open(File.join(File.dirname(__FILE__), "fastlane_config.yaml")))
    settings = OpenStruct.new(config)
    lane_settings = settings[options[:lane_name]]
    releaseVersion = get_info_plist_value(path: "#{lane_settings['info_plist_path']}", key: "CFBundleShortVersionString")
    buildNumber = get_info_plist_value(path: "#{lane_settings['info_plist_path']}", key: "CFBundleVersion")
    
    increment_build_number(
      build_number: ENV["BUILD_NUMBER"],
      xcodeproj: "#{settings['xcodeproj_path']}"
    )

    buildNumber = get_info_plist_value(path: "#{settings['base_info_plist_path']}", key: "CFBundleVersion")
    
    build_only_options = {
      scheme: "#{lane_settings['scheme']}",
      configuration: "#{lane_settings['configuration']}",
      workspace: "#{settings['workspace_path']}",
      derived_data_path: "#{settings['derived_data_path']}",
      buildlog_path: "#{settings['log_path']}/gym"
    }
    
    # Main Info.plist
    puts("Updating WILDFIRE_GROUP_NAME in the main Info.plist to #{lane_settings['safari_app_group']}")
    set_info_plist_value(
      path: "#{lane_settings['info_plist_path']}",
      key: "WILDFIRE_GROUP_NAME",
      value: "#{lane_settings['safari_app_group']}"
    )

    # Info.plist in the Extension
    # please note all the plist keys should be placed as strings 
    #  plist["Ext_Env"] = "#{lane_settings['Ext_Env']}"
    # NOT  plist[:Ext_Env] = "#{lane_settings['Ext_Env']}"
    update_plist(
      plist_path: "#{settings['safari_info_plist_path']}",
      block: proc do |plist|
        puts("Updating Ext_Env in the main Info.plist to #{lane_settings['Ext_Env']}")
        plist["Ext_Env"] = "#{lane_settings['Ext_Env']}"
        puts("Updating extension_ga_id in the main Info.plist to #{lane_settings['extension_ga_id']}")
        plist["extension_ga_id"] = "#{lane_settings['extension_ga_id']}"
        puts("Updating WILDFIRE_GROUP_NAME in the main Info.plist to #{lane_settings['safari_app_group']}")
        plist["WILDFIRE_GROUP_NAME"] = "#{lane_settings['safari_app_group']}"
        puts("Updating safari_app_group in the main Info.plist to #{lane_settings['safari_app_group']}")
        plist["safari_app_group"] = "#{lane_settings['safari_app_group']}"
        puts("Updating extension_ga_secret in the main Info.plist to #{lane_settings['extension_ga_secret']}")
        plist["extension_ga_secret"] = "#{lane_settings['extension_ga_secret']}"
        puts("Updating team_id in the main Info.plist to #{lane_settings['team_id']}")
        plist["team_id"] = "#{lane_settings['team_id']}"
      
        puts("Successfully updated Extension plist file --------------------------")
      
        puts("team_id: #{plist['team_id']}")
        puts("extension_ga_secret: #{plist['extension_ga_secret']}")
        puts("safari_app_group: #{plist['safari_app_group']}")
        puts("WILDFIRE_GROUP_NAME: #{plist['safari_app_group']}")
        puts("extension_ga_id: #{plist['extension_ga_id']}")
        puts("Ext_Env: #{plist['Ext_Env']}")
    end
    )

    update_plist(
      plist_path: "#{settings['base_settings_folder']}/Root-PROD.plist",
      block: proc do |plist|
        puts("Looking in the PROD plist")
        version_entry = plist["PreferenceSpecifiers"].find{|item| item["Key"] == "APP_VERSION_AND_BUILD"}
        if version_entry == nil then
          puts("Could not find the entry in the plist")
        else
          puts("Found the entry: #{version_entry}")
          version_entry["DefaultValue"] = "#{releaseVersion} (#{buildNumber})"
        end
    end
    )
    update_plist(
      plist_path: "#{settings['base_settings_folder']}/Root-DEV.plist",
      block: proc do |plist|
        puts("Looking in the DEV plist")
        version_entry = plist["PreferenceSpecifiers"].find{|item| item["Key"] == "APP_VERSION_AND_BUILD"}
        if version_entry == nil then
          puts("Could not find the entry in the plist")
        else
          puts("Found the entry: #{version_entry}")
          version_entry["DefaultValue"] = "#{releaseVersion} (#{buildNumber})"
        end
    end
    )

    mob_value = options[:environment] ? options[:environment] : "IST0"
    skip_build_archive = lane_settings['skip_build_archive'] ? lane_settings['skip_build_archive'] : false
    puts("Parameter 'skip_build_archive' is set to: [ #{skip_build_archive} ] from lane_settings")
    archive_package_options = {
      clean: true,
      output_name: "#{settings['base_output_name']}",
      output_directory: "#{settings['build_output_path']}",
      archive_path: "#{settings['archive_path']}",
      codesigning_identity: "#{lane_settings['codesigning_identity']}",
      xcargs: "CODE_SIGN_STYLE=Manual MOB_ENV=#{mob_value} SKIP_BUILD_ARCHIVE=#{skip_build_archive} -skipPackagePluginValidation -skipMacroValidation",
      export_options: {
        team_id: "#{lane_settings['team_id']}",
        method: "#{lane_settings['export_method']}",
        compileBitcode: lane_settings['compile_bitcode'],
        stripSwiftSymbols: lane_settings['strip_swift_symbols'],
        iCloudContainerEnvironment: "#{lane_settings['iCloudContainerEnvironment']}"
      }
    }
    
    build_only_package_options = {
      clean: true,
      output_name: "#{settings['base_output_name']}",
      output_directory: "#{settings['build_output_path']}",
      archive_path: "#{settings['archive_path']}",
      codesigning_identity: "#{lane_settings['codesigning_identity']}",
      xcargs: "CODE_SIGN_STYLE=Automatic MOB_ENV=#{mob_value} SKIP_BUILD_ARCHIVE=#{skip_build_archive} -skipPackagePluginValidation -skipMacroValidation",
      export_options: {
        skip_archive: true,
        team_id: "#{lane_settings['team_id']}",
        method: "#{lane_settings['export_method']}",
        compileBitcode: lane_settings['compile_bitcode'],
        stripSwiftSymbols: lane_settings['strip_swift_symbols'],
        iCloudContainerEnvironment: "#{lane_settings['iCloudContainerEnvironment']}"
      }
    }
    
    update_code_signing_settings(
      use_automatic_signing: true, ## Development builds require Automatic Signing
      path: "#{settings['xcodeproj_path']}",
      team_id: "#{lane_settings['team_id']}"
    )
    case options[:lane_name]
      when 'enterprise_dev_ist'
            gym(build_only_options.merge(build_only_package_options))
      when 'enterprise_dist_ist'
            ist_build_options = build_only_options.merge(archive_package_options)
            puts("Ready to run gym for IST/Enterprise with build_options: #{ist_build_options}")
            gym(ist_build_options)
      when 'corporate_dev', 'corporate_dist', 'appstore_and_piv_release', 'enterprise_dist_prod'
            prod_build_options = build_only_options.merge(archive_package_options)
            puts("Ready to run gym for PROD/Corporate with build_options: #{prod_build_options}")
            gym(prod_build_options)
      else
          puts("Please enter a valid lane name. Current Lane Not Found: ${options[:lane_name]}")
    end
  end

Thank you!

Upvotes: 0

Views: 118

Answers (0)

Related Questions