Created
June 15, 2023 14:23
-
-
Save ArthurSav/e1fbbe06ce1f986e28d831a16d2905db to your computer and use it in GitHub Desktop.
Detects UI Framework (React Native, Flutter, SwiftUI) used in a simulator build.
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 java.io.BufferedReader | |
import java.io.File | |
import java.io.InputStreamReader | |
import kotlin.concurrent.thread | |
// This script will determine the framework used to build an iOS app. | |
// Compile: kotlinc FrameworkFinder.kt -include-runtime -d FrameworkFinder.jar | |
// Usage: java -jar FrameworkFinder.jar <path-to-app-bundle> | |
// Example: java -jar FrameworkFinder.jar /Users/username/Desktop/MyApp.app | |
fun main(args: Array<String>) { | |
if (args.isEmpty()) { | |
println("Please provide a path to the app bundle as an argument.") | |
return | |
} | |
val appBundle = File(args[0]) // Use the first argument as the path. | |
if (!appBundle.exists() || !appBundle.isDirectory) { | |
println("App bundle does not exist or is not a directory") | |
return | |
} | |
val binaryFile = File(appBundle, appBundle.nameWithoutExtension) | |
if (!binaryFile.exists() || !binaryFile.isFile) { | |
println("Binary file does not exist or is not a file") | |
return | |
} | |
val process = Runtime.getRuntime().exec("nm ${binaryFile.absolutePath}") | |
val reader = BufferedReader(InputStreamReader(process.inputStream)) | |
var output = "" | |
val readThread = thread { | |
output = reader.use { it.readText() } | |
} | |
// Wait for the process to finish. | |
process.waitFor() | |
// Wait for the output to be read. | |
readThread.join() | |
when { | |
output.contains("_OBJC_CLASS_\$_UIHostingView") -> { | |
println("The app is an iOS app built using *SwiftUI*") | |
} | |
output.contains("_OBJC_CLASS_\$_Flutter") -> { | |
println("The app is an iOS app built using *Flutter*") | |
} | |
output.contains("_OBJC_CLASS_\$_RCTRootView") -> { | |
println("The app is an iOS app built using *React Native*") | |
} | |
else -> { | |
println("The app was not built using React Native, Flutter, or SwiftUI") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment