mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Merge pull request #480 from Beniamiiin/generating_empty_directories
Added an abbility to generate empty directories
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
## Master
|
||||
|
||||
#### Added
|
||||
- Added new ability to generate empty directories via `options.generateEmptyDirectories` [#480](https://github.com/yonaskolb/XcodeGen/pull/480) @Beniamiiin
|
||||
|
||||
## 2.1.0
|
||||
|
||||
#### Added
|
||||
|
||||
@@ -93,6 +93,7 @@ Note that target names can also be changed by adding a `name` property to a targ
|
||||
- `bottom` - at the bottom, after other files
|
||||
- `none` - sorted alphabetically with all the other files
|
||||
- [ ] **transitivelyLinkDependencies**: **Bool** - If this is `true` then targets will link to the dependencies of their target dependencies. If a target should embed its dependencies, such as application and test bundles, it will embed these transitive dependencies as well. Some complex setups might want to set this to `false` and explicitly specify dependencies at every level. Targets can override this with [Target](#target).transitivelyLinkDependencies. Defaults to `false`.
|
||||
- [ ] **generateEmptyDirectories**: **Bool** - If this is `true` then empty directories will be added to project too else will be missed. Defaults to `false`.
|
||||
|
||||
```yaml
|
||||
options:
|
||||
|
||||
@@ -19,6 +19,7 @@ public struct SpecOptions: Equatable {
|
||||
public var defaultConfig: String?
|
||||
public var transitivelyLinkDependencies: Bool
|
||||
public var groupSortPosition: GroupSortPosition
|
||||
public var generateEmptyDirectories: Bool
|
||||
|
||||
public enum ValidationType: String {
|
||||
case missingConfigs
|
||||
@@ -71,7 +72,8 @@ public struct SpecOptions: Equatable {
|
||||
disabledValidations: [ValidationType] = [],
|
||||
defaultConfig: String? = nil,
|
||||
transitivelyLinkDependencies: Bool = false,
|
||||
groupSortPosition: GroupSortPosition = .bottom
|
||||
groupSortPosition: GroupSortPosition = .bottom,
|
||||
generateEmptyDirectories: Bool = false
|
||||
) {
|
||||
self.minimumXcodeGenVersion = minimumXcodeGenVersion
|
||||
self.carthageBuildPath = carthageBuildPath
|
||||
@@ -89,6 +91,7 @@ public struct SpecOptions: Equatable {
|
||||
self.defaultConfig = defaultConfig
|
||||
self.transitivelyLinkDependencies = transitivelyLinkDependencies
|
||||
self.groupSortPosition = groupSortPosition
|
||||
self.generateEmptyDirectories = generateEmptyDirectories
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,5 +117,6 @@ extension SpecOptions: JSONObjectConvertible {
|
||||
defaultConfig = jsonDictionary.json(atKeyPath: "defaultConfig")
|
||||
transitivelyLinkDependencies = jsonDictionary.json(atKeyPath: "transitivelyLinkDependencies") ?? false
|
||||
groupSortPosition = jsonDictionary.json(atKeyPath: "groupSortPosition") ?? .bottom
|
||||
generateEmptyDirectories = jsonDictionary.json(atKeyPath: "generateEmptyDirectories") ?? false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,8 +318,12 @@ class SourceGenerator {
|
||||
return try dirPath.children()
|
||||
.filter {
|
||||
if $0.isDirectory {
|
||||
let children = try $0.children().filter(isIncludedPath)
|
||||
return !children.isEmpty
|
||||
if project.options.generateEmptyDirectories {
|
||||
return true
|
||||
} else {
|
||||
let children = try $0.children().filter(isIncludedPath)
|
||||
return !children.isEmpty
|
||||
}
|
||||
} else if $0.isFile {
|
||||
return isIncludedPath($0)
|
||||
} else {
|
||||
@@ -352,18 +356,18 @@ class SourceGenerator {
|
||||
for path in directories {
|
||||
let subGroups = try getGroupSources(targetType: targetType, targetSource: targetSource, path: path, isBaseGroup: false)
|
||||
|
||||
guard !subGroups.sourceFiles.isEmpty else {
|
||||
guard !subGroups.sourceFiles.isEmpty || project.options.generateEmptyDirectories else {
|
||||
continue
|
||||
}
|
||||
|
||||
allSourceFiles += subGroups.sourceFiles
|
||||
|
||||
guard let firstGroup = subGroups.groups.first else {
|
||||
continue
|
||||
if let firstGroup = subGroups.groups.first {
|
||||
groupChildren.append(firstGroup)
|
||||
groups += subGroups.groups
|
||||
} else if project.options.generateEmptyDirectories {
|
||||
groups += subGroups.groups
|
||||
}
|
||||
|
||||
groupChildren.append(firstGroup)
|
||||
groups += subGroups.groups
|
||||
}
|
||||
|
||||
// find the base localised directory
|
||||
|
||||
Reference in New Issue
Block a user