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

Migrate to CocoaPods #88

Merged
merged 9 commits into from
Jul 29, 2023
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
30 changes: 18 additions & 12 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Pull Request

on:
Expand All @@ -13,10 +10,25 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Cocoapods cache
uses: actions/cache@v3
id: cocoapods-cache
with:
path: |
~/.cocoapods
~/Library/Caches/CocoaPods
*/build/cocoapods
*/build/classes
key: cocoapods-cache

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
cache: gradle

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -31,7 +43,7 @@ jobs:
target: google_apis
arch: x86_64
profile: Nexus 6
script: ./gradlew connectedAndroidTest
script: ./gradlew webrtc-kmp:connectedAndroidTest

- name: Upload Android test artifact
uses: actions/upload-artifact@v2
Expand All @@ -40,14 +52,8 @@ jobs:
name: "Android Instrumented Tests Report HTML"
path: "webrtc-kmp/build/reports/androidTests/connected"

- name: Install Carthage
run: brew list carthage || brew install carthage

- name: Fetch xCode frameworks
run: carthage update --use-xcframeworks

- name: Run iOS tests
run: ./gradlew iosX64Test
run: ./gradlew cleanTest webrtc-kmp:iosX64Test

- name: Upload iOS test artifact
uses: actions/upload-artifact@v2
Expand All @@ -57,7 +63,7 @@ jobs:
path: "webrtc-kmp/build/reports/tests/iosX64Test"

- name: Run JS tests
run: ./gradlew jsTest
run: ./gradlew cleanTest webrtc-kmp:jsTest

- name: Upload JS test artifact
uses: actions/upload-artifact@v2
Expand Down
3 changes: 0 additions & 3 deletions Cartfile

This file was deleted.

60 changes: 42 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,64 @@ WebRTC Kotlin Multiplatform SDK
Current revision: M114

## Installation
Root build.gradle.kts

```Kotlin
allprojects {
repositories {
mavenCentral()
}
}
```
The library is published to [Maven Central](https://search.maven.org/artifact/com.shepeliev/webrtc-kmp).

Shared module build.gradle.kts
```Kotlin
kotlin {
cocoapods {
version = "1.0.0"
summary = "Shared module"
homepage = "not published"
ios.deploymentTarget = "10.0"

ios {
binaries
.filterIsInstance<Framework>()
.forEach {
it.transitiveExport = true
it.export("com.shepeliev:webrtc-kmp:$webRtcKmmVersion")
}
specRepos {
url("https://github.com/webrtc-sdk/Specs.git")
}

pod("WebRTC-SDK") {
version = "114.5735.01"
linkOnly = true
}

podfile = project.file("../iosApp/Podfile")

framework {
baseName = "shared"
export(project(":webrtc-kmp"))
transitiveExport = true
}

xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG
xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE
}


android()

ios()

js {
useCommonJs()
browser()
}

sourceSets {
val commonMain by getting {
dependencies {
api("com.shepeliev:webrtc-kmp:$webRtcKmmVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
api("com.shepeliev:webrtc-kmp:$webRtcKmpVersion")
}
}
}
}
```

Also add the following to your `Podfile` in the target section:
```Ruby
use_frameworks!
pod 'shared', :path => '../shared'
```

## Usage

Please reffer to [sample](sample/README.md).
6 changes: 0 additions & 6 deletions WebRTC.json

This file was deleted.

16 changes: 2 additions & 14 deletions buildSrc/src/main/kotlin/FrameworkUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@ import org.gradle.api.Project
import org.jetbrains.kotlin.konan.target.KonanTarget
import java.io.File

fun Project.getFrameworks(target: KonanTarget): Map<String, File> {
val cartBuildPath = rootProject.projectDir.resolve("Carthage/Build")

val frameworks = cartBuildPath
.listFiles { _, name -> name.endsWith(".xcframework") }
?.filter { it.isDirectory }
?.map { it.name.substringBefore(".xcframework") }
?: emptyList()

return frameworks.associateWith { cartBuildPath.resolveArchPath(target, it) }
}

private fun File.resolveArchPath(target: KonanTarget, framework: String): File {
fun File.resolveArchPath(target: KonanTarget, framework: String): File? {
val archPaths = resolve("$framework.xcframework")
.listFiles { _, name -> target.matches(name) }
?: error("Can't find framework '$framework' for target '${target.name}'")
?: return null

check(archPaths.size == 1) { "Resolving framework '$framework' arch path failed: $archPaths" }

Expand Down
7 changes: 1 addition & 6 deletions sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Demo application for WebRTC KMP.
```bash
git clone https://github.com/shepeliev/webrtc-kmp.git
cd webrtc-kmp
carthage update --use-xcframeworks
```

### Android
Expand All @@ -20,11 +19,7 @@ Run Android emulator or connect real device.

### iOS

```bash
./gradlew assembleSharedDebugXCFramework
```

Then open `sample/app-ios/app-ios.xcodeproj` in XCode build and run
Open `sample/app-ios/app-ios.xcworkspace` in XCode build and run

### Web

Expand Down
2 changes: 2 additions & 0 deletions sample/app-ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,5 @@ Dependencies/
**/xcshareddata/WorkspaceSettings.xcsettings

# End of https://www.toptal.com/developers/gitignore/api/swift,xcode,C,objective-c,osx

Pods/
6 changes: 6 additions & 0 deletions sample/app-ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
platform :ios, '11.0'

target 'app-ios' do
use_frameworks!
pod 'shared', :path => '../shared'
end
Loading