import AppKit import Ch56Kit import SwiftUI @main struct Ch56Demo { @MainActor static func main() { let now = Date(timeIntervalSince1970: 1_800_000_000) let profile = ProvisioningProfile( name: "App Store", teamID: "TEAM123456", bundleID: "dev.xwrt.tutorial.app", expiration: now.addingTimeInterval(86_400), deviceCount: 0 ) print("[56.1] 描述文件问题 = \(profile.problems(now: now).count)") let expired = ProvisioningProfile( name: "旧", teamID: "TEAM123456", bundleID: "dev.xwrt.tutorial.app", expiration: now.addingTimeInterval(-1), deviceCount: 0 ) print("[56.2] 过期问题 = \(expired.problems(now: now).count)") let options = ExportOptions( method: .appStore, teamID: "TEAM123456", provisioningProfiles: ["dev.xwrt.tutorial.app": "App Store"] ) print("[56.3] 导出选项有效 = \(options.isValid)") print("[56.4] method = \(options.plist["method"] as? String ?? "nil")") print("[56.5] 键数 = \(options.plist.count)") do { let data = try options.plistData() let parsed = try PropertyListSerialization.propertyList(from: data, format: nil) print("[56.6] plist 往返 = \(parsed as? [String: Any] != nil)") } catch { print("[56.6] plist 失败 = \(error)") } let archive = ArchivePlan.archiveArguments( project: "App.xcodeproj", scheme: "App", configuration: "Release", archivePath: "build/App.xcarchive" ) print("[56.7] archive 参数数 = \(archive.count)") print("[56.8] archive 末项 = \(archive.last ?? "nil")") let export = ArchivePlan.exportArguments( archivePath: "build/App.xcarchive", exportPath: "build/export", optionsPlist: "ExportOptions.plist" ) print("[56.9] export 参数数 = \(export.count)") print("[56.10] 签名板渲染 = \(size(SigningBoard()))") print( "[56.11] MemoryLayout = \(MemoryLayout.size) 字节" ) if let directory = ProcessInfo.processInfo.environment["SHOTS_DIR"] { write(SigningBoard(), name: "ios-signing-board.png", directory: directory) } } @MainActor private static func size(_ view: some View) -> String { guard let image = ImageRenderer(content: view).cgImage else { return "nil" } return "\(image.width)x\(image.height)" } @MainActor private static func write(_ view: some View, name: String, directory: String) { let renderer = ImageRenderer(content: view) renderer.scale = 2 guard let image = renderer.cgImage, let data = NSBitmapImageRep(cgImage: image).representation(using: .png, properties: [:]) else { print("[56.12] 截图失败:\(name)") return } let url = URL(fileURLWithPath: directory).appendingPathComponent(name) do { try FileManager.default.createDirectory( at: url.deletingLastPathComponent(), withIntermediateDirectories: true ) try data.write(to: url) print("[56.12] 截图 = \(name) \(image.width)x\(image.height)") } catch { print("[56.12] 截图失败:\(error)") } } }