Skip to content

Avoid the usage of the exported local package

Introduced in version 0.10.0

This major feature avoids the mandatory usage of the exported local package by copying the necessary resources directly to the application.

Experimental

The goal of this experimental feature is to remove the need to have the exported package included inside your Xcode project.

Documentation and usage feeback are welcomed.

Requirement

Gradle

Set the copyDependenciesToApp at true inside your plugin configuration.

Xcode

Call the following gradle task after the build of your KMP library inside the build phase of Xcode.

:yourKotlinModule:cInteropNameCopyPackageResources

Example :

./gradlew :example:embedAndSignAppleFrameworkForXcode // build the library
./gradlew :example:nativeIosSharedCopyPackageResources // copy the SPM resources

Custom configuration

You can call this task with custom parameters and override the Xcode build environment.

./gradlew :example:nativeIosSharedCopyPackageResources \
                                -PPLATFORM_NAME=iphone \
                                -PARCHS=arm64 \
                                -PBUILT_PRODUCTS_DIR=... \
                                -PCONTENTS_FOLDER_PATH=... \

Optional

You can control what's inside the exported package by setting isIncludedInExportedPackage and exclude non-needed packages.

Example

The example project uses this new feature, and you can take it as a reference for implementing in your project, especially the Gradle file.

Info

The local package can still be used even if you have enabled this feature. Xcode will overwrite the copied files.

Limitation

  • It doesn't work with static frameworks/dependencies (like FirebaseAnalytics).

  • If you have the error Undefined symbol error message, you must include the local package or the required dependency yourself.

  • You lose the capability to use the external dependency inside your Swift Application code.

Feedback

As this feature is experimental, create an issue if needed :)