Created
April 7, 2021 05:31
-
-
Save notoroid/6a512ccfaed650ea1c52b0b85b35a53a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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