Skip to content

Instantly share code, notes, and snippets.

@notoroid
Created April 7, 2021 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notoroid/6a512ccfaed650ea1c52b0b85b35a53a to your computer and use it in GitHub Desktop.
Save notoroid/6a512ccfaed650ea1c52b0b85b35a53a to your computer and use it in GitHub Desktop.
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