Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gym] Copy Asset Pack into output directory #16117

Merged
merged 2 commits into from Mar 23, 2020

Conversation

CRoig
Copy link
Contributor

@CRoig CRoig commented Mar 4, 2020

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

This changes make easier to locate the assetpack files generated during the export phase. Before this change, the asset packs were created in the temporary output folder. Gym tool only copied .ipa, .dSym, and Apps folder.
Locating asset pack files is very helpful if you want to upload automatically your remote assets into a particular server.

I opened an issue (#16037) in order to ask the community how was I supposed to access the asset pack files. During my investigation I found out this feature was not implemented, so I implemented myself.

Description

I extended runner.rb functionality to copy OnDemandResources as Apps folder and ipa and dSym files.

I installed the gem from my repo and archived my project using fastlane gym. I could see on the console the path to the asset packs output and verified the files were in the expected location.

Testing Steps

In order to verify the functionality works, project should have "Enable On Demand Resources" set to "Yes" in the iOS Project Build Settings menu. In addition, at least one assets should have a tag assigned. This tag will appear under iOS Project Resource Tags menu.

Gym export options should include the following parameters:

export_options: {
        embedOnDemandResourcesAssetPacksInBundle: false,
        onDemandResourcesAssetPacksBaseURL: "https://assets.dummy.com/tags"
}

@googlebot

This comment has been minimized.

@CRoig

This comment has been minimized.

@googlebot

This comment has been minimized.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Mar 4, 2020
@Fl0p
Copy link

Fl0p commented Mar 4, 2020

+1

@gonchar
Copy link

gonchar commented Mar 4, 2020

yay! thanks for doing this! waiting when it will be merged

@Fl0p
Copy link

Fl0p commented Mar 4, 2020

@CRoig tnx

@fahadhaq
Copy link

fahadhaq commented Mar 4, 2020

@CRoig thanks for this. Saved me a lot of time :)

@joshdholtz
Copy link
Member

@CRoig TIL about asset packs 😊 And thanks for those testing steps! Going to test this on my test project but code looks 💯 . Thanks for doing this!

@CRoig
Copy link
Contributor Author

CRoig commented Mar 5, 2020

@CRoig TIL about asset packs 😊 And thanks for those testing steps! Going to test this on my test project but code looks 💯 . Thanks for doing this!

Today I Learned what TIL stands for 🤣

@janpio janpio changed the title Copy Asset Pack into output directory [gym] Copy Asset Pack into output directory Mar 6, 2020
@fahadhaq
Copy link

fahadhaq commented Mar 9, 2020

First of all thanks for the code it creates the asset packs when I run Fastlane. The problem I am seeing is that when I generate the assetpack using Fastlane I am not able to download it . I am getting a

Error Domain=NSURLErrorDomain Code=-1008 Resource Unavailable For Download Request

I then went to Xcode and archived my project and generated the OnDemandResources folder with the same assetpack. After doing this I can now download my assetpack when I run my app.

Not sure if anyone else is experiencing the same issue.

Few differences that I have noticed is that when I generate a asset pack via Xcode the name appends the end bit of the bundle key string that is in the AssetPackManifest.plist. the screenshot below is from the assetpack that downloads correctly.

Screenshot 2020-03-10 at 8 51 13 AM

Screen shot of the assetpack that does not download correctly

Screenshot 2020-03-10 at 8 53 59 AM

Cant really see any other difference between the two assetpack that I have uploaded to the server. Can some one please help. Thanks in advance.

@CRoig
Copy link
Contributor Author

CRoig commented Mar 10, 2020

Hi @fahadhaq, I faced same problem in the past. Somehow maybe your are copying to the server some packs that does not match with AssetPackManifest.plist.

I know it is obvious, but this is the root cause of your problem.

In my case, I faced 2 problems, I solved by deeply understanding how it worked:

  1. Be sure Asset Pack Manifest URL Prefix parameter in Build Settings properly resolves for you Build Configuration.

Screenshot 2020-03-10 at 12 09 34

  1. Be sure AssetPackManifest.plist embed in ipa matches the AssetPackManifest.plist embed in the ipa. Because of the previous bullet (setting did not resolve properly), the embedded AssetPackManifest pointed to my local machine (e.g. something similart to http://127.0.0.1/Users/...)

  2. Be sure asset pack you are using are an actual file. From Archive several folders named <product-name>-<tag-name>-<hash>.assetpack are generated, but the ones you need to upload are the ones signed which are not inspectable.

I created a gitlab pipeline to upload directly asset packs generated on build output path using this actual PR, and everything seems fine to me.

Also worth to define the following export_options as part of your gym setup:

export_options: {
        embedOnDemandResourcesAssetPacksInBundle: false,
        onDemandResourcesAssetPacksBaseURL: "https://assets.dummy.com/tags"
}

Good luck.

PS: it is a pity there is no so detailed documentation on this topic. I am about to write kind of a Medium tutorial to export and update assetpack (to use ODR) using fastlane.

@fahadhaq
Copy link

Thanks for your help @CRoig. My issue was I was using Legacy build system win Fastlane to create the On Demand resources and when running my app from Xcode I was using the new build system. That is why I couldn't access my Resources and nothing was downloading. Hope this will help someone. Make sure the build systems are same when creating and running the app

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks so much for adding this feature 😊 Really appreciate the contribution ❤️ This will be released today

@joshdholtz joshdholtz merged commit ad2b7a8 into fastlane:master Mar 23, 2020
@fastlane-bot
Copy link

Hey @CRoig 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

Copy link

@fastlane-bot fastlane-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations! 🎉 This was released as part of fastlane 2.144.0 🚀

@fastlane fastlane locked and limited conversation to collaborators May 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants