yonaskolb / XcodeGen

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

Localizable.strings files not correctly grouped when referenced directly #374

Open keith opened 6 years ago

keith commented 6 years ago

With this project spec:

{
  "name": "Test",
  "options": {
    "createIntermediateGroups": true
  },
  "targets": {
    "ResourceBundle": {
      "platform": "iOS",
      "sources": [
        "Resources/Strings/Base.lproj/Localizable.strings"
      ],
      "type": "bundle"
    }
  }
}

And this folder structure:

.
├── Resources
│   └── Strings
│       └── Base.lproj
│           └── Localizable.strings
└── project.json

When I run XcodeGen like this:

~/dev/XcodeGen/.build/debug/xcodegen --spec project.json

I end up with a project where the Localizable.strings file isn't correctly setup as a localized file. In this case it looks like this:

image

If you change the source path to be Resources/Strings instead of Resources/Strings/Base.lproj/Localizable.strings this issue is fixed and it looks like this:

image

But sometimes having the complete path to the file is useful so you don't include resources that shouldn't be a part of your target.

Here's the sample project showing this issue: XcodeGenLocalizable.zip

This was tested with b918a1e76b4b98883de2a8ba99a5dbce435764f8

keith commented 6 years ago

It looks like this is because we hit this branch https://github.com/yonaskolb/XcodeGen/blob/461de39f8e7c837a78f5617bc4fc20d4d84267b7/Sources/XcodeGenKit/SourceGenerator.swift#L470 which doesn't have any of the lproj logic