-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor KMP iOS build #796
Conversation
app-ios-shared/build.gradle.kts
Outdated
(this.target.name == "iosSimulatorArm64" && this.debuggable) || (this.target.name == "iosArm64" && this.debuggable) | ||
} else { | ||
true | ||
val includeToXCF = when (project.activeArch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the logic of activeArch
val Project.activeArch
get() = Arch.findByArch(
rootProject.layout.projectDirectory.file("local.properties").asFile.takeIf { it.exists() }
?.let {
Properties().apply {
load(it.reader(Charsets.UTF_8))
}.getProperty("arch")
} ?: System.getenv("arch") ?: properties["app.ios.shared.arch"] as? String
)
@@ -171,7 +175,7 @@ | |||
8C7DACB72BCBCCB0002C298A /* Preview Assets.xcassets in Resources */, | |||
8C31F46B2BF6909A003F1BBA /* GoogleService-Info.plist in Resources */, | |||
8C7074772C7791BD00FD4F39 /* ci_post_clone.sh in Resources */, | |||
830BFA7C2C74EBF40017A600 /* compose-resources in Resources */, | |||
83CD07FE2C7B1F5400CDEFDB /* compose-resources in Resources */, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -194,7 +194,7 @@ | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
shellPath = /bin/zsh; | |||
shellScript = "cd ${SRCROOT}/../..\n\n./gradlew assembleSharedXCFramework --no-configuration-cache\n./gradlew iosSimulatorArm64AggregateResources --no-configuration-cache\n./gradlew iosArm64AggregateResources --no-configuration-cache\n\nSIMULATOR_RESOURCE_DIR=\"./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosSimulatorArm64\"\nDEVICE_RESOURCE_DIR=\"./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosArm64\"\n\nmkdir -p ${SIMULATOR_RESOURCE_DIR}/composeResources\nmkdir -p ${DEVICE_RESOURCE_DIR}/composeResources\n\nmkdir -p ${SIMULATOR_RESOURCE_DIR}/compose-resources\nmkdir -p ${DEVICE_RESOURCE_DIR}/compose-resources\n\ncp -R ${SIMULATOR_RESOURCE_DIR}/composeResources ${SIMULATOR_RESOURCE_DIR}/compose-resources\ncp -R ${DEVICE_RESOURCE_DIR}/composeResources ${DEVICE_RESOURCE_DIR}/compose-resources\n"; | |||
shellScript = "cd ${SRCROOT}/../..\n\n./build_xcframework_with_xcode_environment_variable.sh\n./gradlew iosSimulatorArm64AggregateResources --no-configuration-cache\n./gradlew iosX64AggregateResources --no-configuration-cache\n\nARM_RESOURCE_DIR=\"./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosSimulatorArm64\"\nX64_RESOURCE_DIR=\"./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosX64\"\nRESOURCE_DIR=\"./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/compose-resources\"\n\nmkdir -p ${ARM_RESOURCE_DIR}/composeResources\nmkdir -p ${X64_RESOURCE_DIR}/composeResources\n\nmkdir -p ${RESOURCE_DIR}\n\ncp -R ${ARM_RESOURCE_DIR}/composeResources ${RESOURCE_DIR}\n\n# Check if X64 resources exist and are not empty\nif [ -d \"${X64_RESOURCE_DIR}/composeResources\" ] && [ \"$(ls -A \"${X64_RESOURCE_DIR}/composeResources\")\" ]; then\n # Copy X64 resources\n cp -R \"${X64_RESOURCE_DIR}/composeResources\" \"${RESOURCE_DIR}\"\nelse\n echo \"Warning: X64_RESOURCE_DIR is empty or does not exist. Skipping X64 resource copy.\"\nfi\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current script is like this
cd ${SRCROOT}/../..
./build_xcframework_with_xcode_environment_variable.sh
./gradlew iosSimulatorArm64AggregateResources --no-configuration-cache
./gradlew iosX64AggregateResources --no-configuration-cache
ARM_RESOURCE_DIR="./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosSimulatorArm64"
X64_RESOURCE_DIR="./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosX64"
RESOURCE_DIR="./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/compose-resources"
mkdir -p ${ARM_RESOURCE_DIR}/composeResources
mkdir -p ${X64_RESOURCE_DIR}/composeResources
mkdir -p ${RESOURCE_DIR}
cp -R ${ARM_RESOURCE_DIR}/composeResources ${RESOURCE_DIR}
# Check if X64 resources exist and are not empty
if [ -d "${X64_RESOURCE_DIR}/composeResources" ] && [ "$(ls -A "${X64_RESOURCE_DIR}/composeResources")" ]; then
# Copy X64 resources
cp -R "${X64_RESOURCE_DIR}/composeResources" "${RESOURCE_DIR}"
else
echo "Warning: X64_RESOURCE_DIR is empty or does not exist. Skipping X64 resource copy."
fi
@@ -14,8 +14,13 @@ build-kmp-module: | |||
cd .. && \ | |||
./gradlew app-ios-shared:assembleSharedXCFramework --no-configuration-cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now build-kmp-module build all architectures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THX!!!
LGTM 👍
Issue
Overview (Required)
app.ios.shared.debug
to achieve Single source of truth.Links
Screenshot (Optional if screenshot test is present or unrelated to UI)
Movie (Optional)