Skip to content

Commit

Permalink
update: cocoapods instructions improvements (#4307)
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-pavlov authored Jun 26, 2024
1 parent 668633d commit a411e9f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
3 changes: 2 additions & 1 deletion docs/topics/multiplatform/multiplatform-ios-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ have some other strong reason to do so.
* [From a custom Podspec repository](native-cocoapods-libraries.md#from-a-custom-podspec-repository)
* [With custom cinterop options](native-cocoapods-libraries.md#with-custom-cinterop-options)

3. Re-import the project.
3. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.

To use the dependency in your Kotlin code, import the package `cocoapods.<library-name>`. For the example above, it's:
Expand Down
17 changes: 11 additions & 6 deletions docs/topics/native/native-cocoapods-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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).
You can then add dependencies on different types of Pod libraries.

When you add a new dependency and re-import the project in IntelliJ IDEA, the new dependency will be added automatically.
When you add a new dependency and re-import the project in your IDE, the new dependency will be added automatically.
No additional steps are required.

To use your Kotlin project with Xcode, you should [make changes in your project Podfile](native-cocoapods.md#update-podfile-for-xcode).
Expand Down Expand Up @@ -49,7 +49,8 @@ version of the library, you can just omit this parameter altogether.
}
```

3. Re-import the project.
3. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.

To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`:

Expand Down Expand Up @@ -101,7 +102,8 @@ import cocoapods.FirebaseAuth.*
>
{type="note"}

3. Re-import the project.
3. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.

To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`:

Expand Down Expand Up @@ -162,7 +164,8 @@ import cocoapods.FirebaseAuth.*
}
```

3. Re-import the project.
3. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.

To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`:

Expand Down Expand Up @@ -198,7 +201,8 @@ import cocoapods.CocoaLumberjack.*
}
```

4. Re-import the project.
4. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.

> To work correctly with Xcode, you should specify the location of specs at the beginning of your Podfile.
> For example,
Expand Down Expand Up @@ -242,7 +246,8 @@ import cocoapods.example.*
}
```

3. Re-import the project.
3. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.

To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`:

Expand Down
13 changes: 10 additions & 3 deletions docs/topics/native/native-cocoapods-xcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ dependency by calling `pod install` manually for each Xcode project. In other ca
end
```

6. Re-import the project.
6. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.

## Xcode project with several targets

Expand Down Expand Up @@ -108,6 +109,12 @@ dependency by calling `pod install` manually for each Xcode project. In other ca
end
```
6. Re-import the project.
6. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.
You can find a sample project [here](https://github.com/Kotlin/kmm-with-cocoapods-multitarget-xcode-sample).
You can find a sample project [here](https://github.com/Kotlin/kmm-with-cocoapods-multitarget-xcode-sample).
## What's next

See [Connect the framework to your iOS project](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-integrate-in-existing-app.html#connect-the-framework-to-your-ios-project)
to learn how to add a custom build script to build phases in Xcode projects.
29 changes: 8 additions & 21 deletions docs/topics/native/native-cocoapods.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Kotlin/Native provides integration with the [CocoaPods dependency manager](https://cocoapods.org/). You can add dependencies
on Pod libraries as well as use a multiplatform project with native targets as a CocoaPods dependency.

You can manage Pod dependencies directly in IntelliJ IDEA and enjoy all the additional features such as code highlighting
and completion. You can build the whole Kotlin project with Gradle and not ever have to switch to Xcode.
You can manage Pod dependencies directly in IntelliJ IDEA or Android Studio and enjoy all the additional features such as
code highlighting and completion. You can build the whole Kotlin project with Gradle and not ever have to switch to Xcode.

Use Xcode only when you need to write Swift/Objective-C code or run your application on a simulator or device.
You only need Xcode if you want to change Swift/Objective-C code or run your application on an Apple simulator or device.
To work correctly with Xcode, you should [update your Podfile](#update-podfile-for-xcode).

Depending on your project and purposes, you can add dependencies between [a Kotlin project and a Pod library](native-cocoapods-libraries.md)
Expand Down Expand Up @@ -91,21 +91,6 @@ sudo gem install cocoapods
</tab>
</tabs>
<procedure initial-collapse-state="collapsed" title="If you use Kotlin prior to version 1.7.0">
<p>If your current version of Kotlin is earlier than 1.7.0, additionally install the <a href="https://github.com/square/cocoapods-generate"><code>cocoapods-generate</code></a> plugin:</p>
<p>
<code style="block"
lang="bash">
sudo gem install -n /usr/local/bin cocoapods-generate
</code>
</p>
<tip>
<p>
Mind that <code>cocoapods-generate</code> couldn't be installed on Ruby 3.0.0 and later. If it's your case, downgrade Ruby or upgrade Kotlin to 1.7.0 or later.
</p>
</tip>
</procedure>
If you encounter problems during the installation, check the [Possible issues and solutions](#possible-issues-and-solutions) section.
## Add and configure Kotlin CocoaPods Gradle plugin
Expand Down Expand Up @@ -170,9 +155,10 @@ If you want to configure your project manually:
>
{type="note"}
3. Re-import the project.
3. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.
4. Generate the [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) to avoid compatibility
issues during an Xcode build.
issues during an Xcode build.
When applied, the CocoaPods plugin does the following:
Expand Down Expand Up @@ -213,7 +199,8 @@ of specs at the beginning of your Podfile:
end
```
> Re-import the project after making changes in the Podfile.
> After making changes in the Podfile, run **Reload All Gradle Projects** in IntelliJ IDEA
> (or **Sync Project with Gradle Files** in Android Studio) to re-import the project.
>
{type="note"}
Expand Down

0 comments on commit a411e9f

Please sign in to comment.