e-sites / Natrium

A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
https://www.e-sites.nl
MIT License
146 stars 15 forks source link

xcassets #21

Closed philosopherdog closed 5 years ago

philosopherdog commented 5 years ago

Is it possible to configure the inclusion and exclusion of different xcassets depending on environment or configuration?

basvankuijck commented 5 years ago

What you could do is the following to include / replace assets in your project:

Create (for instance) a PDF asset and place it in a folder:

And make (for instance) environment specific instances in:

Then use the files settings in your .natrium.yml:


files:
  "MyApp/Resources/Assets.xcassets/MyImage.imageset/MyImage.pdf":
    Staging: "Environments/Staging/MyImage.pdf"
    Production: "Environments/Production/MyImage.pdf"

That way Environments/Staging/MyImage.pdf will be copied (and replace) MyApp/Resources/Assets.xcassets/MyImage.imageset/MyImage.pdf in the pre-build step for your Staging environment

Excluding files is not possible at this time

philosopherdog commented 5 years ago

This is a very good suggestion. In my case I have xcassets that contain duplicate file names. So, I have Base.xcassets twice in my project with the same file names for different assets. Is it possible to just add a dummy xcassets folder and copy the correct one over at run time. I'm thinking that might be a way to handle this. Is it possible to copy over the contents of xcassets instead of just a single file?

basvankuijck commented 5 years ago

Yes you can also use a directory in the files parameters. That way a complete directory will be copied (and overwritten)