-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow plists to inherit from others by using the :inherit_from key #44
base: main
Are you sure you want to change the base?
Conversation
@@ -284,6 +284,7 @@ | |||
buildSettings = { | |||
CLANG_ENABLE_MODULES = YES; | |||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; | |||
MACOSX_DEPLOYMENT_TARGET = 10.11; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to increase the deployment target from 10.10 (Yosemite, 2014) to 10.11 (El Capitan) as URL(fileURLWithPath: String, relativeTo: URL)
is only available from 10.11.
guard var plistDictionary = (try? PropertyListSerialization.propertyList(from: data, options: [], format: nil)) as? [String: AnyObject] else { | ||
fatalError("Failed to load plist from: \(url.absoluteString)") | ||
} | ||
let inheritKey = ":inherit_from" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this deserves a special key name style - perhaps it could be simply called basePlistFile
.
fatalError("Expected \"\(inheritKey)\" in \(url.absoluteString) to be a string path") | ||
} | ||
let inheritedPlist = loadPlist(url: URL(fileURLWithPath: inheritPath, relativeTo: url)) | ||
plistDictionary = inheritedPlist.merging(plistDictionary, uniquingKeysWith: { (_, override) in override }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plistDictionary = inheritedPlist.merging(plistDictionary, uniquingKeysWith: { (_, override) in override }) | |
plistDictionary = inheritedPlist.merging(plistDictionary, uniquingKeysWith: { (_, newValue) in newValue }) |
Please call this newValue
for clarity.
@@ -295,6 +296,7 @@ | |||
buildSettings = { | |||
CLANG_ENABLE_MODULES = YES; | |||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; | |||
MACOSX_DEPLOYMENT_TARGET = 10.11; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're bumping the minimum macOS version, then I think it needs to be mentioned in the CHANGELOG as well.
let inheritKey = ":inherit_from" | ||
if let inheritPath = plistDictionary.removeValue(forKey: inheritKey) { | ||
guard let inheritPath = inheritPath as? String, !inheritPath.isEmpty else { | ||
fatalError("Expected \"\(inheritKey)\" in \(url.absoluteString) to be a string path") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failure message should also mention that the path must be non-empty (since you're checking for it above):
fatalError("Expected \"\(inheritKey)\" in \(url.absoluteString) to be a string path") | |
fatalError("Expected \"\(inheritKey)\" in \(url.absoluteString) to be a non-empty String path") |
An implementation to allow inheriting from other plists as mentioned in issue #43