You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kotlin CocoaPods Gradle plugin is a tool for creating Podspec files. These files are necessary to integrate your Kotlin
4
-
project with the [CocoaPods dependency manager](https://cocoapods.org/).
3
+
<tldr>
4
+
5
+
* Before adding Pod dependencies, [complete the initial configuration](native-cocoapods.md#set-up-an-environment-to-work-with-cocoapods).
6
+
* See the sample project with [different Pod dependencies set up in a Kotlin project](https://github.com/Kotlin/kmp-with-cocoapods-multitarget-xcode-sample).
7
+
* Check out the sample project where [an Xcode project with several targets depends on a Kotlin library](https://github.com/Kotlin/kmp-with-cocoapods-multitarget-xcode-sample).
8
+
9
+
</tldr>
5
10
6
-
This reference contains the complete list of blocks, functions, and properties for the Kotlin CocoaPods Gradle plugin that
7
-
you can use when working with the [CocoaPods integration](native-cocoapods.md).
11
+
The Kotlin CocoaPods Gradle plugin is a tool for creating Podspec files. These files are necessary to integrate your Kotlin
12
+
project with the [CocoaPods dependency manager](https://cocoapods.org/).
8
13
9
-
* Learn how to [set up the environment and configure the Kotlin CocoaPods Gradle plugin](native-cocoapods.md).
10
-
* Depending on your project and purposes, you can add dependencies between [a Kotlin project and a Pod library](native-cocoapods-libraries.md)
11
-
as well as [a Kotlin Gradle project and an Xcode project](native-cocoapods-xcode.md).
14
+
This DSL reference lists the main blocks, functions, and properties for the Kotlin CocoaPods Gradle plugin that
15
+
you can use when setting up CocoaPods integration.
12
16
13
17
## Enable the plugin
14
18
@@ -23,9 +27,9 @@ plugins {
23
27
24
28
The plugin versions match the [Kotlin release versions](releases.md). The latest stable version is %kotlinVersion%.
25
29
26
-
## cocoapods block
30
+
## `cocoapods {}` block
27
31
28
-
The `cocoapods` block is the top-level block for the CocoaPods configuration. It contains general information on the Pod,
32
+
The `cocoapods {}` block is the top-level block for the CocoaPods configuration. It contains general information on the Pod,
29
33
including required information like the Pod version, summary, and homepage, as well as optional features.
30
34
31
35
You can use the following blocks, functions, and properties inside it:
@@ -36,7 +40,7 @@ You can use the following blocks, functions, and properties inside it:
36
40
|`summary`| A required description of the Pod built from this project. |
37
41
|`homepage`| A required link to the homepage of the Pod built from this project. |
38
42
|`authors`| Specifies authors of the Pod built from this project. |
39
-
|`podfile`| Configures the existing `Podfile` file.|
43
+
|`podfile`| Configures the existing Podfile. |
40
44
|`noPodspec()`| Sets up the plugin not to produce a Podspec file for the `cocoapods` section. |
41
45
|`name`| The name of the Pod built from this project. If not provided, the project name is used. |
42
46
|`license`| The license of the Pod built from this project, its type, and the text. |
@@ -88,9 +92,9 @@ kotlin {
88
92
}
89
93
```
90
94
91
-
### framework block
95
+
### `framework {} block
92
96
93
-
The `framework` block is nested inside `cocoapods` and configures the framework properties of the Pod built from the project.
97
+
The `framework {}` block is nested inside `cocoapods` and configures the framework properties of the Pod built from the project.
94
98
95
99
> Note that `baseName` is a required field.
96
100
>
@@ -116,7 +120,7 @@ kotlin {
116
120
}
117
121
```
118
122
119
-
## pod() function
123
+
## `pod()` function
120
124
121
125
The `pod()` function call adds a CocoaPods dependency to the Pod built from this project. Each dependency requires
122
126
a separate function call.
@@ -153,3 +157,9 @@ kotlin {
153
157
}
154
158
}
155
159
```
160
+
161
+
## What's next
162
+
163
+
*[See the full syntax of Kotlin DSL in the Kotlin Gradle plugin repository](https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt)
164
+
*[Add dependencies on a Pod library in your Kotlin project](native-cocoapods-libraries.md)
165
+
*[Set up dependencies between a Kotlin project and an Xcode project](native-cocoapods-xcode.md)
Copy file name to clipboardExpand all lines: docs/topics/multiplatform/native-cocoapods-libraries.md
+40-23Lines changed: 40 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,36 @@
1
1
[//]: #(title: Add dependencies on a Pod library)
2
2
3
-
To add dependencies between a Kotlin project and a Pod library, [complete the initial configuration](native-cocoapods.md#set-up-an-environment-to-work-with-cocoapods).
4
-
You can then add dependencies on different types of Pod libraries.
3
+
<tldr>
5
4
6
-
When you add a new dependency and re-import the project in your IDE, the new dependency will be added automatically.
7
-
No additional steps are required.
5
+
* Before adding Pod dependencies, [complete the initial configuration](native-cocoapods.md#set-up-an-environment-to-work-with-cocoapods).
6
+
* You can find a sample project in our [GitHub repository](https://github.com/Kotlin/kmp-with-cocoapods-sample).
8
7
9
-
To use your Kotlin project with Xcode, you should [make changes in your project Podfile](native-cocoapods.md#update-podfile-for-xcode).
8
+
</tldr>
10
9
11
-
A Kotlin project requires the `pod()` function call in `build.gradle(.kts)` for adding a Pod dependency.
12
-
Each dependency requires its separate function call. You can specify the parameters for the dependency in
10
+
You can add dependencies on Pod libraries from different locations in your Kotlin project.
11
+
12
+
To add a Pod dependency, call the `pod()` function in the shared module's `build.gradle(.kts)` file.
13
+
Each dependency requires a separate function call. You can specify the parameters for the dependency in
13
14
the configuration block of the function.
14
15
16
+
* When you add a new dependency and re-import the project in your IDE, the library will be connected automatically.
17
+
* To use your Kotlin project with Xcode, [make changes in your project's Podfile](native-cocoapods.md#update-podfile-for-xcode) first.
18
+
15
19
> If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target,
16
-
> you will get an error.
20
+
> you'll get an error.
17
21
>
18
22
{style="note"}
19
23
20
-
You can find a sample project [here](https://github.com/Kotlin/kmm-with-cocoapods-sample).
21
-
22
24
## From the CocoaPods repository
23
25
26
+
To add a dependency on a Pod library located in the CocoaPods repository:
27
+
24
28
1. Specify the name of a Pod library in the `pod()` function.
25
29
26
-
In the configuration block, you can specify the version of the library using the `version` parameter. To use the latest
27
-
version of the library, you can just omit this parameter altogether.
30
+
In the configuration block, you can specify the version of the library using the `version` parameter.
31
+
To use the latest version of the library, you can omit this parameter altogether.
28
32
29
-
> You can add dependencies on subspecs.
33
+
> You can add dependencies on subspecs as well.
30
34
>
31
35
{style="note"}
32
36
@@ -49,7 +53,7 @@ version of the library, you can just omit this parameter altogether.
49
53
}
50
54
```
51
55
52
-
3. Run**ReloadAllGradleProjects**inIntelliJIDEA (or**SyncProject with GradleFiles**inAndroidStudio)
56
+
3. Run**Build** | **ReloadAllGradleProjects**inIntelliJIDEA (or**File** |**SyncProject with GradleFiles**inAndroidStudio)
53
57
to re-import the project.
54
58
55
59
To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`:
@@ -60,12 +64,14 @@ import cocoapods.SDWebImage.*
60
64
61
65
## On a locally stored library
62
66
67
+
To add a dependency on a locally stored Pod library:
68
+
63
69
1. Specify the name of a Pod library in the `pod()` function.
64
70
65
71
In the configuration block, specify the path to the local Pod library: use the `path()` function in the `source` parameter value.
66
72
67
73
> You can add local dependencies on subspecs as well.
68
-
> The `cocoapods` block can include dependencies to Pods stored locally and Pods from the CocoaPods repository at
74
+
> The `cocoapods {}` block can include dependencies to Pods stored locally and Pods from the CocoaPods repository at
69
75
> the same time.
70
76
>
71
77
{style="note"}
@@ -104,7 +110,7 @@ import cocoapods.SDWebImage.*
104
110
>
105
111
{style="note"}
106
112
107
-
3. Run**ReloadAllGradleProjects**inIntelliJIDEA (or**SyncProject with GradleFiles**inAndroidStudio)
113
+
3. Run**Build** | **ReloadAllGradleProjects**inIntelliJIDEA (or**File** |**SyncProject with GradleFiles**inAndroidStudio)
108
114
to re-import the project.
109
115
110
116
To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`:
@@ -117,6 +123,8 @@ import cocoapods.SDWebImage.*
117
123
118
124
## From a custom Git repository
119
125
126
+
To add a dependency on a Pod library located in the custom Git repository:
127
+
120
128
1. Specify the name of a Pod library in the `pod()` function.
121
129
122
130
In the configuration block, specify the path to the git repository: use the `git()` function in the `source` parameter value.
@@ -166,7 +174,7 @@ import cocoapods.SDWebImage.*
166
174
}
167
175
```
168
176
169
-
3. Run**ReloadAllGradleProjects**inIntelliJIDEA (or**SyncProject with GradleFiles**inAndroidStudio)
177
+
3. Run**Build** | **ReloadAllGradleProjects**inIntelliJIDEA (or**File** |**SyncProject with GradleFiles**inAndroidStudio)
170
178
to re-import the project.
171
179
172
180
To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`:
0 commit comments