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

iOS: "IllegalArgumentException: bundle with identifier com.xxx.presentation.resources.main not found" due to custom build CONFIGURATION name #795

Open
tamimattafi opened this issue Dec 16, 2024 · 0 comments

Comments

@tamimattafi
Copy link

Problem

After migrating from a dynamic framework, that used CocoaPods plugin, to a static one, without the latter, we faced difficulties with bundling resources to the app.

Setup

As shown in the ReadMe file, we added the following script to our build phase:

"$SRCROOT/../../gradlew" -p "$SRCROOT/../../" :app:composeApp:copyFrameworkResourcesToApp \
    -Pmoko.resources.PLATFORM_NAME="$PLATFORM_NAME" \
    -Pmoko.resources.CONFIGURATION="$CONFIGURATION" \
    -Pmoko.resources.ARCHS="$ARCHS" \
    -Pmoko.resources.BUILT_PRODUCTS_DIR="$BUILT_PRODUCTS_DIR" \
    -Pmoko.resources.CONTENTS_FOLDER_PATH="$CONTENTS_FOLDER_PATH" 

Everything else is set up correctly:

  • Latest moko-resources version: 0.24.4.
  • Resources plugin is added to the submodule and to the shared module.
  • Resources library is added to the submodule and the shared module through implementation(...).

Here's how we build and link the shared framework to the iosApp (This script runs before copying resources, as shown above):

if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
  echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
  exit 0
fi
cd "$SRCROOT/../../"
./gradlew :app:composeApp:embedAndSignAppleFrameworkForXcode

Diagnosis

  • Running find . -type d -name "*.bundle" in the build folder of the shared module shows that bundles exist during the build phase:
./bin/iosArm64/debugFramework/ComposeApp.framework/xxx-kmp-app.data:local.bundle
./bin/iosArm64/debugFramework/ComposeApp.framework/xxx-kmp-app.presentation:resources.bundle
./xcode-frameworks/DebugDevelopment/iphoneos17.4/ComposeApp.framework/xxx-kmp-app.data:local.bundle
./xcode-frameworks/DebugDevelopment/iphoneos17.4/ComposeApp.framework/xxx-kmp-app.presentation:resources.bundle
  • Running ./gradlew tasks in the root project folder shows that copy tasks are correctly generated:
**Moko-resources tasks**
**--------------------**
copyResourcesDebugFrameworkIosArm64
copyResourcesDebugFrameworkIosSimulatorArm64
copyResourcesDebugFrameworkIosX64
copyResourcesDebugTestIosArm64
copyResourcesDebugTestIosSimulatorArm64
copyResourcesDebugTestIosX64
copyResourcesReleaseFrameworkIosArm64
copyResourcesReleaseFrameworkIosSimulatorArm64
copyResourcesReleaseFrameworkIosX64
generateMR
....
// остальные все generate

Workaround

During our discussion with the author @Alex009, we realized that the issue is caused by custom build CONFIGURATION name. In our case, we used DebugDevelopment, while the copy tasks expected something like Debug or Release for static frameworks.

As a workaround, we added KOTLIN_FRAMEWORK_BUILD_TYPE variable to configuration files, with the following values:

// inside debug configuration files
KOTLIN_FRAMEWORK_BUILD_TYPE=debug

// inside release configuration files
KOTLIN_FRAMEWORK_BUILD_TYPE=release

Then we updated the copy script to use KOTLIN_FRAMEWORK_BUILD_TYPE instead of CONFIGURATION, which now looks like this:

"$SRCROOT/../../gradlew" -p "$SRCROOT/../../" :app:composeApp:copyFrameworkResourcesToApp \
    -Pmoko.resources.PLATFORM_NAME="$PLATFORM_NAME" \
    -Pmoko.resources.CONFIGURATION="$KOTLIN_FRAMEWORK_BUILD_TYPE" \
    -Pmoko.resources.ARCHS="$ARCHS" \
    -Pmoko.resources.BUILT_PRODUCTS_DIR="$BUILT_PRODUCTS_DIR" \
    -Pmoko.resources.CONTENTS_FOLDER_PATH="$CONTENTS_FOLDER_PATH" 

This solved our problem! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant