[📝] ignore 수정

This commit is contained in:
김선규 2024-10-21 14:48:02 +09:00
parent 33435ed672
commit a7d36694bb
13 changed files with 614 additions and 35 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
WebAppUIKitBase/SecretCode.swift

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,33 @@
//
// AppDelegate.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
//
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}

View File

@ -0,0 +1,8 @@
//
// CommonUtils.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
//
import Foundation

View File

@ -0,0 +1,440 @@
//
// SwiftUI_Prefix.swift
// PersonalHealthDiary
//
// Created by Sean Kim on 2/20/24.
//
import SwiftUI
// MARK: - TYPEALIAS
typealias VOID_TO_VOID = () -> ()
// MARK: - VARIABLE
public var APPSTORE_URL = "https://itunes.apple.com/app/"
public var KEYBOARD_UP_HEIGHT: CGFloat = 46.0
enum Compare: Int{
case bigger = 0
case smaller
case equal
case error
}
// MARK: - FUNCTION
/// print
public func printLog<T>(_ object: T, _ file: String = #file, _ function: String = #function, _ line: Int = #line){
#if DEBUG
let dateString = Date().convertString("yyyy/MM/dd HH:mm:ss:SSS")
Swift.print(
// """
// __________ __________
// |* TIME = [\(dateString)] || FILE = [\(file.lastPathComponent)]
// | NAME = [\(function)] || LINE = [\(line)]
// |>>> PRINT = \(object)
//
// """
"""
__________ __________ __________ __________
* LOCATION : [\(file.lastPathComponent) : \(line)] - \(function)
| TIME : [\(dateString)]
> NOTE : \(object)
"""
)
#else
#endif
}
public func getDeviceWidth() -> CGFloat { UIScreen.main.bounds.size.width }
public func getDeviceHeight() -> CGFloat { UIScreen.main.bounds.size.height }
///
public func isIllegalDevice() -> Bool {
func canOpen(path: String) -> Bool {
let file = fopen(path, "r")
guard file != nil else { return false }
fclose(file)
return true
}
guard let cydiaUrlScheme = NSURL(string: "cydia://package/com.example.package") else { return false }
if UIApplication.shared.canOpenURL(cydiaUrlScheme as URL) {
return true
}
#if arch(i386) || arch(x86_64)
return false
#endif
let fileManager = FileManager.default
if fileManager.fileExists(atPath: "/Applications/Cydia.app") ||
fileManager.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
fileManager.fileExists(atPath: "/bin/bash") ||
fileManager.fileExists(atPath: "/usr/sbin/sshd") ||
fileManager.fileExists(atPath: "/etc/apt") ||
fileManager.fileExists(atPath: "/usr/bin/ssh") ||
fileManager.fileExists(atPath: "/private/var/lib/apt") {
return true
}
if canOpen(path: "/Applications/Cydia.app") ||
canOpen(path: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
canOpen(path: "/bin/bash") ||
canOpen(path: "/usr/sbin/sshd") ||
canOpen(path: "/etc/apt") ||
canOpen(path: "/usr/bin/ssh") {
return true
}
let path = "/private/" + NSUUID().uuidString
do {
try "anyString".write(toFile: path, atomically: true, encoding: String.Encoding.utf8)
try fileManager.removeItem(atPath: path)
return true
} catch let error { //
printLog("Jail ERROR: \(error))")
return false
}
}
public func fontNameCheck() {
for family: String in UIFont.familyNames {
print(family)
for names : String in UIFont.fontNames(forFamilyName: family){
printLog("\(names)")
}
}
}
/// a b true ( false)
public func isBigger (_ a: Int, _ b: Int) -> Bool {
if a > b { return true } else { return false }
}
/// JSON String Dictionary
public func jsonToDict(_ input: String) -> [String: Any] {
if let jsonData = input.data(using: .utf8){
do {
if let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any] {
return jsonObject
}
} catch let error { //
printLog("JSON ERROR: \(error))")
}
}
return [:]
}
func versionChange(ver: String) -> [Int] {
return ver.components(separatedBy: ["."]).map {Int($0) ?? 0}
}
/// a b OOO .
func compareVersion(_ a: String, _ b: String) -> Compare {
let aList = versionChange(ver: a)
let bList = versionChange(ver: b)
if aList.count != bList.count { return .error }
else {
for i in 0 ..< aList.count {
if aList[i] > bList[i] { return .bigger }
else if aList[i] < bList[i] { return .smaller }
}
return .equal
}
}
func copyToClipboard(_ text: String){
UIPasteboard.general.string = text
}
// MARK: - CUSTOM COMPONENTS
// MARK: - EXTENSION
extension String {
///
var lastPathComponent: String {
get {
return (self as NSString).lastPathComponent
}
}
///
func cut(start: Int, end: Int) -> String {
let startIndex = self.index(self.startIndex,offsetBy: start >= 0 ? start : 0)
let endIndex = self.index(self.startIndex,offsetBy: end >= 0 ? end : 0)
let result: String = "\(self[startIndex ..< endIndex])"
return result
}
///
func letter() -> [String] {
return self.map { String($0) }
}
/// ()
func word() -> [String] {
return self.components(separatedBy: " ")
}
/// Date() -> (Bool, Date)
func convertDate(_ dateFormat: String = "yyyyMMdd") -> (Bool, Date) {
let dateFormatter = Date().setDateFormatter(dateFormat)
if let convert = dateFormatter.date(from: self) {
return (true, convert)
} else {
return (false, Date())
}
}
///
///
/// : "[A-Z0-9a-z._%+-]+@[A-Z0-9a-z._%+-]+\\.[A-Za-z]{2,64}"
/// : "[A-Z0-9a-z._%+-]{6,12}"
func checkFilter(_ filter: String) -> Bool {
if self == "" { return false }
return self.range(of: filter, options: .regularExpression) != nil
}
/// Bool DateFormat
static func makeDateFormat(year: Bool, month: Bool, day: Bool, dayOfWeek: Bool = false, am_pm: Bool = false, hour: Bool = false,_ fullTime: Bool = true, minute: Bool = false, second: Bool = false, mSecond: Bool = false, mSDigit: Int = 1) -> String {
var dateFormat = ""
if year {
dateFormat = dateFormat + "yyyy"
}
if month {
dateFormat = dateFormat + "MM"
}
if day {
dateFormat = dateFormat + "dd"
}
if dayOfWeek {
dateFormat = dateFormat + "EEEEEE"
}
if am_pm {
dateFormat = dateFormat + "a"
}
if fullTime { // 24
if hour {
dateFormat = dateFormat + "HH"
}
} else { // 12
if hour {
dateFormat = dateFormat + "hh"
}
}
if minute {
dateFormat = dateFormat + "mm"
}
if second {
dateFormat = dateFormat + "ss"
}
if mSecond {
for _ in 0 ..< mSDigit {
dateFormat = dateFormat + "S"
}
}
return dateFormat
}
/// String
static func combineDate(year: Int, month: Int, day: Int) -> String {
return "\(year * 10000 + month * 100 + day)"
}
func stringToInt() -> Int {
if let intValue = Int(self) {
return intValue
} else {
return 0
}
}
}
extension Date {
///
///
///
var year: Int {
let dateFormatter = self.setDateFormatter("yyyy")
if let year = Int(dateFormatter.string(from: self)){
return year
} else {
return Calendar.current.component(.year, from: self)
}
}
///
///
///
var month: Int {
let dateFormatter = self.setDateFormatter("MM")
if let month = Int(dateFormatter.string(from: self)) {
return month
} else {
return Calendar.current.component(.month, from: self)
}
}
///
///
///
var day: Int {
let dateFormatter = self.setDateFormatter("dd")
if let day = Int(dateFormatter.string(from: self)) {
return day
} else {
return Calendar.current.component(.day, from: self)
}
}
///
///
/// 0~6
///
/// -1
var dayOfWeek: Int {
let dateFormatter = self.setDateFormatter("EEEEEE")
let convert = dateFormatter.string(from: self)
switch convert {
case "":
return 0
case "":
return 1
case "":
return 2
case "":
return 3
case "":
return 4
case "":
return 5
case "":
return 6
default:
return -1
}
}
func setDateFormatter(_ dateFormat: String) -> DateFormatter {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = dateFormat
dateFormatter.timeZone = TimeZone(abbreviation: "KST")
dateFormatter.locale = Locale(identifier: "ko_kr")
return dateFormatter
}
/// String
func convertString(_ dateFormat: String = "yyyyMMdd") -> String {
let dateFormatter = self.setDateFormatter(dateFormat)
return dateFormatter.string(from: self)
}
///
///
///
func checkLeapMonth() -> Bool {
if self.year % 4 == 0 {
if self.year % 100 == 0 {
if self.year % 400 == 0 {
return true
}
} else {
return true
}
}
return false
}
///
///
///
func getLastDayOfMonth() -> Int {
switch self.month {
case 1,3,5,7,8,10,12 :
return 31
case 2:
if self.checkLeapMonth() {
return 29
} else {
return 28
}
case 4,6,9,11:
return 30
default:
return -1
}
}
}
extension Font {
enum NPS_Font : String {
case regular
case bold
var value: String {
switch self {
case .regular:
return "NPS-font-Regular"
case .bold:
return "NPS-font-Bold"
}
}
}
static func nps(font: NPS_Font = .regular, size: CGFloat = 12) -> Font {
return .custom(font.value, size: size)
}
}
extension View {
func endTextEditing() {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}
// MARK: - ANNOTATION
///
/// @UserDefault (key: "keyName", defaultValue: "default") var
/// print()
/// - UserDefaults key
/// =
/// - UserDefaults key
@propertyWrapper
struct UserDefault<T> {
private let ud: UserDefaults = .standard
private let key: String
private var defaultValue: T
var wrappedValue: T {
set { ud.set(newValue, forKey: key) }
get { ud.object(forKey: key) as? T ?? defaultValue }
}
init(key: String, defaultValue: T) {
self.key = key
self.defaultValue = defaultValue
}
///: _.removeData()
/// - _
func removeData() {
ud.removeObject(forKey: key)
}
}

View File

@ -0,0 +1,8 @@
//
// LoactionProtocol.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
//
import Foundation

View File

@ -13,10 +13,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: UIScreen.main.bounds)
window?.windowScene = windowScene
//
window?.rootViewController = IntroVC()
window?.makeKeyAndVisible()
}
func sceneDidDisconnect(_ scene: UIScene) {

View File

@ -0,0 +1,8 @@
//
// IntroVC.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
//
import Foundation

View File

@ -0,0 +1,33 @@
//
// AppDelegate.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
//
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}

View File

@ -1,5 +1,5 @@
//
// ViewController.swift
// IntroVC.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
@ -7,13 +7,11 @@
import UIKit
class ViewController: UIViewController {
class IntroVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}

View File

@ -0,0 +1,8 @@
//
// MainWebVC.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
//
import Foundation

View File

@ -0,0 +1,55 @@
//
// SceneDelegate.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
//
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: UIScreen.main.bounds)
window?.windowScene = windowScene
//
window?.rootViewController = IntroVC()
window?.makeKeyAndVisible()
}
func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
}

View File

@ -0,0 +1,8 @@
//
// SecretCode.swift
// WebAppUIKitBase
//
// Created by Sean Kim on 10/21/24.
//
import Foundation