moko-resources
moko-resources copied to clipboard
Strange `can't compile assets - 1` error on iOS due to missing simulator
My build server runs ./gradlew iosSimulatorArm64Test as a GitHub action. When I added moko-resources into a new (almost empty) project, I started running into a strange can't compile assets - 1 that took a little while to debug. This error was not happening locally for me, just on the build server.
I'm not sure this is a moko-resources issue, but I'll document it here for future reference.
The error was:
> Task :shared:compileKotlinIosSimulatorArm64
can't compile assets - 1
FAILURE: Build failed with an exception.
> Task :shared:compileKotlinIosSimulatorArm64 FAILED
* What went wrong:
Execution failed for task ':shared:compileKotlinIosSimulatorArm64'.
> Assets compilation failed:
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org/./
... which I saw was coming from https://github.com/icerockdev/moko-resources/blob/590fc8f2eacbe5aca4992df83aa7473b[…]rock/gradle/generator/apple/action/PackResourcesToKLibAction.kt
After remoting into the server, I tried the command with debugging info: ./gradlew iosSimulatorArm64Test --debug --stacktrace
There was a lot of output, but this was the relevant part:
2024-04-23T11:17:11.252-0400 [ERROR] [org.gradle.api.Task] can't compile assets - 1
2024-04-23T11:17:11.252-0400 [INFO] [org.gradle.api.Task] <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.actool.compilation-results</key>
<dict>
<key>output-files</key>
<array/>
</dict>
<key>com.apple.actool.errors</key>
<array>
<dict>
<key>description</key>
<string>The operation couldn't be completed. Failed to locate any simulator runtime matching options: {
BuildVersionString = 21E210;
Platforms = (
"com.apple.platform.iphonesimulator"
);
VersionString = "17.4";
}</string>
<key>failure-reason</key>
<string>Failed to locate any simulator runtime matching options: {
BuildVersionString = 21E210;
Platforms = (
"com.apple.platform.iphonesimulator"
);
VersionString = "17.4";
}</string>
</dict>
</array>
</dict>
</plist>
That was able to point me in the right direction.
Running xcrun simctl list devices available showed that I had no 17.4 sims on the build server.
So, I tried to create one: xcrun simctl create "iPhone 15 (17.4)" "iPhone 15" iOS17.4 ... but that failed with: Invalid runtime: iOS17.4
Opening Xcode on the Mac mini and installing iOS 17.4 SDK, then creating a simulator, did the trick. (Previously, the highest SDK available I had installed on this particular Mac Mini build server was 17.2)
Again, what's interesting is that ./gradlew iosSimulatorArm64Test worked just fine before moko-resources was included in the project (the tests were run with one of the existing simulators).
The task only started failing because the xcrun actool Assets.xcassets --compile . --platform iphoneos --minimum-deployment-target 9.0 command was looking for the 17.4 simulator which wasn't installed... I'm not 100% sure why that is, or if there's something the moko-resources plugin can do to pick the same simulator as the multiplatform plugin to avoid erroring?
Anyway, I thought this was worth sharing. I'm not sure it's a bug... but it took a bit of digging to figure out so I wanted to share my findings here should anyone else encounter the same thing in the future. 👋
@darronschall in 0.24.0 we now have iosMinimumDeploymentTarget property that passed in actool here
https://github.com/icerockdev/moko-resources/blob/d1afd653949f50e8a74de44aa934d89618418eab/resources-generator/src/main/kotlin/dev/icerock/gradle/actions/apple/PackAppleResourcesToKLibAction.kt#L105
so maybe you configure that minimum target is 17.4? in gradle
@ExNDY here need to change info to error
https://github.com/icerockdev/moko-resources/blob/d1afd653949f50e8a74de44aa934d89618418eab/resources-generator/src/main/kotlin/dev/icerock/gradle/actions/apple/PackAppleResourcesToKLibAction.kt#L115
task.logger.info(input) changed in #674
For this particular project, I have the iOS Deployment Target set in Xcode to 16.0. I'm not sure why actool was looking for a 17.4 sim... I couldn't find a 17.4 reference in any of the project source files.
@darronschall i tell not about deployment target in xcode, but about iosMinimalDeploymentTarget in gradle configuration. did you change it?
@Alex009 Ah, I see. No, I did not supply a value. I'm using a very minimal configuration:
multiplatformResources {
resourcesPackage = "com.myapp.resources"
}
Hi! Was there a resolution for this? We are also seeing this on one of the Macs we are using. Originally, we just used the default iosMinimalDeploymentTarget (9.0), but tried setting it to 13.0 (the minimum target in our iOS project).
We see this error in the logs:
Adding resources to klib file `{SUBMODULE_PATH}/build/classes/kotlin/iosX64/main/klib/design.klib`
can't compile assets - 1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.actool.compilation-results</key>
<dict>
<key>output-files</key>
<array/>
</dict>
<key>com.apple.actool.errors</key>
<array>
<dict>
<key>description</key>
<string>No simulator runtime version from [<DVTBuildVersion 21C62>, <DVTBuildVersion 21E213>, <DVTBuildVersion 21F79>, <DVTBuildVersion 22A3351>] available to use with iphonesimulator SDK version <DVTBuildVersion 22B74></string>
</dict>
</array>
</dict>
</plist>
> Task :design:compileKotlinIosX64 FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':design:compileKotlinIosX64'.
> Assets compilation failed:`
We checked, and there are iOS Simulators versions installed on the problem Mac's XCode.
@Alex009, I forgot to mention, we are also using moko resources version 0.24.0. Please let me know if I should create a separate issue or it's fine here (since it's the same moko resources version). Thanks!
@omargda The error message indicates the issue:
No simulator runtime version from [<DVTBuildVersion 21C62>, <DVTBuildVersion 21E213>, <DVTBuildVersion 21F79>, <DVTBuildVersion 22A3351>] available to use with iphonesimulator SDK version <DVTBuildVersion 22B74>
Double-check that the correct simulator runtime (DVTBuildVersion 22B74) is installed on the macOS machine running the build. See e.g. https://stackoverflow.com/questions/79114871/no-simulator-runtime-version-from-iphonesimulator - sometimes Xcode installs an update in the background and the new SDK needs to be installed manually.
@darronschall Thanks for the response! Both the MacOS and XCode did update automatically recently, so we checked under the components and it does show on the list, but maybe we'll try removing them and re-downloading to see if it helps.