Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import SwiftUI
import UIKit
// Debug.xcconfig
// OTHER_SWIFT_FLAGS = $(inherited) "-D" "DEBUG"
// DebugStage.xcconfig
// OTHER_SWIFT_FLAGS = $(inherited) "-D" "DEBUG" "-D" "STAGE"
// Release.xcconfig
// OTHER_SWIFT_FLAGS = $(inherited)
// ReleaseStage.xcconfig
// OTHER_SWIFT_FLAGS = $(inherited) "-D" "STAGE"
@main
struct TestModeApp: App {
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String
var body: some Scene {
WindowGroup {
ContentView(version: version, build: build)
.onAppear(perform: {
#if STAGE
let taregetIconName: String? = "stage"
#else
let taregetIconName: String? = nil
#endif
if UIApplication.shared.alternateIconName != taregetIconName {
UIApplication.shared.setAlternateIconName(taregetIconName) { error in
print("/!\\ setAlternateIconName error! \(String(describing: error))")
}
}
})
}
}
}
struct ContentView: View {
let version: String
let build: String
var body: some View {
Text("version \(version)(\(build))")
.padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment