
import Foundation
import Capacitor

@objc(BuildInfoPlugin)
public class BuildInfoPlugin: CAPPlugin {
    @objc func getBuildInfo(_ call: CAPPluginCall) {
        let versionName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0.0"
        let buildNumber = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "1"
        
        let result = [
            "versionName": versionName,
            "buildNumber": Int(buildNumber) ?? 1,
            "platform": "ios",
            // 추가 디버깅 정보
            "bundleId": Bundle.main.bundleIdentifier ?? "unknown",
            "buildDate": DateFormatter.localizedString(from: Date(), dateStyle: .short, timeStyle: .short)
        ] as [String : Any]
        
        call.resolve(result)
    }
}
