Skip to content

Commit 4859735

Browse files
committed
refactor: Add iOS UI test target and CocoaPods support
- Add a new `test.podspec` file to define a CocoaPods spec for the iOS UI test library. - Configure the podspec to build the 'test' Kotlin framework and link against `SQLCipher`. - Update the `ui/test/build.gradle.kts` file to enable the CocoaPods plugin. - Add CocoaPods configuration for the UI test module, including summary, homepage, version, and iOS deployment target. - Include `kotlin("test")` as a dependency in the `commonTest` source set.
1 parent 4c788b5 commit 4859735

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

ui/test/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ExperimentalComposeLibrary::class
55
)
66

7+
import org.gradle.internal.os.OperatingSystem
78
import org.jetbrains.compose.ExperimentalComposeLibrary
89
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
910
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
@@ -15,6 +16,7 @@ plugins {
1516
alias(libs.plugins.android.library)
1617
alias(libs.plugins.compose)
1718
alias(libs.plugins.compose.compiler)
19+
alias(libs.plugins.kotlin.cocoapods)
1820
}
1921

2022
kotlin {
@@ -50,6 +52,7 @@ kotlin {
5052
}
5153
val commonTest by getting {
5254
dependencies {
55+
implementation(kotlin("test"))
5356
}
5457
}
5558
val jvmTest by getting {
@@ -59,6 +62,17 @@ kotlin {
5962
}
6063
val androidInstrumentedTest by getting
6164
}
65+
cocoapods {
66+
summary = "UI test library for the NoteDelight app"
67+
homepage = "https://github.com/softartdev/NoteDelight"
68+
version = "1.0"
69+
ios.deploymentTarget = "14.0"
70+
pod("SQLCipher", libs.versions.iosSqlCipher.get(), linkOnly = true)
71+
framework {
72+
isStatic = false
73+
}
74+
if (!OperatingSystem.current().isMacOsX) noPodspec()
75+
}
6276
}
6377

6478
android {

ui/test/test.podspec

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Pod::Spec.new do |spec|
2+
spec.name = 'test'
3+
spec.version = '1.0'
4+
spec.homepage = 'https://github.com/softartdev/NoteDelight'
5+
spec.source = { :http=> ''}
6+
spec.authors = ''
7+
spec.license = ''
8+
spec.summary = 'UI test library for the NoteDelight app'
9+
spec.vendored_frameworks = 'build/cocoapods/framework/test.framework'
10+
spec.libraries = 'c++'
11+
spec.ios.deployment_target = '14.0'
12+
spec.dependency 'SQLCipher', '4.9.0'
13+
14+
if !Dir.exist?('build/cocoapods/framework/test.framework') || Dir.empty?('build/cocoapods/framework/test.framework')
15+
raise "
16+
17+
Kotlin framework 'test' doesn't exist yet, so a proper Xcode project can't be generated.
18+
'pod install' should be executed after running ':generateDummyFramework' Gradle task:
19+
20+
./gradlew :ui:test:generateDummyFramework
21+
22+
Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)"
23+
end
24+
25+
spec.xcconfig = {
26+
'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO',
27+
}
28+
29+
spec.pod_target_xcconfig = {
30+
'KOTLIN_PROJECT_PATH' => ':ui:test',
31+
'PRODUCT_MODULE_NAME' => 'test',
32+
}
33+
34+
spec.script_phases = [
35+
{
36+
:name => 'Build test',
37+
:execution_position => :before_compile,
38+
:shell_path => '/bin/sh',
39+
:script => <<-SCRIPT
40+
if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
41+
echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
42+
exit 0
43+
fi
44+
set -ev
45+
REPO_ROOT="$PODS_TARGET_SRCROOT"
46+
"$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
47+
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
48+
-Pkotlin.native.cocoapods.archs="$ARCHS" \
49+
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION"
50+
SCRIPT
51+
}
52+
]
53+
spec.resources = ['build/compose/cocoapods/compose-resources']
54+
end

0 commit comments

Comments
 (0)