Files
farzaa--clicky/leanring-buddy/AppBundleConfiguration.swift
2026-07-13 13:11:38 +08:00

29 lines
934 B
Swift

//
// AppBundleConfiguration.swift
// leanring-buddy
//
// Shared helper for reading runtime configuration from the built app bundle.
//
import Foundation
enum AppBundleConfiguration {
static func stringValue(forKey key: String) -> String? {
if let value = Bundle.main.object(forInfoDictionaryKey: key) as? String {
let trimmedValue = value.trimmingCharacters(in: .whitespacesAndNewlines)
if !trimmedValue.isEmpty {
return trimmedValue
}
}
guard let resourceInfoPath = Bundle.main.path(forResource: "Info", ofType: "plist"),
let resourceInfo = NSDictionary(contentsOfFile: resourceInfoPath),
let value = resourceInfo[key] as? String else {
return nil
}
let trimmedValue = value.trimmingCharacters(in: .whitespacesAndNewlines)
return trimmedValue.isEmpty ? nil : trimmedValue
}
}