简体   繁体   中英

How to setup fastlane in iOS for different export methods and provision profiles?

We are using fastlane and jenkins in an iOS app to build it. Wer have already configured fastlane to build the app but the problem is that we couldn't find a solution to use the same configs to build both ad-hoc and app-store apps.

under /fastlane folder we have gymfile and fastfile with these configuration:

Gymfile:

scheme("XXXApp")
workspace("XXXX")
output_directory("./fastlane/Builds")
export_method("ad-hoc")
include_symbols(true)
include_bitcode(false)
xcconfig("......XXXX")
sdk("iphoneos")

Fastfile: for Test app (where we want to build it with ad-hoc)

lane :test do |options|
        get_info_plist_value(path: ENV["INFO_PLIST_PATH"], key: "CFBundleVersion")
        increment_build_number(
            build_number: options[:build_number],
            xcodeproj: "./XXXXX"
        )
        build_test
    end

for production app (where we want to use app-store export method):

lane :candidate_prod do |options|
        get_info_plist_value(path: ENV["INFO_PLIST_PATH"], key: "CFBundleVersion")
        increment_build_number(
            build_number: options[:build_number],
            xcodeproj: "./XXXXXX"
        )

        update_project_provisioning(
        xcodeproj: "./XXXXXX",
        profile: "./fastlane/productionprovisionprofile", 
        target_filter: "productionappname", 
        build_configuration: "Release",
        code_signing_identity: "XXXX" 
        )

        build_prod 

and also we have this private lane in fastfile(this is for prod but we have another one for test app):

private_lane :build_prod do 
        build_ios_app(
            workspace: "XXXXXX",
            #configuration: configuration,  
            scheme: "productionappname",
            silent: false,
            codesigning_identity: "XXXXX",
            include_bitcode: false,
        )
        puts "$IPA_OUTPUT_PATH::\"#{lane_context[SharedValues::IPA_OUTPUT_PATH]}\""
    end 

In jenniks, we have a step where it runs this:

fastlane candidate_prod build_number:${BUILD_NUMBER}

or test instead of candidate_prod in case we want test app

The question is: what changes can we make in order to have lanes with different export methods according to the app that we want to generate (add-hoc or app-store) and how to specify the provision profile for each build(test and prod) so we make sure we build the app with its provision profile?

There are several options - my guess is that in anyway you have more than 1 bundle identifier to the different apps...

  1. You can setup a new target and just create the same lane with a different scheme for that target (or build a function and send the correct scheme as a parameter). You will also have to create a different bundle id.
  2. If you don't wish to create a different target and you are you using Automatic signing on your project, you will have to change it to manual and specify the provisioning profile there. Make sure to have different build numbers / versions or a conflict could occur

something like this

Prod

    build_app(
  workspace: "XXXX.xcworkspace",
  scheme: "XXXXX",
  ......
  export_options: {
    method: "app-store",
    signingStyle: 'manual',
    provisioningProfiles: {
      "bundle id": "Prod profile full name",
    }
  })

Ad-hoc

    build_app(
  workspace: "XXXX.xcworkspace",
  scheme: "XXXXX",
  ......
  export_options: {
    method: "ad-hoc",
    signingStyle: 'manual',
    provisioningProfiles: {
      "bundle id": "Ad-hoc full name",
    }
  })

Not sure if the naming are correct for the methods - See for more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM