PadXcode-Daemon/Daemon/Setup.swift

33 lines
1.7 KiB
Swift
Raw Normal View History

2026-04-12 00:42:51 -07:00
import Foundation
func ensureConfigFile() {
let dir = URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent(".padxcode")
let file = dir.appendingPathComponent("config.json")
guard !FileManager.default.fileExists(atPath: file.path) else { return }
try? FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
let defaults: [String: String] = [
"developmentTeam": "YOUR_10_CHAR_TEAM_ID",
"codeSignIdentity": "Apple Development",
"allowProvisioningUpdates": "true"
]
if let data = try? JSONEncoder().encode(defaults) { try? data.write(to: file) }
print("""
PadXcode Daemon First Run Setup
Config created: ~/.padxcode/config.json
Edit it and set your developmentTeam to your
10-character Apple Developer Team ID.
Find it at: developer.apple.com/account
""")
}
func loadTeamID() -> String {
let file = "\(NSHomeDirectory())/.padxcode/config.json"
guard let data = try? Data(contentsOf: URL(fileURLWithPath: file)),
let json = try? JSONDecoder().decode([String: String].self, from: data),
let id = json["developmentTeam"] else { return "" }
return id
}