Skip to content

Commit a3229ff

Browse files
committed
WIP Allow loading iOS configuration from local.properties
1 parent d427433 commit a3229ff

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

buildSrc/src/main/kotlin/IosTargetsExt.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,33 @@
2121
*/
2222

2323
import org.gradle.api.Project
24+
import java.io.File
25+
import java.util.*
2426

2527
// can't use by lazy, we need Project.findProperty not accessible there
2628
@Suppress("ObjectPropertyName")
2729
private lateinit var _iosTargets: List<String>
2830

31+
private val localProperties = Properties()
32+
private fun Project.getIosTargetedConfiguration(): String? {
33+
return findProperty("ios.target") as? String
34+
?: run {
35+
if (localProperties.isEmpty) {
36+
val localPropertiesFile = File("local.properties")
37+
if (localPropertiesFile.isFile) {
38+
localPropertiesFile.inputStream().use { reader ->
39+
localProperties.load(reader)
40+
}
41+
}
42+
}
43+
localProperties.getProperty("ios.target")
44+
}
45+
}
46+
2947
val Project.iosTargets: List<String>
3048
get() {
3149
if (!::_iosTargets.isInitialized) {
32-
_iosTargets = when (findProperty("ios.target") as? String) {
50+
_iosTargets = when (getIosTargetedConfiguration()) {
3351
// We ignore "iosX64", not considered as a use case
3452
"all" -> listOf("iosArm64", "iosSimulatorArm64")
3553
"simulator" -> listOf("iosSimulatorArm64")

0 commit comments

Comments
 (0)