//
//  SiiLibSampleApp.swift
//  SiiLibSample
//

import SwiftUI

@main
struct SiiLibSampleApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

class AppDelegate: UIResponder, UIApplicationDelegate{
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool{
        createSampleFile()
        return true
    }
}

func createSampleFile() {
    let filePath = NSHomeDirectory() + "/Documents/Sample.txt"
    let result = FileManager().createFile(atPath: filePath, contents: nil, attributes: nil)
    if result {
        let text = "SampleText\n"
        do {
            try text.write(toFile: filePath, atomically: true, encoding: .utf8)
        } catch {}
    }
}
