Skip to content

Commit 7dcf26b

Browse files
authored
Merge pull request #648 from FabioCornelli/watchos-support
Add WatchOS support
2 parents 0d35aef + 60eafe0 commit 7dcf26b

35 files changed

Lines changed: 784 additions & 41 deletions

File tree

.github/compilation-check-source.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ on:
6363

6464
jobs:
6565
build-library:
66-
runs-on: ${{ matrix.os }}
67-
strategy:
68-
matrix:
69-
<<: *runner_matrix
66+
runs-on: macOS-latest
7067

7168
steps:
7269
- *checkout
@@ -76,10 +73,13 @@ jobs:
7673

7774
- name: Check
7875
run: ./local-check.sh
76+
shell: bash
7977
- name: Plugin local publish
8078
run: ./gradlew -p resources-generator publishToMavenLocal
79+
shell: bash
8180
- name: Library local publish
8281
run: ./gradlew publishToMavenLocal
82+
shell: bash
8383

8484
- name: Upload artifacts
8585
uses: actions/upload-artifact@v3
@@ -106,6 +106,7 @@ jobs:
106106

107107
- name: Sample - android-mpp-app
108108
run: cd samples/android-mpp-app && ./local-check.sh
109+
shell: bash
109110

110111
- *publish_test_report
111112
- *upload_reports
@@ -126,6 +127,7 @@ jobs:
126127

127128
- name: Sample - auto-manifest
128129
run: cd samples/auto-manifest && ./local-check.sh
130+
shell: bash
129131

130132
- *publish_test_report
131133
- *upload_reports
@@ -146,6 +148,7 @@ jobs:
146148

147149
- name: Sample - compose-jvm-app
148150
run: cd samples/compose-jvm-app && ./local-check.sh
151+
shell: bash
149152

150153
- *publish_test_report
151154
- *upload_reports
@@ -166,6 +169,7 @@ jobs:
166169

167170
- name: Sample - resources-gallery
168171
run: cd samples/resources-gallery && ./local-check.sh
172+
shell: bash
169173

170174
- *publish_test_report
171175
- *upload_reports
@@ -186,6 +190,7 @@ jobs:
186190

187191
- name: Sample - default-hierarchy-gallery-mobile
188192
run: cd samples/default-hierarchy-gallery-mobile && ./local-check.sh
193+
shell: bash
189194

190195
- *publish_test_report
191196
- *upload_reports
@@ -203,6 +208,7 @@ jobs:
203208

204209
- name: Sample - ios-static-xcframework
205210
run: cd samples/ios-static-xcframework && ./local-check.sh
211+
shell: bash
206212

207213
- *publish_test_report
208214
- *upload_reports
@@ -220,6 +226,7 @@ jobs:
220226

221227
- name: Sample - ios-cocoapods-static-framework
222228
run: cd samples/ios-cocoapods-static-framework && ./local-check.sh
229+
shell: bash
223230

224231
- *publish_test_report
225232
- *upload_reports
@@ -237,6 +244,7 @@ jobs:
237244

238245
- name: Sample - kotlin-ios-app
239246
run: cd samples/kotlin-ios-app && ./local-check.sh
247+
shell: bash
240248

241249
- *publish_test_report
242250
- *upload_reports
@@ -257,6 +265,7 @@ jobs:
257265

258266
- name: Sample - compose-resources-gallery
259267
run: cd samples/compose-resources-gallery && ./local-check.sh
268+
shell: bash
260269

261270
- *publish_test_report
262271
- *upload_reports
@@ -277,6 +286,7 @@ jobs:
277286

278287
- name: Sample - kotlin-2-sample
279288
run: cd samples/kotlin-2-sample && ./local-check.sh
289+
shell: bash
280290

281291
- *publish_test_report
282292
- *upload_reports
@@ -297,6 +307,7 @@ jobs:
297307

298308
- name: Sample - cm-resources-sample
299309
run: cd samples/cm-resources-sample && ./local-check.sh
310+
shell: bash
300311

301312
- *publish_test_report
302313
- *upload_reports

.github/workflows/compilation-check.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ on:
1212

1313
jobs:
1414
build-library:
15-
runs-on: ${{ matrix.os }}
16-
strategy:
17-
matrix:
18-
os:
19-
- macOS-latest
20-
- windows-latest
21-
- ubuntu-latest
15+
runs-on: macOS-latest
2216
steps:
2317
- uses: actions/checkout@v1
2418
- name: Set up JDK 17
@@ -39,10 +33,13 @@ jobs:
3933
${{ runner.os }}-konan-
4034
- name: Check
4135
run: ./local-check.sh
36+
shell: bash
4237
- name: Plugin local publish
4338
run: ./gradlew -p resources-generator publishToMavenLocal
39+
shell: bash
4440
- name: Library local publish
4541
run: ./gradlew publishToMavenLocal
42+
shell: bash
4643
- name: Upload artifacts
4744
uses: actions/upload-artifact@v3
4845
with:
@@ -94,6 +91,7 @@ jobs:
9491
path: ~/.m2/repository/dev/icerock
9592
- name: Sample - android-mpp-app
9693
run: cd samples/android-mpp-app && ./local-check.sh
94+
shell: bash
9795
- name: Publish Test Report
9896
uses: mikepenz/action-junit-report@v2
9997
if: ${{ always() }}
@@ -140,6 +138,7 @@ jobs:
140138
path: ~/.m2/repository/dev/icerock
141139
- name: Sample - auto-manifest
142140
run: cd samples/auto-manifest && ./local-check.sh
141+
shell: bash
143142
- name: Publish Test Report
144143
uses: mikepenz/action-junit-report@v2
145144
if: ${{ always() }}
@@ -186,6 +185,7 @@ jobs:
186185
path: ~/.m2/repository/dev/icerock
187186
- name: Sample - compose-jvm-app
188187
run: cd samples/compose-jvm-app && ./local-check.sh
188+
shell: bash
189189
- name: Publish Test Report
190190
uses: mikepenz/action-junit-report@v2
191191
if: ${{ always() }}
@@ -232,6 +232,7 @@ jobs:
232232
path: ~/.m2/repository/dev/icerock
233233
- name: Sample - resources-gallery
234234
run: cd samples/resources-gallery && ./local-check.sh
235+
shell: bash
235236
- name: Publish Test Report
236237
uses: mikepenz/action-junit-report@v2
237238
if: ${{ always() }}
@@ -278,6 +279,7 @@ jobs:
278279
path: ~/.m2/repository/dev/icerock
279280
- name: Sample - default-hierarchy-gallery-mobile
280281
run: cd samples/default-hierarchy-gallery-mobile && ./local-check.sh
282+
shell: bash
281283
- name: Publish Test Report
282284
uses: mikepenz/action-junit-report@v2
283285
if: ${{ always() }}
@@ -318,6 +320,7 @@ jobs:
318320
path: ~/.m2/repository/dev/icerock
319321
- name: Sample - ios-static-xcframework
320322
run: cd samples/ios-static-xcframework && ./local-check.sh
323+
shell: bash
321324
- name: Publish Test Report
322325
uses: mikepenz/action-junit-report@v2
323326
if: ${{ always() }}
@@ -358,6 +361,7 @@ jobs:
358361
path: ~/.m2/repository/dev/icerock
359362
- name: Sample - ios-cocoapods-static-framework
360363
run: cd samples/ios-cocoapods-static-framework && ./local-check.sh
364+
shell: bash
361365
- name: Publish Test Report
362366
uses: mikepenz/action-junit-report@v2
363367
if: ${{ always() }}
@@ -398,6 +402,7 @@ jobs:
398402
path: ~/.m2/repository/dev/icerock
399403
- name: Sample - kotlin-ios-app
400404
run: cd samples/kotlin-ios-app && ./local-check.sh
405+
shell: bash
401406
- name: Publish Test Report
402407
uses: mikepenz/action-junit-report@v2
403408
if: ${{ always() }}
@@ -444,6 +449,7 @@ jobs:
444449
path: ~/.m2/repository/dev/icerock
445450
- name: Sample - compose-resources-gallery
446451
run: cd samples/compose-resources-gallery && ./local-check.sh
452+
shell: bash
447453
- name: Publish Test Report
448454
uses: mikepenz/action-junit-report@v2
449455
if: ${{ always() }}
@@ -490,6 +496,7 @@ jobs:
490496
path: ~/.m2/repository/dev/icerock
491497
- name: Sample - kotlin-2-sample
492498
run: cd samples/kotlin-2-sample && ./local-check.sh
499+
shell: bash
493500
- name: Publish Test Report
494501
uses: mikepenz/action-junit-report@v2
495502
if: ${{ always() }}
@@ -536,6 +543,7 @@ jobs:
536543
path: ~/.m2/repository/dev/icerock
537544
- name: Sample - cm-resources-sample
538545
run: cd samples/cm-resources-sample && ./local-check.sh
546+
shell: bash
539547
- name: Publish Test Report
540548
uses: mikepenz/action-junit-report@v2
541549
if: ${{ always() }}

resources-build-logic/src/main/kotlin/apple-main-convention.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ kotlin {
3131
dependsOn(appleTest)
3232
}
3333
}
34+
35+
sourceSets.matching {
36+
it.name == "watchosMain"
37+
}.configureEach {
38+
this.dependsOn(sourceSets.getByName("appleMain"))
39+
}
3440
}

resources-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ kotlin {
2626
}
2727

2828
sourceSets {
29+
val commonMain by getting
30+
2931
val iosX64Main by getting
3032
val iosArm64Main by getting
3133
val iosSimulatorArm64Main by getting
@@ -46,7 +48,6 @@ kotlin {
4648
iosSimulatorArm64Test.dependsOn(this)
4749
}
4850

49-
val commonMain by getting
5051
val macosArm64Main by getting
5152
val macosX64Main by getting
5253

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
plugins {
6+
id("multiplatform-library-convention")
7+
}
8+
9+
kotlin {
10+
watchosX64()
11+
watchosArm32()
12+
watchosArm64()
13+
watchosSimulatorArm64()
14+
15+
sourceSets {
16+
val commonMain by getting
17+
18+
val watchosMain by creating {
19+
dependsOn(commonMain)
20+
}
21+
val watchosX64Main by getting {
22+
dependsOn(watchosMain)
23+
}
24+
val watchosArm32Main by getting{
25+
dependsOn(watchosMain)
26+
}
27+
val watchosArm64Main by getting{
28+
dependsOn(watchosMain)
29+
}
30+
val watchosSimulatorArm64Main by getting{
31+
dependsOn(watchosMain)
32+
}
33+
}
34+
}
35+

resources-compose/src/appleMain/kotlin/dev/icerock/moko/resources/compose/internal/CGImageRef+Skia.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import kotlinx.cinterop.CPointed
1010
import kotlinx.cinterop.CPointer
1111
import kotlinx.cinterop.CValue
1212
import kotlinx.cinterop.ExperimentalForeignApi
13-
import kotlinx.cinterop.readBytes
1413
import kotlinx.cinterop.refTo
1514
import org.jetbrains.skia.ColorAlphaType
1615
import org.jetbrains.skia.ColorType

resources-test/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
plugins {
6-
id("multiplatform-library-convention")
6+
id("multiplatform-library-extended-convention")
77
id("multiplatform-android-publish-convention")
88
id("apple-main-convention")
99
id("detekt-convention")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package dev.icerock.moko.resources.test
6+
7+
import dev.icerock.moko.resources.FontResource
8+
import dev.icerock.moko.resources.ImageResource
9+
10+
actual fun createImageResourceMock(): ImageResource = ImageResource("")
11+
actual fun createFontResourceMock(): FontResource = FontResource("")

resources/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
plugins {
6-
id("multiplatform-library-convention")
6+
id("multiplatform-library-extended-convention")
77
id("multiplatform-android-publish-convention")
88
id("apple-main-convention")
99
id("kotlin-parcelize")

resources/src/appleMain/kotlin/dev/icerock/moko/resources/FontResource.kt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
package dev.icerock.moko.resources
66

7+
import cnames.structs.CGDataProvider
8+
import cnames.structs.CGFont
79
import cnames.structs.__CFData
10+
import cnames.structs.__CFString
11+
import cnames.structs.__CFURL
812
import kotlinx.cinterop.BetaInteropApi
913
import kotlinx.cinterop.CPointer
1014
import kotlinx.cinterop.ExperimentalForeignApi
@@ -45,12 +49,12 @@ actual class FontResource(
4549
internal val fontRef: CGFontRef by lazy {
4650
val fontData: NSData = this.data
4751
val cfDataRef: CPointer<__CFData>? = CFDataCreate(
48-
kCFAllocatorDefault,
49-
fontData.bytes() as CPointer<UInt8Var>,
50-
fontData.length.toLong().convert()
52+
allocator = kCFAllocatorDefault,
53+
bytes = fontData.bytes() as CPointer<UInt8Var>,
54+
length = fontData.length.toLong().convert()
5155
)
52-
val dataProvider = CGDataProviderCreateWithCFData(cfDataRef)
53-
val cgFont = CGFontCreateWithDataProvider(dataProvider)!!
56+
val dataProvider: CPointer<CGDataProvider>? = CGDataProviderCreateWithCFData(cfDataRef)
57+
val cgFont: CPointer<CGFont> = CGFontCreateWithDataProvider(dataProvider)!!
5458

5559
CGDataProviderRelease(dataProvider)
5660
CFRelease(cfDataRef)
@@ -82,22 +86,23 @@ actual class FontResource(
8286
// an NSString so `as NSString` is fine.
8387
// UNCHECKED_CAST - NSString and CFStringRef are toll-free bridged
8488
@Suppress("CAST_NEVER_SUCCEEDS", "UNCHECKED_CAST")
85-
val cfStringFilePath = CFBridgingRetain(filePath as NSString) as CFStringRef
86-
val cfFontUrlRef = CFURLCreateWithFileSystemPath(
87-
kCFAllocatorDefault,
88-
cfStringFilePath,
89-
kCFURLPOSIXPathStyle,
90-
false
89+
val cfStringFilePath: CPointer<__CFString> =
90+
CFBridgingRetain(filePath as NSString) as CFStringRef
91+
val cfFontUrlRef: CPointer<__CFURL>? = CFURLCreateWithFileSystemPath(
92+
allocator = kCFAllocatorDefault,
93+
filePath = cfStringFilePath,
94+
pathStyle = kCFURLPOSIXPathStyle,
95+
isDirectory = false
9196
)
9297

9398
var nsError: NSError? = null
9499

95100
memScoped {
96101
val error = alloc<CFErrorRefVar>()
97102
if (!CTFontManagerRegisterFontsForURL(
98-
cfFontUrlRef,
99-
kCTFontManagerScopeProcess,
100-
error.ptr
103+
fontURL = cfFontUrlRef,
104+
scope = kCTFontManagerScopeProcess,
105+
error = error.ptr
101106
)
102107
) {
103108
error.value?.let {

0 commit comments

Comments
 (0)