Skip to content
Closed
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
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ plugins {
`kotlin-dsl`
}
repositories {
jcenter()
mavenCentral()
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ object Versions {
}

object BuildPluginsVersion {
const val DETEKT = "1.15.0"
const val KOTLIN = "1.4.30"
const val DETEKT = "1.23.6"
const val KOTLIN = "2.0.0"
const val KTLINT = "10.0.0"
const val VERSIONS_PLUGIN = "0.36.0"
}
Expand Down
31 changes: 29 additions & 2 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,40 @@ kotlin {
}

spm {
ios("11") {
ios("13") {
dependencies {
packages(
url = "https://github.com/AFNetworking/AFNetworking.git",
version = "4.0.0",
version = "4.0.1",
name = "AFNetworking"
)
/* TODO: Support building target dependencies? i.e `FirebaseCore` & `FirebaseSharedSwift`
Copy link
Author

Choose a reason for hiding this comment

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

Packages which have dependencies such as FirebaseRemoteConfig we will need to loop through the dependencies defined in the FIrebase Package.swift. Unless there is another way to identify the dependencies.

Copy link
Author

Choose a reason for hiding this comment

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

for instance using tool allows to output detailed information about all the linked frameworks:

otool -l ./FirebaseRemoteConfig

Load command 5
     cmd LC_LINKER_OPTION
 cmdsize 40
   count 2
  string #1 -framework
  string #2 FirebaseCore

  string #2 FirebaseCore
Load command 50
     cmd LC_LINKER_OPTION
 cmdsize 48
   count 2
  string #1 -framework
  string #2 FirebaseSharedSwift

packages(
url = "https://github.com/firebase/firebase-ios-sdk.git",
version = "10.21.0",
name = "FirebaseRemoteConfig"
)
*/
packages(
url = "https://github.com/Alamofire/Alamofire.git",
version = "5.2.0",
name = "Alamofire"
)
packages(
url = "https://github.com/malcommac/SwiftDate.git",
version = "7.0.0",
name = "SwiftDate"
)
packages(
url = "https://github.com/CombineCommunity/CombineExt.git",
version = "1.8.1",
name = "CombineExt"
)
packages(
url = "https://github.com/jozsef-vesza/AVFoundation-Combine.git",
version = "0.0.3",
name = "AVFoundationCombine"
)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions example/src/iosX64Main/kotlin/Network.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSError
import platform.Foundation.NSProgress
import platform.Foundation.NSURLSessionDataTask
Expand All @@ -8,10 +9,13 @@ import spm.AFNetworking.AFNetworkReachabilityStatusNotReachable
actual class Network actual constructor() {
actual fun hello(): String = "Hello iOS from Kotlin"

@OptIn(ExperimentalForeignApi::class)
fun manager(): String = AFHTTPSessionManager.manager().toString()

@OptIn(ExperimentalForeignApi::class)
fun status() = AFNetworkReachabilityStatusNotReachable

@OptIn(ExperimentalForeignApi::class)
fun restGet(): String {
val manager = AFHTTPSessionManager.manager()
val url = "https://httpbin.org/get"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion plugin-build/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ allprojects {
repositories {
google()
mavenCentral()
jcenter()
}

apply {
Expand Down
2 changes: 1 addition & 1 deletion plugin-build/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ plugins {
`kotlin-dsl`
}
repositories {
jcenter()
mavenCentral()
}
4 changes: 2 additions & 2 deletions plugin-build/buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ object Versions {
}

object BuildPluginsVersion {
const val DETEKT = "1.15.0"
const val KOTLIN = "1.4.30"
const val DETEKT = "1.23.6"
const val KOTLIN = "2.0.0"
const val KTLINT = "10.0.0"
const val PLUGIN_PUBLISH = "1.0.0"
const val VERSIONS_PLUGIN = "0.36.0"
Expand Down
2 changes: 1 addition & 1 deletion plugin-build/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 10 additions & 6 deletions plugin-build/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BuildPluginsVersion.KOTLIN

plugins {
kotlin("jvm")
kotlin("jvm")// version BuildPluginsVersion.KOTLIN apply false
id("java-gradle-plugin")
id("maven-publish")
id("com.gradle.plugin-publish")
Expand All @@ -21,29 +21,33 @@ dependencies {

testImplementation(TestingLib.JUNIT)
}

/*
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlin {
jvmToolchain(17)
}
*/
gradlePlugin {
plugins {
create(PluginCoordinates.ID) {
id = PluginCoordinates.ID
displayName = PluginBundle.DISPLAY_NAME
description = PluginBundle.DESCRIPTION
tags = PluginBundle.TAGS
implementationClass = PluginCoordinates.IMPLEMENTATION_CLASS
version = PluginCoordinates.VERSION
}
}
}

// Configuration Block for the Plugin Marker artifact on Plugin Central
pluginBundle {
website = PluginBundle.WEBSITE
vcsUrl = PluginBundle.VCS
tags = PluginBundle.TAGS
gradlePlugin {
website = PluginBundle.WEBSITE
vcsUrl = PluginBundle.VCS
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class SwiftPackageBuildDirs(private val project: Project) {
private val utils: File
get() = project.buildDir.resolve("spmUtils")

fun derivedDataPath(): File = root.resolve("derivedData")

fun platformRoot(family: Family): File = root.resolve(family.name)

fun packageSwiftFile(family: Family): File = platformRoot(family).resolve(PACKAGE_SWIFT_FILE)

fun packageResolvedFile(family: Family): File = platformRoot(family).resolve(PACKAGE_SWIFT_RESOLVED_FILE)

fun xcodeProjectFile(family: Family): File = platformRoot(family).resolve("${family}.$XCODEPROJECT_EXTENSION")

fun releaseDir(family: Family): File = platformRoot(family).resolve(BUILD_DIRECTORY).resolve(family.toReleaseSdk())

fun defsDir(family: Family): File = platformRoot(family).resolve(DEF_DIRECTORY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ class DependencyManager {
@Internal
override fun getName(): String = dependencyName

@get:Internal
val packageName: String
get() = url
.subSequence(url.lastIndexOf("/") + 1, url.length - ".git".length)
.toString()

fun convertToPackageContent(): String {
return """
.package(
name: "$dependencyName",
name: "$packageName",
url: "$url",
from: "$version"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ abstract class KotlinSpmPlugin : Plugin<Project> {
// Integration Swift Package dependency to Kotlin
registerInitializeSwiftPackageProjectTask(project, availablePlatforms)
registerCreatePackageSwiftFileTask(project, availablePlatforms)
registerGenerateXcodeTask(project, availablePlatforms)
registerBuildFrameworksTask(project, availablePlatforms)
registerGenerateDefFileTask(project, availablePlatforms)
registerConfigureLinkerOptionsTask(project, availablePlatforms, multiplatformExtension)
Expand Down Expand Up @@ -59,11 +58,17 @@ abstract class KotlinSpmPlugin : Plugin<Project> {
platforms: NamedDomainObjectContainer<PlatformManager.SwiftPackageManager>,
) {
platforms.all { platform ->
val cleanSwiftPackageTask = project.tasks.named(
"$CLEAN_SWIFT_PACKAGE_PROJECT_TASK_NAME${platform.family}",
CleanSwiftPackageProjectTask::class.java
)

project.tasks.register(
"$INITIALIZE_SWIFT_PACKAGE_PROJECT_TASK_NAME${platform.family}",
InitializeSwiftPackageProjectTask::class.java
) { task ->
task.platformFamily.set(platform.family)
task.dependsOn(cleanSwiftPackageTask)
}
}
}
Expand Down Expand Up @@ -91,7 +96,7 @@ abstract class KotlinSpmPlugin : Plugin<Project> {
}
}

private fun registerGenerateXcodeTask(
private fun registerBuildFrameworksTask(
project: Project,
platforms: NamedDomainObjectContainer<PlatformManager.SwiftPackageManager>,
) {
Expand All @@ -102,48 +107,25 @@ abstract class KotlinSpmPlugin : Plugin<Project> {
)

project.tasks.register(
"$GENERATE_XCODE_TASK_NAME${platform.family}",
GenerateXcodeTask::class.java
"$BUILD_FRAMEWORK_TASK_NAME${platform.family}",
BuildFrameworksTask::class.java
) { task ->
task.platformFamily.set(platform.family)
task.platformDependencies.set(platform.dependenciesContainer.map { it.name })

task.dependsOn(createPackageSwiftFileTask)
}
}
}

private fun registerBuildFrameworksTask(
project: Project,
platforms: NamedDomainObjectContainer<PlatformManager.SwiftPackageManager>,
) {
platforms.all { platform ->
val generateXcodeTask = project.tasks.named(
"$GENERATE_XCODE_TASK_NAME${platform.family}",
GenerateXcodeTask::class.java
)

platform.dependenciesContainer.all { dependency ->
project.tasks.register(
"$BUILD_FRAMEWORK_TASK_NAME${platform.family}${dependency.dependencyName}",
BuildFrameworksTask::class.java
) { task ->
task.platformFamily.set(platform.family)
task.platformDependency.set(dependency.dependencyName)

task.dependsOn(generateXcodeTask)
}
}
}
}

private fun registerGenerateDefFileTask(
project: Project,
platforms: NamedDomainObjectContainer<PlatformManager.SwiftPackageManager>,
) {
platforms.all { platform ->
platform.dependenciesContainer.all { dependency ->
val buildFrameworkTask = project.tasks.named(
"$BUILD_FRAMEWORK_TASK_NAME${platform.family}${dependency.dependencyName}",
"$BUILD_FRAMEWORK_TASK_NAME${platform.family}",
BuildFrameworksTask::class.java
)

Expand Down Expand Up @@ -172,7 +154,7 @@ abstract class KotlinSpmPlugin : Plugin<Project> {

platform.dependenciesContainer.all { dependency ->
val buildFrameworkTask = project.tasks.named(
"$BUILD_FRAMEWORK_TASK_NAME${platform.family}${dependency.dependencyName}",
"$BUILD_FRAMEWORK_TASK_NAME${platform.family}",
BuildFrameworksTask::class.java
)

Expand Down
Loading