Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make deliver (fastlane) download metadata for multiple targets?

I have an Xcode project with six targets, each target is made to build a separate app. I'm trying to setup fastlane to assist me in publication of these apps.

Fastlane docs suggest using .env files in order to handle multiple targets (you can specify app_identifier, team_name, etc. in different .env files, and then, for instance, call fastlane appstore --env ENV_NAME_HERE). However I can't figure out how to set up deliver properly.

deliver init downloads metadata for one target only by default. I need to download metadata for all my targets to different directories (and then use those directories to upload data, obviously). deliver download_metadata doesn't accept the --env parameter (my Deliverfile depends on env files). I've tried fastlane deliver --env, but it seems to be just a shorthand for deliver, so it doesn't work either.

I guess I could just manually run deliver with different --metadata_path parameters (and all the other parameters since my Deliverfile is invalid, because it depends on env files), and then later specify directories using Deliverfile + .env files. But since I have Deliverfile and .env files already set up (now I use deliver to upload the binary only), I hoped that there is a better way. Is there?

P.S. This is a large legacy project, so splitting it into six different projects would be great, but it's not an option, unfortunately.

like image 249
FreeNickname Avatar asked May 11 '16 10:05

FreeNickname


3 Answers

I've been struggling with this as well and setting up the submit is easy using the .env files.

But retrieving the initial data is difficult, but not impossible.

To grab the metadata it ran this command:

fastlane deliver download_metadata -m "./Targets/Release/Metadata" -u "itunes@username" -a "com.example.ios"

And for the screenshots:

fastlane deliver download_screenshots -w "./Targets/Release/Screenshots" -u "itunes@username" -a "com.example.ios"
like image 130
rckoenes Avatar answered Nov 15 '22 16:11

rckoenes


Adding up to @rckoenes answer:

1) Create an .env.yourEnvName file with this info (as an example):

DLV_METADATA_PATH="../Targets/Your_Target/Metadata"
DLV_ITUNESCONNECT_USERNAME="[email protected]"
DLV_BUNDLE_ID="com.yourCompany.yourTarget"

2) Create a lane like this:

desc "Download metadata"
 lane :metadata do
    sh('fastlane deliver download_metadata -m "$DLV_METADATA_PATH" -u $DLV_ITUNESCONNECT_USERNAME -a $DLV_BUNDLE_ID')
 end

3) Call fastlane like this:

fastlane metadata --env yourEnvName

That way it's a little bit cleaner, and you keep the vars in the .env file. For automating this call for multiple targets, please refer to: https://docs.fastlane.tools/faqs/#multiple-targets-of-the-same-underlying-app

like image 33
Riddick Avatar answered Nov 15 '22 14:11

Riddick


This is a combination of @rckoenes, @Riddick's answer and this fastlane github issue submission.

I was trying @Riddick's answer to have a cleaner workflow but I couldn't make it work to download metadata. For some reason, it only makes the metadata path folder but no metadata downloaded from iTunesConnect. I did some trial and error and found this line of code from the link above this:

ENV["DELIVER_FORCE_OVERWRITE"] = "1"

added it to the lane and worked!

1) Create an .env.yourEnvName file with this info (as an example):

METADATA_PATH="../Targets/Your_Target/Metadata"
APP_IDENTIFIER="com.yourCompany.yourTarget"

2) Create a lane like this:

desc "Download metadata"
 lane :metadata do
    ENV["DELIVER_FORCE_OVERWRITE"] = "1" # This is the additional line from Riddick's code
    sh "fastlane deliver download_metadata --app_identifier #{ENV['APP_IDENTIFIER'] --metadata_path #{ENV['METADATA_PATH']}"
 end

3) Call fastlane like this:

fastlane metadata --env yourEnvName

***I did not use the username parameter because I had it on my Deliver File.

like image 44
r_19 Avatar answered Nov 15 '22 15:11

r_19