OptionSet: Treat empty strings as nil
- This fixes issues in inheritance when inheriting a nil
value with no other customization leads to an empty string,
which can crash Xcode in the case of run args
PiperOrigin-RevId: 269433225
diff --git a/src/TulsiGenerator/TulsiOption.swift b/src/TulsiGenerator/TulsiOption.swift
index b1257d8..ee04442 100644
--- a/src/TulsiGenerator/TulsiOption.swift
+++ b/src/TulsiGenerator/TulsiOption.swift
@@ -142,8 +142,9 @@
let inheritValue = defaultValue ?? ""
func resolveInheritKeyword(_ value: String?) -> String? {
guard let value = value else { return nil }
- return value.replacingOccurrences(of: TulsiOption.InheritKeyword,
- with: inheritValue)
+ let newValue = value.replacingOccurrences(of: TulsiOption.InheritKeyword,
+ with: inheritValue)
+ return newValue.isEmpty ? nil : newValue
}
if optionType.contains(.SupportsInheritKeyword) {
projectValue = resolveInheritKeyword(projectValue)