Skip to content

Commit 74d9111

Browse files
committed
Fix xcode project setup
1 parent 0a7ab9c commit 74d9111

34 files changed

Lines changed: 385 additions & 191 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Linux Command Library (Mobile+CLI+Web)
1+
## Linux Command Library (Android+iOS+Desktop GUI and CLI+Web)
22

33
![Icon](https://raw.githubusercontent.com/SimonSchubert/LinuxCommandLibrary/master/art/web_hi_res_144.png)
44

@@ -14,10 +14,16 @@ The app currently has **6219** manual pages, **23+** basic categories and a bunc
1414
<img src="https://raw.githubusercontent.com/SimonSchubert/LinuxCommandBibliotheca/master/art/screen-android-1.png" width="200">
1515
<img src="https://raw.githubusercontent.com/SimonSchubert/LinuxCommandBibliotheca/master/art/screen-android-2.png" width="200">
1616
</p>
17+
18+
### iOS screenshots
19+
1720
<p>
1821
<img src="https://raw.githubusercontent.com/SimonSchubert/LinuxCommandBibliotheca/master/art/screen-ios-1.png" width="200">
1922
<img src="https://raw.githubusercontent.com/SimonSchubert/LinuxCommandBibliotheca/master/art/screen-ios-2.png" width="200">
2023
</p>
24+
25+
### Desktop screenshots
26+
2127
<p>
2228
<img src="https://raw.githubusercontent.com/SimonSchubert/LinuxCommandBibliotheca/master/art/screen-desktop-1.png" width="400">
2329
<img src="https://raw.githubusercontent.com/SimonSchubert/LinuxCommandBibliotheca/master/art/screen-desktop-2.png" width="400">

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MainActivity : AppCompatActivity() {
3535
override fun onCreate(savedInstanceState: Bundle?) {
3636
enableEdgeToEdge(
3737
statusBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT),
38-
navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT)
38+
navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT),
3939
)
4040
super.onCreate(savedInstanceState)
4141

art/web_hi_res_1024.png

110 KB
Loading

common/build.gradle.kts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,35 @@ kotlin {
6060
}
6161
}
6262

