-
Notifications
You must be signed in to change notification settings - Fork 18
Allow plists to inherit from others by using the :inherit_from key #44
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
| PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | ||
| SWIFT_VERSION = 4.2; | ||
|
|
@@ -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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| SWIFT_VERSION = 4.2; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -45,16 +45,8 @@ final class OptionsParser { | |||||
|
|
||||||
| lazy var plistDictionary: [String: AnyObject] = { [unowned self] in | ||||||
| let inputPlistFilePathURL = URL(fileURLWithPath: self.inputPlistFilePath) | ||||||
| guard let data = try? Data(contentsOf: inputPlistFilePathURL) else { | ||||||
| fatalError("No data at path: \(self.inputPlistFilePath)") | ||||||
| } | ||||||
|
|
||||||
| guard let plistDictionary = (try? PropertyListSerialization.propertyList(from: data, options: [], format: nil)) as? [String: AnyObject] else { | ||||||
| fatalError("Failed to create plist") | ||||||
| } | ||||||
|
|
||||||
| return plistDictionary | ||||||
| }() | ||||||
| return loadPlist(url: inputPlistFilePathURL) | ||||||
| }() | ||||||
|
|
||||||
| lazy var sortedHints: [Hint] = { [unowned self] in | ||||||
| guard let hintsString = try? String(contentsOfFile: self.inputHintsFilePath, encoding: String.Encoding.utf8) else { | ||||||
|
|
@@ -71,5 +63,24 @@ final class OptionsParser { | |||||
| hints.append(Hint(variableName: separatedHints[0], type: separatedHints[1])) | ||||||
| } | ||||||
| return hints.sorted(by: <) | ||||||
| }() | ||||||
| }() | ||||||
|
|
||||||
| private func loadPlist(url: URL) -> [String: AnyObject] { | ||||||
| guard let data = try? Data(contentsOf: url) else { | ||||||
| fatalError("No data at path: \(url.absoluteString)") | ||||||
| } | ||||||
|
|
||||||
| 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" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
| 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") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||
| } | ||||||
| let inheritedPlist = loadPlist(url: URL(fileURLWithPath: inheritPath, relativeTo: url)) | ||||||
| plistDictionary = inheritedPlist.merging(plistDictionary, uniquingKeysWith: { (_, override) in override }) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please call this |
||||||
| } | ||||||
| return plistDictionary | ||||||
| } | ||||||
| } | ||||||
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.