-
Notifications
You must be signed in to change notification settings - Fork 201
How do you run the iOS app correctly (on X64)? #768
-
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 5 comments · 10 replies
-
Allow me to ping @woxtu and @Corvus400 as you have been submitting iOS pull requests recently. 助けてくれ〜 😭 |
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
|
Beta Was this translation helpful? Give feedback.
All reactions
-
@takahirom @ry-itto |
Beta Was this translation helpful? Give feedback.
All reactions
-
The problem is likely due to using an Intel MacBook. When running arm64 KMP tasks on an Intel MacBook, they are skipped, so valid frameworks are not included in the XCFramework. It seems that an x64 build of KMP will be necessary. Currently, I don't think we have prepared a build for Intel. Let me summarize the situation briefly. |
Beta Was this translation helpful? Give feedback.
All reactions
-
👀 1
-
About XCFramework BuildThis is the core logic:
|
(this.target.name == "iosSimulatorArm64" && this.debuggable) || (this.target.name == "iosArm64" && this.debuggable) |
./gradlew assembleSharedXCFramework --no-configuration-cache -Papp.ios.shared.debug=false
This will include all the frameworks, thus solving the Intel CPU problem.
About iOS Build Phase
This is the core logic. We have 3 build commands:
cd ${SRCROOT}/../..
./gradlew assembleSharedXCFramework --no-configuration-cache
./gradlew iosSimulatorArm64AggregateResources --no-configuration-cache
./gradlew iosArm64AggregateResources --no-configuration-cache
SIMULATOR_RESOURCE_DIR="./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosSimulatorArm64"
DEVICE_RESOURCE_DIR="./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosArm64"
mkdir -p ${SIMULATOR_RESOURCE_DIR}/composeResources
mkdir -p ${DEVICE_RESOURCE_DIR}/composeResources
mkdir -p ${SIMULATOR_RESOURCE_DIR}/compose-resources
mkdir -p ${DEVICE_RESOURCE_DIR}/compose-resources
cp -R ${SIMULATOR_RESOURCE_DIR}/composeResources ${SIMULATOR_RESOURCE_DIR}/compose-resources
cp -R ${DEVICE_RESOURCE_DIR}/composeResources ${DEVICE_RESOURCE_DIR}/compose-resources
./gradlew assembleSharedXCFramework --no-configuration-cache
This is the command I've explained, so let's skip it.
./gradlew iosSimulatorArm64AggregateResources --no-configuration-cache
This task might be skipped on Intel CPUs as well. We might need to add an iosSimulatorX64AggregateResources
task.
./gradlew iosArm64AggregateResources --no-configuration-cache
I think this task is not used and is unnecessary. The reason it's not used is that we don't copy the resources to the app. And it seems that we can run with the simulator resource.
What we should do
I don't have any way to fix the debug build for X64 right now. We might have to pass a flag to Gradle indicating which architecture to use. However, we can fix the resource problem by including iosSimulatorArm64AggregateResources
and iosSimulatorX64AggregateResources
.
@mannodermaus My computer doesn't have the iosSimulatorX64AggregateResources
task. Do you have one?
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for all the insight so far, everybody! I haven't made it work yet, unfortunately, but will keep trying later. @takahirom There is no |
Beta Was this translation helpful? Give feedback.
All reactions
-
@mannodermaus Thank you. Could you provide the tasks of AggregateResources? You can use "./gradlew tasks -a" or something similar. |
Beta Was this translation helpful? Give feedback.
All reactions
-
Of course, here you go. Funnily enough I don't seem to have any of those.
|
Beta Was this translation helpful? Give feedback.
All reactions
-
I see. In KMP, |
Beta Was this translation helpful? Give feedback.
All reactions
-
I'm working on the resource problem. |
Beta Was this translation helpful? Give feedback.
All reactions
-
Sounds like a plan. Please let me know if you need me to test something else! 🙇♂️ |
Beta Was this translation helpful? Give feedback.
All reactions
-
KMP iOS support should work well with the following approach: Framework BuildNormal Use CaseTo build arm64simulator debug:
For all-inclusive build:
Other PatternsYou can build for different architectures by changing the arm64SimulatorDebug part to arm64 (builds for both Simulator and device) or x86_64:
Omitting the When Called from XcodeWhen called from Xcode's build script, it automatically detects Xcode environment variables (such as ARCHS) and builds the appropriate version. Resources are built for both arm and x64, and the suitable ones are automatically included for use. |
Beta Was this translation helpful? Give feedback.
All reactions
-
@mannodermaus |
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1
-
It took 27, but this made the iOS build work indeed! Thank you so much for your hard work on this, I appreciate it. From now on I'll be able to verify code changes in iOS myself, too. 💪 |
Beta Was this translation helpful? Give feedback.
All reactions
-
I need to point out that the current script will link both the debug and release frameworks on every build, even if the release build might not be necessary. We could shave off a few minutes, I think. |
Beta Was this translation helpful? Give feedback.
@mannodermaus
I've added the README. Could you take a look at it? It might take about 10 minutes to build.
https://github.com/DroidKaigi/conference-app-2024/tree/main/app-ios#case3-you-are-using-x86_64-mac-and-want-to-build-the-project