Skip to content

update: cocoapods import and links #4782

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

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ and `source` of the library, in its configuration block:
```kotlin
kotlin {
iosArm64()

cocoapods {
version = "2.0"
summary = "CocoaPods test library"
homepage = "https://github.com/JetBrains/kotlin"

ios.deploymentTarget = "16.0"

pod("pod_dependency") {
Expand Down
10 changes: 2 additions & 8 deletions docs/topics/multiplatform/native-cocoapods-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ version of the library, you can just omit this parameter altogether.

cocoapods {
version = "2.0"
ios.deploymentTarget = "16.0"

summary = "CocoaPods test library"
homepage = "https://github.com/JetBrains/kotlin"
ios.deploymentTarget = "16.0"

pod("SDWebImage") {
version = "5.20.0"
Expand Down Expand Up @@ -81,7 +80,6 @@ import cocoapods.SDWebImage.*
version = "2.0"
summary = "CocoaPods test library"
homepage = "https://github.com/JetBrains/kotlin"

ios.deploymentTarget = "16.0"

pod("pod_dependency") {
Expand Down Expand Up @@ -145,7 +143,6 @@ import cocoapods.SDWebImage.*
version = "2.0"
summary = "CocoaPods test library"
homepage = "https://github.com/JetBrains/kotlin"

ios.deploymentTarget = "16.0"

pod("SDWebImage") {
Expand Down Expand Up @@ -175,7 +172,7 @@ import cocoapods.SDWebImage.*
To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`:

```kotlin
import cocoapods.Alamofire.*
import cocoapods.SDWebImage.*
import cocoapods.JSONModel.*
import cocoapods.CocoaLumberjack.*
```
Expand All @@ -194,7 +191,6 @@ import cocoapods.CocoaLumberjack.*
version = "2.0"
summary = "CocoaPods test library"
homepage = "https://github.com/JetBrains/kotlin"

ios.deploymentTarget = "16.0"

specRepos {
Expand Down Expand Up @@ -245,7 +241,6 @@ import cocoapods.example.*
version = "2.0"
summary = "CocoaPods test library"
homepage = "https://github.com/JetBrains/kotlin"

ios.deploymentTarget = "16.0"

pod("FirebaseAuth") {
Expand Down Expand Up @@ -294,7 +289,6 @@ kotlin {
version = "2.0"
summary = "CocoaPods test library"
homepage = "https://github.com/JetBrains/kotlin"

ios.deploymentTarget = "16.0"

pod("PodName") {
Expand Down
1 change: 1 addition & 0 deletions docs/topics/multiplatform/native-cocoapods-xcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependency by calling `pod install` manually for each Xcode project. In other ca
summary = "CocoaPods test library"
homepage = "https://github.com/JetBrains/kotlin"
ios.deploymentTarget = "16.0"

pod("SDWebImage") {
version = "5.20.0"
}
Expand Down
19 changes: 12 additions & 7 deletions docs/topics/multiplatform/native-cocoapods.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ To create a project using the web wizard and configure the CocoaPods integration
alias(libs.plugins.kotlinCocoapods)
```

Now you are ready to use CocoaPods in your Kotlin Multiplatform project.
Now you are ready to [configure CocoaPods in your Kotlin Multiplatform project](#configure-the-project).

### In Android Studio

To create a project in Android Studio with the CocoaPods integration:

1. Install the [Kotlin Multiplatform plugin](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform) to Android Studio.
2. In Android Studio, select **File** | **New** | **New Project** in the menu.
2. In Android Studio, select **File** | **New** | **New Project** in the menu.
3. In the list of project templates, select **Kotlin Multiplatform App** and then click **Next**.
4. Name your application and click **Next**.
5. Choose **CocoaPods Dependency Manager** as the iOS framework distribution option.
Expand All @@ -152,11 +152,16 @@ To create a project in Android Studio with the CocoaPods integration:

The plugin will automatically generate the project with the CocoaPods integration set up.

## Configure existing project
## Configure the project

If you already have a project, you can add and configure the Kotlin CocoaPods Gradle plugin manually:
To configure the Kotlin CocoaPods Gradle plugin in your multiplatform project:

1. In `build.gradle(.kts)` of your project, apply the CocoaPods plugin as well as the Kotlin Multiplatform plugin:
1. In `build.gradle(.kts)` of your project, apply the CocoaPods plugin as well as the Kotlin Multiplatform plugin.

> Skip this step if you've created your project with the [web wizard](#using-web-wizard) or
> the [Kotlin Multiplatform plugin for Android Studio](#in-android-studio).
>
{style="note"}

```kotlin
plugins {
Expand Down Expand Up @@ -318,8 +323,8 @@ Try these workarounds to avoid this error:

1. Look through the downloaded Pod directory `[shared_module_name]/build/cocoapods/synthetic/IOS/Pods/...`
for the `module.modulemap` file.
2. Check the framework name inside the module, for example `SDWebImageMapKit {}`. If the framework name doesn't match the Pod
name, specify it explicitly:
2. Check the framework name inside the module, for example `SDWebImageMapKit {}`. If the framework name doesn't match
the Pod name, specify it explicitly:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not about the PR changes, but I have trouble understanding what needs to be done here. If the framework name doesn't match the Pod name, what should I specify as moduleName?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some Pods are distributed as frameworks, so in some sense, the terms are interchangeable. I'm expanding this section in another PR and mention that as well


```kotlin
pod("SDWebImage/MapKit") {
Expand Down