rename Plist.attributes to properties

This commit is contained in:
Yonas Kolb
2018-10-30 21:47:16 +11:00
parent 26106a04b3
commit eef1dc473e
5 changed files with 19 additions and 19 deletions
+4 -4
View File
@@ -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") ?? [:]
}
}
+1 -1
View File
@@ -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,
+11 -11
View File
@@ -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)
}
}
+1 -1
View File
@@ -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",
]
]