mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
rename Plist.attributes to properties
This commit is contained in:
@@ -4,16 +4,16 @@ import JSONUtilities
|
||||
public struct Plist: Equatable {
|
||||
|
||||
public let path: String
|
||||
public let attributes: [String: Any]
|
||||
public let properties: [String: Any]
|
||||
|
||||
public init(path: String, attributes: [String: Any] = [:]) {
|
||||
self.path = path
|
||||
self.attributes = attributes
|
||||
self.properties = attributes
|
||||
}
|
||||
|
||||
public static func == (lhs: Plist, rhs: Plist) -> Bool {
|
||||
return lhs.path == rhs.path &&
|
||||
NSDictionary(dictionary: lhs.attributes).isEqual(to: rhs.attributes)
|
||||
NSDictionary(dictionary: lhs.properties).isEqual(to: rhs.properties)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ extension Plist: JSONObjectConvertible {
|
||||
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
path = try jsonDictionary.json(atKeyPath: "path")
|
||||
attributes = jsonDictionary.json(atKeyPath: "attributes") ?? [:]
|
||||
properties = jsonDictionary.json(atKeyPath: "properties") ?? [:]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class InfoPlistGenerator {
|
||||
return dictionary
|
||||
}()
|
||||
|
||||
public func generateAttributes(target: Target) -> [String: Any] {
|
||||
public func generateProperties(target: Target) -> [String: Any] {
|
||||
var targetInfoPlist = defaultInfoPlist
|
||||
switch target.type {
|
||||
case .uiTestBundle,
|
||||
|
||||
@@ -30,22 +30,22 @@ public class ProjectWriter {
|
||||
for target in project.targets {
|
||||
// write Info.plist
|
||||
if let plist = target.info {
|
||||
let path = project.basePath + plist.path
|
||||
let attributes = infoPlistGenerator.generateAttributes(target: target).merged(plist.attributes)
|
||||
let data = try PropertyListSerialization.data(fromPropertyList: attributes, format: .xml, options: 0)
|
||||
try? path.delete()
|
||||
try path.parent().mkpath()
|
||||
try path.write(data)
|
||||
let properties = infoPlistGenerator.generateProperties(target: target).merged(plist.properties)
|
||||
try writePlist(properties, path: plist.path)
|
||||
}
|
||||
|
||||
// write entitlements
|
||||
if let plist = target.entitlements {
|
||||
let path = project.basePath + plist.path
|
||||
let data = try PropertyListSerialization.data(fromPropertyList: plist.attributes, format: .xml, options: 0)
|
||||
try? path.delete()
|
||||
try path.parent().mkpath()
|
||||
try path.write(data)
|
||||
try writePlist(plist.properties, path: plist.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func writePlist(_ plist: [String: Any], path: String) throws {
|
||||
let path = project.basePath + path
|
||||
let data = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
|
||||
try? path.delete()
|
||||
try path.parent().mkpath()
|
||||
try path.write(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ targets:
|
||||
platform: macOS
|
||||
info:
|
||||
path: App_macOS/Info.plist
|
||||
attributes:
|
||||
properties:
|
||||
LSMinimumSystemVersion: $(MACOSX_DEPLOYMENT_TARGET)
|
||||
NSMainStoryboardFile: Main
|
||||
NSPrincipalClass: NSApplication
|
||||
|
||||
@@ -159,7 +159,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
var targetDictionary = validTarget
|
||||
targetDictionary["info"] = [
|
||||
"path": "Info.plist",
|
||||
"attributes": [
|
||||
"properties": [
|
||||
"CFBundleName": "MyAppName",
|
||||
"UIBackgroundModes": ["fetch"]
|
||||
]
|
||||
@@ -176,7 +176,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
var targetDictionary = validTarget
|
||||
targetDictionary["entitlements"] = [
|
||||
"path": "app.entitlements",
|
||||
"attributes": [
|
||||
"properties": [
|
||||
"com.apple.security.application-groups": "com.group",
|
||||
]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user