yonaskolb / XcodeGen

A Swift command line tool for generating your Xcode project
MIT License
7.07k stars 819 forks source link

ResourcesTag do not work #1183

Open pengzishang opened 2 years ago

pengzishang commented 2 years ago

There is a font file named "Songti.otf" under the path "GuruClub/Resources/Songti.otf" I need to add a ResourcesTag to it I tried like those :

    sources:
      - path: GuruClub/Resources/
        excludes:
            - "Songti.otf"
      - path: GuruClub/Resources/Songti.otf
        resourceTags: ["example", "movie"]

or

    sources:
      - path: GuruClub/Resources/Songti.otf
        buildPhase: resources
        resourceTags:
          - example
          - movie

or

    sources:
      - path: GuruClub/Resources/Songti.otf
        resourceTags: [movie]

none of them working, it there any mistake or typo in my code?

Summys commented 2 years ago

I suppose GuruClub is the name of your project and not a directory inside. What worked for me is


     sources:
      - path: Resources/file.type
        buildPhase: resources
        resourceTags:
          - example
          - movie
pengzishang commented 2 years ago

sadly, I tried a code like yours

  GuruClub:
    type: application
    platform: iOS
    sources:
      - GuruClub
      - GuruClubFoundationBundle/Localizable
      - path: Resources/Songti.otf
        buildPhase: resources
        resourceTags:
          - example
          - movie

it shows me a prompt Spec validation error: Target "GuruClub" has a missing source directory "/Users/deshglh/Projects/guruclub/Resources/Songti.otf"

after I checked the path, Songti.otf 's path is guruclub/GuruClub/Resources/Songti.otf, so I Tried

targets:
  GuruClub:
    type: application
    platform: iOS
    sources:
      - GuruClub
      - GuruClubFoundationBundle/Localizable
      - path: GuruClub/Resources/Songti.otf
        buildPhase: resources
        resourceTags:
          - example
          - movie

however, it also did not work.

I suppose GuruClub is the name of your project and not a directory inside. What worked for me is

     sources:
      - path: Resources/file.type
        buildPhase: resources
        resourceTags:
          - example
          - movie
yonaskolb commented 2 years ago

Try setting the resourceTags in the first source. Source paths are processed in order and then reused. Does that work?

      - path: GuruClub/Resources/Songti.otf
        buildPhase: resources
        resourceTags:
          - example
          - movie
      - GuruClub
alphatroya commented 1 year ago

Try setting the resourceTags in the first source. Source paths are processed in order and then reused. Does that work?

      - path: GuruClub/Resources/Songti.otf
        buildPhase: resources
        resourceTags:
          - example
          - movie
      - GuruClub

Looks like I had a similar problem and this advice helped me.