Skip to content
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

Merged
merged 10 commits into from
Aug 25, 2024
Merged

Conversation

takahirom
Copy link
Member

Issue

  • close #ISSUE_NUMBER

Overview (Required)

  • Remove app.ios.shared.debug to achieve Single source of truth.
  • Build resource for x64 as well
  • Build KMP Framework by xcode environment variable

Links

Screenshot (Optional if screenshot test is present or unrelated to UI)

Before After

Movie (Optional)

Before After

@takahirom takahirom requested review from ry-itto and a team August 25, 2024 09:07
(this.target.name == "iosSimulatorArm64" && this.debuggable) || (this.target.name == "iosArm64" && this.debuggable)
} else {
true
val includeToXCF = when (project.activeArch) {
Copy link
Member Author

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 */,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current resource is like this
image

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 25, 2024 09:10 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution August 25, 2024 09:14 Inactive
@@ -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";
Copy link
Member Author

@takahirom takahirom Aug 25, 2024

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

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 25, 2024 09:17 Inactive
@@ -14,8 +14,13 @@ build-kmp-module:
cd .. && \
./gradlew app-ios-shared:assembleSharedXCFramework --no-configuration-cache
Copy link
Member Author

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.

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 25, 2024 10:50 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution August 25, 2024 11:05 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution August 25, 2024 11:10 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution August 25, 2024 11:18 Inactive
Copy link
Contributor

@MrSmart00 MrSmart00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX!!!
LGTM 👍

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 25, 2024 12:20 Inactive
@takahirom takahirom merged commit 9e87f5a into main Aug 25, 2024
7 checks passed
@takahirom takahirom deleted the takahirom/refactor-kmp-ios-build/2024-08-25 branch August 25, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants