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

update: cocoapods setup add info #4464

Merged
merged 5 commits into from
Oct 17, 2024
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
16 changes: 13 additions & 3 deletions docs/topics/multiplatform/native-cocoapods-xcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ dependency by calling `pod install` manually for each Xcode project. In other ca
end
```

6. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
6. Run `pod install` in you project directory.

When you run `pod install` for the first time, it creates the `.xcworkspace` file. This file
includes your original `.xcodeproj` and the CocoaPods project.
7. Close your `.xcodeproj` and open the new `.xcworkspace` file instead. This way you avoid issues with project dependencies.
8. 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 @@ -109,12 +114,17 @@ dependency by calling `pod install` manually for each Xcode project. In other ca
end
```

6. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
6. Run `pod install` in you project directory.

When you run `pod install` for the first time, it creates the `.xcworkspace` file. This file
includes your original `.xcodeproj` and the CocoaPods project.
7. Close your `.xcodeproj` and open the new `.xcworkspace` file instead. This way you avoid issues with project dependencies.
8. 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).

## 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.
to learn how to add a custom build script to build phases in Xcode projects.
53 changes: 29 additions & 24 deletions docs/topics/multiplatform/native-cocoapods.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,40 +216,45 @@ the build process of an Xcode project.

## Update Podfile for Xcode

If you want to import your Kotlin project in an Xcode project, you need to make some changes to your Podfile:
If you want to import your Kotlin project to an Xcode project:

* If your project has any Git, HTTP, or custom Podspec repository dependencies, you should also specify the path to
the Podspec in the Podfile.
1. Make changes in your Podfile:

For example, if you add a dependency on `podspecWithFilesExample`, declare the path to the Podspec in the Podfile:
* If your project has any Git, HTTP, or custom Podspec repository dependencies, you should specify the path to
the Podspec in the Podfile.

```ruby
target 'ios-app' do
For example, if you add a dependency on `podspecWithFilesExample`, declare the path to the Podspec in the Podfile:

```ruby
target 'ios-app' do
# ... other dependencies ...
pod 'podspecWithFilesExample', :path => 'cocoapods/externalSources/url/podspecWithFilesExample'
end
```
pod 'podspecWithFilesExample', :path => 'cocoapods/externalSources/url/podspecWithFilesExample'
end
```

The `:path` should contain the filepath to the Pod.
The `:path` should contain the filepath to the Pod.

* When you add a library from the custom Podspec repository, you should also specify the [location](https://guides.cocoapods.org/syntax/podfile.html#source)
of specs at the beginning of your Podfile:
* When you add a library from the custom Podspec repository, you should also specify the [location](https://guides.cocoapods.org/syntax/podfile.html#source)
of specs at the beginning of your Podfile:

```ruby
source 'https://github.com/Kotlin/kotlin-cocoapods-spec.git'
```ruby
source 'https://github.com/Kotlin/kotlin-cocoapods-spec.git'

target 'kotlin-cocoapods-xcproj' do
# ... other dependencies ...
pod 'example'
end
```
target 'kotlin-cocoapods-xcproj' do
# ... other dependencies ...
pod 'example'
end
```

> 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.
>
{style="note"}
2. Run `pod install` in you project directory.

When you run `pod install` for the first time, it creates the `.xcworkspace` file. This file
includes your original `.xcodeproj` and the CocoaPods project.
3. Close your `.xcodeproj` and open the new `.xcworkspace` file instead. This way you avoid issues with project dependencies.
4. Run **Reload All Gradle Projects** in IntelliJ IDEA (or **Sync Project with Gradle Files** in Android Studio)
to re-import the project.

If you don't make these changes to the Podfile, the `podInstall` task will fail, and the CocoaPods plugin will show
If you don't make these changes in the Podfile, the `podInstall` task will fail, and the CocoaPods plugin will show
an error message in the log.

## Possible issues and solutions
Expand Down
Loading