Skip to content

Conversation

@Jon889
Copy link

@Jon889 Jon889 commented Feb 13, 2020

An implementation to allow inheriting from other plists as mentioned in issue #43

buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
Copy link
Author

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"
Copy link
Contributor

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 })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
plistDictionary = inheritedPlist.merging(plistDictionary, uniquingKeysWith: { (_, override) in override })
plistDictionary = inheritedPlist.merging(plistDictionary, uniquingKeysWith: { (_, newValue) in newValue })

Please call this newValue for clarity.

buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
Copy link
Contributor

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")
Copy link
Contributor

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):

Suggested change
fatalError("Expected \"\(inheritKey)\" in \(url.absoluteString) to be a string path")
fatalError("Expected \"\(inheritKey)\" in \(url.absoluteString) to be a non-empty String path")

@MarcoGuerrieriTAB MarcoGuerrieriTAB changed the base branch from master to main September 15, 2020 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants