GithubHelp home page GithubHelp logo

ge-org / multiplatform-swiftpackage Goto Github PK

View Code? Open in Web Editor NEW
335.0 11.0 49.0 129 KB

Gradle plugin that generates a Swift Package Manager manifest and an XCFramework to distribute a Kotlin Multiplatform library for Apple platforms.

License: Apache License 2.0

Kotlin 100.00%
kotlin-multiplatform gradle-plugin swift-package-manager xcframework ios macos watchos tvos kotlin swift gradle

multiplatform-swiftpackage's Introduction

Multiplatform Swift Package

Build Status

This is a Gradle plugin for Kotlin Multiplatform projects that generates an XCFramework for your native Apple targets and creates a matching Package.swift file to distribute it as a binary target.

To distribute the framework a ZIP file containing it will be created and referenced from the Package. You can upload the ZIP file to your package registry so that SPM can download it.

Prerequisites

  • XCode version 12.0+
  • Gradle version 6.0+

Installing

The plugin is published on Maven central. Add it to the plugins block in the Gradle build file.

plugins {
  id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3"
}

Execution

The plugin adds two Gradle tasks to your project.

  • ./gradlew createSwiftPackage

    Creates the XCFramework, ZIP file and Package.swift

  • ./gradlew createXCFramework

    Creates only the XCFramework

Configuration

Generation of the Package and XCFramework can be configured using the plugin's DSL. Add the configuration to the Gradle build file.

This is a complete example of the required configuration. All available options will be explained in the following sections.

multiplatformSwiftPackage {
    swiftToolsVersion("5.3")
    targetPlatforms {
      iOS { v("13") }
    }
}

Package Name

By default, the name of the Swift package will be the base name of the first framework found in the project. However, you can declare a different name for the package. This might be useful if your frameworks have different base names, and you want your package to have a common name.

packageName("MyAwesomeKit")

Hint: If the cocoapods plugin is applied the name of the package will default to the value assigned to the frameworkName property. Otherwise, the value of the baseName property of the framework configuration will be used.

Output Directory

By default, the plugin will write all files into the swiftpackage folder in the project directory. You can configure the output folder by providing a File object pointing to it.

outputDirectory(File(projectDir, "swiftpackage"))

Swift Tools Version

The first line of every Package.swift file is a header declaring the Swift tools version required by the package. To set the version use the following configuration and provide the version your XCode project supports.

swiftToolsVersion("5.3")

Distribution Mode

Swift packages can distribute binary targets either via the local file system or via a remote ZIP file. Depending on your requirements (e.g. local development or CI) use one of the following configurations.

Local distribution

distributionMode { local() }

Remote distribution

Provide a URL where the ZIP file containing the XCFramework is located. This should point to the root directory and not to the ZIP file itself.

// correct
distributionMode { remote("https://example.com") }

// wrong
distributionMode { remote("https://example.com/MyLib.zip") }

ZIP File Name

By default, the name of the generated ZIP file consists of the package name concatenated with the project's version. You can configure the name by setting a custom value. The .zip file extension will be added during the build and should be omitted here.

zipFileName("MyAwesomeKit")

Build Configuration

Apple frameworks can be built with different configurations. By default, these are release and debug. However, you can also create your own configurations.

Default

buildConfiguration { release() }
// or
buildConfiguration { debug() }

Custom

buildConfiguration { named("staging") }

Target Platforms

The main feature of an XCFramework is packaging multiple architectures for the same platform. This is great since it allows distributing e.g. iOS builds for both the physical device, and the simulator in one package.

Swift packages require declaring the minimum supported version for each platform. Therefore, you need to configure both the architectures for each platform and the version.

You can either declare all target architectures specifically or add all architectures of a platform at once.

targetPlatforms {
  // all iOS targets (== device and simulator) with minimum version 13
  iOS { v("13") }

  // macOS with minimum version 10.0
  targets("macosX64") { v("10.0") }
}

Note: If you are using Groovy for the build script the target names must be passed as a list.

targetPlatforms {
  // the catch-all DSL works the same in Groovy and Kotlin
  iOS { v("13") }

  // however, Groovy requires a list when the targets() DSL is used
  targets(['macosX64']) { v('10.0') }
}

Available platform shortcuts are:

  • iOS { v("xxx") }
  • tvOS { v("xxx") }
  • macOS { v("xxx") }
  • watchOS { v("xxx") }

Further Reading

To learn more about the Swift Package Manager I recommend reading the following resources.

License

Copyright 2020 Georg Dresler

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

multiplatform-swiftpackage's People

Contributors

ge-org avatar justinmkaufman avatar netroy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multiplatform-swiftpackage's Issues

Allow conditionally applying this plugin

I'd like to do something like this

import com.chromaticnoise.multiplatformswiftpackage.MultiplatformSwiftPackagePlugin

val isCI = System.getenv("CI") == "true"

plugins {
  kotlin("multiplatform") version "1.4.20"
  id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.0" apply false
}

kotlin {
  jvm()
  ios()
}

if (isCI) {
  apply(plugin = "com.chromaticnoise.multiplatform-swiftpackage")
  configure<MultiplatformSwiftPackagePlugin> {
    multiplatformSwiftPackage {
      packageName("MyFramework")
      swiftToolsVersion("5.3")
      targetPlatforms {
        iOS { v("13.0") }
      }
    }
  }
}

But , since MultiplatformSwiftPackagePlugin is marked a internal, I'm unable to do this.
Because of this anyone working on the jvm part of our library has to chose between removing this plugin, or setting up xcode.

If it's okay, I can send a pull-request to make the plugin class public.

remote distributionMode

This is probably more a question rather than issue but wasn't clear from docs how remote distributionMode should work. If I have package hosted for example on Github should this allow uploading generated artifacts to there? btw wrote short post on experience using plugin so far (in case anything you think isn't quite right there or should be clarified ) https://johnoreilly.dev/posts/kotlinmultiplatform-swift-package/

Missing path from XCFramework as defined by 'DebugSymbolsPath' in its `Info.plist` file

Hello,

Nice plugin but when adding the Repo link, building the project fails with this error
Missing path (/.../Library/Developer/Xcode/DerivedData/Test-eqqqbrehuzabdnegojwzdecqruxe/SourcePackages/checkouts/MyFrameworkName/MyFrameworkName.xcframework/ios-x86_64-simulator/dSYMs) Missing path from XCFramework 'MyFrameworkName.xcframework' as defined by 'DebugSymbolsPath' in its Info.plist file
What I'm doing wrong ?

Adding this plugin breaks the project

First of all, thanks for building this plugin!

I was looking for a simple solution to build an XCFramework for my project, but unfortunately I'm having an issue as soon as I add the plugin reference.
I have a medium-sized project that targets JVM, JS and iOS, but to keep it simple, I created a new project using the IntelliJ wizard and I'm seeing the same issue.

As soon as I add your plugin, the entire project "breaks" and it is no longer recognized as Multiplatform project. All the platform modules disappear and I don't see any of the usual Gradle tasks anymore.

Screenshot 2021-07-15 at 14 16 26

This is my build.gradle.kts (I am using Kotlin 1.5.21 and Gradle 6.8:

plugins {
    kotlin("multiplatform") version "1.5.21"
    id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3"
}

group = "me.alex"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

kotlin {
    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = "1.8"
        }
        testRuns["test"].executionTask.configure {
            useJUnit()
        }
    }
    js(LEGACY) {
        browser {
            commonWebpackConfig {
                cssSupport.enabled = true
            }
        }
    }
    ios {
        binaries {
            framework {
                baseName = "library"
            }
        }
    }
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val jvmMain by getting
        val jvmTest by getting
        val jsMain by getting
        val jsTest by getting
        val iosMain by getting
        val iosTest by getting
    }
}

As said, this is a brand new project, so the configuration should be pretty standard.

Is this a known issue? Am I using versions of Kotlin or Gradle that are not compatible with this plugin?

createXCFramework / createSwiftPackage task FAILED

> Task :xxx:createXCFramework FAILED
Both watchos-arm64_32 and watchos-armv7k represent two equivalent library definitions.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dryrun:createXCFramework'.
> Process 'command 'xcodebuild'' finished with non-zero exit value 70

Xcode version: Version 12.5.1 (12E507) on Intel Mackbook Pro running macOS Big Sur.

A snippet of the project build.gradle.kts

plugins {
    id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3"
}

kotlin {
    ios()
    watchos()
    tvos()
    macosX64()
}
multiplatformSwiftPackage {
    swiftToolsVersion("5.3")
    packageName(project.name)
    outputDirectory(File(projectDir, "swiftpackage"))
    targetPlatforms {
        iOS { v("5") }
        tvOS { v("9") }
        macOS { v("10") }
        watchOS { v("4") }
    }
}

It is working only if remove the watchOS target.
Looks like, this is related to this issue: https://developer.apple.com/forums/thread/666335

Plugin seems to ignore the target version

Using this plugin in our project with the following setup:

    multiplatformSwiftPackage {
        swiftToolsVersion("5.4")
        packageName("Common")
        zipFileName("Common")
        outputDirectory(File(rootDir, "/app-ios/CommonFramework"))
        distributionMode { local() }
        targetPlatforms {
            iOS { v("13") }
        }
    }

and when invoking the createSwiftPackage gradle task the framework is created successfully and the ios app can be built without problems.
BUT as soon as we try to upload the app an error arise:

ERROR ITMS-90208: "Invalid Bundle. The bundle <AppName> Alpha.app/Frameworks/Common.framework does not support the minimum OS Version specified in the Info.plist

And inspecting the created Info.plist
the /app-ios/CommonFramework/Common.xcframework/ios-arm64/Common.framework/Info.plist file contains the following:

<key>MinimumOSVersion</key>
<string>9.0</string>

Which is a problem for us because the KMP module uses some native dependencies which compiled against min 13.0 version that's why we are setting the target version with the plugin.


As a workaround right now we are manually modifying the affected Info.plist file to match the version but it would be better if the plugin would respect the setting and automatically do that for us.

While building for Mac Catalyst, no library for this platform was found

Hi,
I'm using this framework to generate xcframework for ios/macos. Work on ios, but for mac I receive an error in Xcode:

While building for Mac Catalyst, no library for this platform was found in '.../shared/swiftpackage/KMMProject.xcframework'.

Configuration:

multiplatformSwiftPackage {
    packageName("KMMProject")
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("13") }
        targets("macosX64") { v("10.0") }
    }
}
val packForXcode by tasks.creating(Sync::class) {
    group = "build"
    val targetDir = File(buildDir, "xcode-frameworks")
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"

    val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
    val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
    val frameworkIos = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)

    inputs.property("mode", mode)
    dependsOn(frameworkIos.linkTask)
    from({ frameworkIos.outputDirectory })
    into(targetDir)

    val frameworkMac = kotlin.targets.getByName<KotlinNativeTarget>("macOS").binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(frameworkMac.linkTask)
    from({ frameworkMac.outputDirectory })
    into(targetDir)
}

Is there any fix for that?

Fat multiplatform framework

Hey,

I have another issue bundling a fat framework.

I added a task called universalFrameworkRelease that bunldes simulator and native ios builds. Is it possible to support as well?

Not sure, but maybe it's optional to add a bunch of additional paths that are used for more sift packages.

additionalFrameworkPaths {
   path = "build/bin/universal/release"
   name = "universal"
}

Here is an example: https://github.com/sebarthel89/example-kmp-swift-package

Missing cocoapods dependency in XCFramework

Hey!

Thanks for the repo. Unfortunately, we ran into an issue with a cocoapods dependency, which is not present in the final XCFramework. Is there any way to add this dependency to the binary?

cocoapods {
        // Configure fields required by CocoaPods.
        summary = ""
        homepage = ""
        // You can change the name of the produced framework.
        // By default, it is the name of the Gradle project.
        ios.deploymentTarget = "12"

        pod("Mixpanel")
    }
multiplatformSwiftPackage {
        swiftToolsVersion("5.3")
        targetPlatforms {
            iOS { v("12") }
            macOS { v("11") }
        }
        outputDirectory(File(projectDir, ""))

    }

Cross link to #kotlin-native channel

import module name

I'm using following config (in https://github.com/joreilly/PeopleInSpace).... PeopleInSpace is being used for name of package but I still need to use import common in Swift code....I'm probably missing something obvious but is there way to change that name (or does gradle module name also need to change?)

multiplatformSwiftPackage {
    packageName("PeopleInSpace")
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("13") }
    }
}

Adopting XCFramework of new kotlin version

Is it possible to adopt the assembleXCFramework gradle task instead of the current createXCFramework task in the project? Is it possible to migrate to that, which is available since kotlin 1.6.0?

I've made a fork which already contains a possible setup.

The only thing that is changed is that the plugin uses the assembleXCFramework task and then copies the generated files to the outputDirectory.

Currently I cannot make a pull request due to the lack of M1 support in the latest version. There is already an open pull request for this by @jizoquval.

Let me know what I can do to help out.

Couldn't import my package with it's name

I used createSwiftPackage command to create swift package and it is successfully created. (Thank you for this great library)

multiplatformSwiftPackage { packageName("VLShared") swiftToolsVersion("5.3") targetPlatforms { iOS { v("13") } } outputDirectory(File(rootDir, "/")) }

But in my main swift project I need to import as "import common" to use package, I want to able to import package with my package name.

How can I solve this problem?

Issue with Checksum

My question is not directly related to this great plugin, but I use it build a framework, the zip and the package.swift.
I put that on a gitlab repo, with the download url pointing to a permalink of the zip file.

When I tried to setup my ios project with this dependency, I get an issue of checksum !
When I download the zip file, the checksum is the good one.

Any idea ?

Error while uploading to AppStore

Hey

I have a setup where, for a new release, I run ./gradlew createXCFramework and commit the .xcframework on my release branch.
This works pretty well, however, when building an IPA and trying to submit to the store, I get the following error:

[Transporter Error Output]: ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'MyApp.app/Frameworks/mysdk.framework/mysdk' is not permitted. Your app can't contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the iOS app bundle structure."

build.gradle:

multiplatformSwiftPackage {
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("12") }
    }
    outputDirectory(File(".."))
}

Any idea what could cause this?

Does not work with KMP 1.4.20

Hi,

thanks for this plugin, it looks exactly what I am looking for.

Unfortunately, I can't get the tasks run successfully with a fresh KMP project version 1.4.20.

My settings:

multiplatformSwiftPackage {
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("13") }
    }
}

I get 2 errros:

  1. Package name is invalid: null
* What went wrong:
A problem occurred configuring root project 'centralized-key-value-library'.
> Could not create task ':createXCFramework'.
   > * Package name is invalid: null
       Either declare the base name of your frameworks or use a non-empty package name.

I can fix this by setting it manually:

multiplatformSwiftPackage {
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("13") }
    }
    packageName(project.name)
}
  1. at least one framework or library must be specified.
> Task :createXCFramework FAILED
error: at least one framework or library must be specified

I could not fix this one on my own. Maybe some internal structure has been changed?

Build failing: symbol(s) not found for architecture arm64

I'm trying to create a SPM from a module which contains a simple object file.

object Strings {
    val TitleTalks = "Talks"
    val TabTalks = "Talks"
    val TabChannels = "Channel"
    val TabProfile = "Profile"
}

complete build.gradle looks like this

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3"
}

kotlin {
    multiplatformSwiftPackage {
        swiftToolsVersion("5.3")
        targetPlatforms {
            iOS { v("13") }
        }
        packageName("AppStrings")
        outputDirectory(File(projectDir, "spm/strings"))
    }

    android()

    ios {
        binaries {
            framework {
                baseName = "strings"
                isStatic = false
            }
        }
    }

    iosSimulatorArm64 {
        binaries {
            framework {
                baseName = "strings"
                isStatic = false
            }
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(libs.moko.resources.core)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation(libs.moko.resources.compose)
            }
        }
        val androidTest by getting

        val iosMain by getting
        val iosTest by getting
        val iosSimulatorArm64Main by getting {
            dependsOn(iosMain)
        }
        val iosSimulatorArm64Test by getting {
            dependsOn(iosTest)
        }
    }
}

android {..}

But I always get the following build error whenever I try accessing Strings.xx inside my Swift file

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_StringsStrings", referenced from:
      objc-class-ref in ContentView.o
ld: symbol(s) not found for architecture arm64

スクリーンショット 2022-09-07 8 58 21

Using the Gradle Build Cache

It would be of great convenience if the Gradle task would declare its inputs explicitly, and declare its outputs as cacheable, so one can use the Gradle Build Cache to avoid waiting for builds with no (Kotlin) code changes.

Local created Swift Package cannot using locally

Hi everyone!
multiplatformSwiftPackage { outputDirectory(File(projectDir,"presentationPackage")) packageName(project.name) swiftToolsVersion("5.3") targetPlatforms { iOS { v("13") } } distributionMode { local() } }

This is my config for create swift package, it's ok when using remote package(publish to github). But when i add to package manager from local file it not working, import in swift get "No such module " error

Generate arm64 swift package

Below is the config for genrating swift package:

multiplatformSwiftPackage {
        packageName("shared")
        swiftToolsVersion("5.3")
        targetPlatforms {
            iOS { v("13") }
        }
    }

what's happening here is generating package which is x86_64 but it will not run on every xcode what if i want to genrate specific framework ?? basically i want arm64 sitable pacakge to be generated.

Create XCFramework for arm simulator

Hi guys, your plugin is awesome! But I stuck with one problem. Here is my configuration :

multiplatformSwiftPackage {
    packageName("XXX")
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("13") }
    }
}

createSwiftPackage task generates Swift package with two targets ios-arm64 and ios-x86_64-simulator, this works great on Intel Mac simulators and iPhones, but this not works on Apple silicone arm simulator.

So is it possible to generate target for Arm simulator ?

Improve README

  • Add table of contents
  • Add links to 'Further Reading' about XCFramework
  • Sort configuration options alphabetically?
  • Add Groovy syntax ?

Build swift package for simulator and device does not work anymore

Hi guys,
I really love this framework - it is awesome.

The only issue I run into now is, when using the newest android studio canary build 15 of android studio with the new build and compile configurations and options and preliminary support for Apple Silicon, only an ios-x86_64-simulator framework is generated. The ios-arm64 framework is missing. The release notes for the new android studio: https://androidstudio.googleblog.com/2021/04/android-studio-arctic-fox-canary-15.html

The packForXCode looks like this:

val packForXcode by tasks.creating(Sync::class) {
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val framework = kotlin.targets.getByName<KotlinNativeTarget>("ios").binaries.getFramework(mode)
    val targetDir = File(buildDir, "xcode-frameworks")

    group = "build"
    dependsOn(framework.linkTask)
    inputs.property("mode", mode)

    from({ framework.outputDirectory })
    into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)

The further configuration in the kotlin {} block for iOS looks like this atm:

kotlin {
    android() {
        publishAllLibraryVariants()
    }

    val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
        if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
            :: iosArm64
        else
            :: iosX64

    iosTarget("ios") {
        binaries {
            framework {
                baseName = "my-shared"
            }
        }
    }

    val ktorVersion = "1.4.0"
    .
    .
    .
}

And my configuration for this framework looks like this:

multiplatformSwiftPackage {
    val spmPath = "<my-spm-path>"

    swiftToolsVersion("5.3")

    spmPath?.apply {
        outputDirectory(File(spmPath))
        targetPlatforms {
            iOS { v("14") }
        }
    }
}

Can you please help me with that? What can I change to make that work? I use the version 2.0.3 of your plugin.

Enabling Bitcode for archiving

Hello, I'm seeing the following error on Xcode Archive:

ld: bitcode bundle could not be generated because '/xxxx/BuildProductsPath/Release-iphoneos/common.framework/common' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/xxxx/BuildProductsPath/Release-iphoneos/common.framework/common' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

AFAIK, SPM requires all frameworks to have bitcode enabled. Is there a way we could do so ? I couldn't find any info in the documentation or implementation (cf. https://github.com/ge-org/multiplatform-swiftpackage/blob/master/src/main/kotlin/com/chromaticnoise/multiplatformswiftpackage/task/CreateXCFrameworkTask.kt).
I'm not sure if I'm missing something, I think we would need to add some bitcode related flags in the xcodebuild command.

Cannot Be Used With Groovy DSL

Due to the way Kotlin and Groovy closures interop the plugin cannot be used if the build script is written with the Groovy DSL.

Middle nativeMain module with specific iosMain and macOSMain fails.

Not sure if this is expected, do have a project with a middle nativeMain source set for specific iosMain & macOSMain source set

- commonMain
    - nativeMain
        - iosMain
        - macOSMain

build.gradle.kts

    macosX64("native")
    macosX64("macOS") {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }
    ios() {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }

    ...

    val nativeMain by getting {
        dependencies {
            implementation(libs.sqlDelight.native)
            implementation(libs.ktor.client.core)
            implementation(libs.coroutines.core)
            implementation(libs.multiplatformSettings.common)
        }
    }
    val iosMain by getting {
        dependsOn(nativeMain)
        dependencies {
            implementation(libs.ktor.client.ios)
            val coroutineCore = libs.coroutines.core.get()
            implementation("${coroutineCore.module.group}:${coroutineCore.module.name}:${coroutineCore.versionConstraint.displayName}") {
                version {
                    strictly(libs.versions.coroutines.native.get())
                }
            }
        }
    }
    val macOSMain by getting {
        dependsOn(nativeMain)
        dependencies {
            implementation("io.ktor:ktor-client-curl:2.0.0-beta-1")
        }
    }

...

multiplatformSwiftPackage {
    packageName("sharedValkyrie")
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("13") }
        macOS { v("11") }
    }
}

Inside commonMain I have multiple expect class ... that are defined only in iosMain and macOSMain and not in nativeMain, such as UserAgent strings, platform name, etc. After gradle sync, those expect classes are solved properly without any errors but when running createSwiftPackage gradle task, I receive that there are no expect declarations in nativeMain module:
Expected class 'Platform' has no actual declaration in module <mySharedModule> for Native

Shouldn't just execute compileKotlinIos and compileKotlinMacOS and skip compileKotlinNative?
Is there a workaround to do this?

After cocopod pod new library , createSwiftPackage fail

I can compile and build the project with this build.gradle

build.gradle

    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()
    cocoapods {
        val properties = Properties()
        project.rootProject.file("publish.properties")
            .takeIf { it.exists() }
            ?.run { properties.load(inputStream()) }
        val urlString = properties.getProperty("maven.url")

        summary = "SHKP the point shared module"
        homepage = "Link to the Shared Module homepage"
        version = libraryVersion
        ios.deploymentTarget = "14.1"
        source = urlString
        framework {
            baseName = "thePointShare"
            isStatic = false
        }
        pod("FirebaseAnalytics")
    }
    multiplatformSwiftPackage {
        packageName("ThePointShared")
        swiftToolsVersion("5.3")
        targetPlatforms {
            iOS { v("13") }
        }
        outputDirectory(File(rootDir, "/"))
    }

logcat

Undefined symbols for architecture arm64:
  "_FIRFirebaseVersion", referenced from:
      +[FIRAnalytics topLevelVersion] in FirebaseAnalytics(FIRAnalytics.o)
  "_FIRInstallationIDDidChangeNotification", referenced from:
      +[FIRAnalytics observeFirebaseInstallationIDChanges] in FirebaseAnalytics(FIRAnalytics.o)
  "_GULIsLoggableLevel", referenced from:
      -[APMMonitor isLoggableLevel:] in GoogleAppMeasurement(APMMonitor.o)
  "_GULLogBasic", referenced from:
      -[APMASLLogger logMessage:logTag:messageCode:withLogLevel:] in GoogleAppMeasurement(APMASLLogger.o)
  "_GULLogError", referenced from:
  ..............
### But I cannot create swift package, is anyone solved?

Building only xcframework without swifttools

Hi there! Great library, thank you for taking the time to start it.

For my use case, I'm only interested in generating xcframeworks.

This means that when setting up the plugin, I'm required to include configuration for swift packages, even though I don't build them.

In other words, in my Gradle file, I need to include the following lines:

multiplatformSwiftPackage {
   . . .
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("13") }
    }
}

But really, I'm only interested in the createXCFramework / createZipFile tasks.

If I remove these lines and run the createXCFramework task, I receive the following error:

> Could not create task ':lib:createXCFramework'.
   > * Swift tools version is missing.
       Declare it by adding your Swift version to the plugin configuration block.

     * Target platforms are missing.
       Declare at least one platform by adding it to the plugin configuration block.

In theory, could these tasks exist without defining those configuration lines?
If so, I would be willing to take a stab at implementing that change 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.