mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Add ability to define templateAttributes within a target
This allows parameterizing templates. Also change
placeholder syntax to `${placeholderName}` also for
existing placeholders `$target_name`and `$platform`
and generate warnings when using the old placeholder
syntax.
This commit is contained in:
@@ -26,6 +26,10 @@ public class SpecLoader {
|
||||
return project
|
||||
}
|
||||
|
||||
public func validateProjectDictionaryWarnings() throws {
|
||||
try projectDictionary?.validateWarnings()
|
||||
}
|
||||
|
||||
public func generateCacheFile() throws -> CacheFile? {
|
||||
guard let projectDictionary = projectDictionary,
|
||||
let project = project else {
|
||||
@@ -38,3 +42,36 @@ public class SpecLoader {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private extension Dictionary where Key == String, Value: Any {
|
||||
|
||||
func validateWarnings() throws {
|
||||
var errors: [SpecValidationError.ValidationError] = []
|
||||
if hasValueContaining("$target_name") {
|
||||
errors.append(.deprecatedUsageOfPlaceholder(placeholderName: "target_name"))
|
||||
}
|
||||
if hasValueContaining("$platform") {
|
||||
errors.append(.deprecatedUsageOfPlaceholder(placeholderName: "platform"))
|
||||
}
|
||||
if !errors.isEmpty {
|
||||
throw SpecValidationError(errors: errors)
|
||||
}
|
||||
}
|
||||
|
||||
func hasValueContaining(_ needle: String) -> Bool {
|
||||
return values.contains { value in
|
||||
switch value {
|
||||
case let dictionary as JSONDictionary:
|
||||
return dictionary.hasValueContaining(needle)
|
||||
case let string as String:
|
||||
return string.contains(needle)
|
||||
case let array as [JSONDictionary]:
|
||||
return array.contains { $0.hasValueContaining(needle) }
|
||||
case let array as [String]:
|
||||
return array.contains { $0.contains(needle) }
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user