63+
// Task to generate Version.kt from libs.versions.toml
64+
val generateVersionFile by tasks.registering {
65+
val appVersion = libs.versions.appVersion.get()
66+
val outputDir = file("src/commonMain/kotlin/com/linuxcommandlibrary/shared")
67+
val outputFile = file("$outputDir/Version.kt")
68+
69+
inputs.property("appVersion", appVersion)
70+
outputs.file(outputFile)
71+
72+
doLast {
73+
outputDir.mkdirs()
74+
outputFile.writeText(
75+
"""
76+
|package com.linuxcommandlibrary.shared
77+
|
78+
|object Version {
79+
| const val appVersion = "$appVersion"
80+
|}
81+
|""".trimMargin()
82+
)
83+
println("Generated Version.kt with version $appVersion")
84+
}
85+
}
86+
87+
// Make compilation depend on version generation
88+
tasks.matching { it.name.contains("compileKotlin") || it.name.contains("Kotlin") && it.name.contains("compile") }.configureEach {
89+
dependsOn(generateVersionFile)
90+
}
91+
6392
android {
6493
compileSdk = 36
6594
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.linuxcommandlibrary.shared
22

33
object Version {
4-
const val appVersion = "3.5.3"
4+
const val appVersion = "3.5.4"
55
}

composeApp/build.gradle.kts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,30 @@ compose.resources {
9696
packageOfResClass = "com.linuxcommandlibrary.app.resources"
9797
generateResClass = always
9898
}
99+
100+
// Task to update iOS Info.plist with the app version from libs.versions.toml
101+
tasks.register("updateIosVersion") {
102+
val appVersion = libs.versions.appVersion.get()
103+
val infoPlistFile = file("${rootProject.projectDir}/iosApp/iosApp/Info.plist")
104+
105+
inputs.property("appVersion", appVersion)
106+
outputs.file(infoPlistFile)
107+
108+
doLast {
109+
if (infoPlistFile.exists()) {
110+
var content = infoPlistFile.readText()
111+
// Update CFBundleShortVersionString
112+
content = content.replace(
113+
Regex("<key>CFBundleShortVersionString</key>\\s*<string>[^<]*</string>"),
114+
"<key>CFBundleShortVersionString</key>\n\t<string>$appVersion</string>"
115+
)
116+
infoPlistFile.writeText(content)
117+
println("Updated iOS Info.plist with version $appVersion")
118+
}
119+
}
120+
}
121+
122+
// Make iOS framework tasks depend on updateIosVersion
123+
tasks.matching { it.name.contains("link") && it.name.contains("Ios") }.configureEach {
124+
dependsOn("updateIosVersion")
125+
}

composeApp/src/androidMain/kotlin/com/linuxcommandlibrary/app/platform/AndroidAssetReader.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@ import android.content.Context
44
import com.linuxcommandlibrary.shared.platform.AssetReader
55

66
class AndroidAssetReader(private val context: Context) : AssetReader {
7-
override fun listFiles(path: String): List<String> {
8-
return try {
9-
context.assets.list(path)?.toList() ?: emptyList()
10-
} catch (e: Exception) {
11-
emptyList()
12-
}
7+
override fun listFiles(path: String): List<String> = try {
8+
context.assets.list(path)?.toList() ?: emptyList()
9+
} catch (e: Exception) {
10+
emptyList()
1311
}
1412

15-
override fun readFile(path: String): String? {
16-
return try {
17-
context.assets.open(path).bufferedReader().readText()
18-
} catch (e: Exception) {
19-
null
20-
}
13+
override fun readFile(path: String): String? = try {
14+
context.assets.open(path).bufferedReader().readText()
15+
} catch (e: Exception) {
16+
null
2117
}
2218
}

composeApp/src/androidMain/kotlin/com/linuxcommandlibrary/app/platform/AndroidPreferencesStorage.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,19 @@ class AndroidPreferencesStorage(context: Context) : PreferencesStorage {
1010
// Use default shared preferences for backward compatibility with existing user data
1111
private val prefs: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
1212

13-
override fun getString(key: String, defaultValue: String): String {
14-
return prefs.getString(key, defaultValue) ?: defaultValue
15-
}
13+
override fun getString(key: String, defaultValue: String): String = prefs.getString(key, defaultValue) ?: defaultValue
1614

1715
override fun putString(key: String, value: String) {
1816
prefs.edit { putString(key, value) }
1917
}
2018

21-
override fun getBoolean(key: String, defaultValue: Boolean): Boolean {
22-
return prefs.getBoolean(key, defaultValue)
23-
}
19+
override fun getBoolean(key: String, defaultValue: Boolean): Boolean = prefs.getBoolean(key, defaultValue)
2420

2521
override fun putBoolean(key: String, value: Boolean) {
2622
prefs.edit { putBoolean(key, value) }
2723
}
2824

29-
override fun getInt(key: String, defaultValue: Int): Int {
30-
return prefs.getInt(key, defaultValue)
31-
}
25+
override fun getInt(key: String, defaultValue: Int): Int = prefs.getInt(key, defaultValue)
3226

3327
override fun putInt(key: String, value: Int) {
3428
prefs.edit { putInt(key, value) }

composeApp/src/androidMain/kotlin/com/linuxcommandlibrary/app/platform/AndroidShareHandler.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ class AndroidShareHandler(private val context: Context) : ShareHandler {
1212
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
1313
}
1414
try {
15-
context.startActivity(Intent.createChooser(intent, "Share command").apply {
16-
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
17-
})
15+
context.startActivity(
16+
Intent.createChooser(intent, "Share command").apply {
17+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
18+
},
19+
)
1820
} catch (e: Exception) {
1921
e.printStackTrace()
2022
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
package com.linuxcommandlibrary.app.platform
22

3+
import androidx.compose.material.icons.Icons
4+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
5+
import androidx.compose.ui.graphics.vector.ImageVector
6+
37
actual val showRateAppButton: Boolean = true
8+
actual val backIcon: ImageVector = Icons.AutoMirrored.Filled.ArrowBack

0 commit comments

Comments
 (0)