Giter VIP home page Giter VIP logo

kotlincocoapods's Introduction

Kotlin Cocoapods Extended

2021 Note

This project is archived. It was a fork of the "official" plugin. Originally we used it to allow static frameworks and other features, but you can do that now with the "official" plugin. We recommend moving to the Kotlin plugin instead.

2021 Note End...

This plugin is a fork of the Kotlin Multiplatform plugin's cocoapods support. Cocoapods support bundled into the KMP Gradle plugin is somewhat limited, and trying to change how that works is difficult because it is bundled with the main plugin and the main Kotlin project itself. This fork has pulled out just the Cocoapods support and changed the namespace so it won't clash.

Features

The main Cocoapods plugin configures the Xcode framework that is built, and does not support all of the configuration options available when you configure the framework manually. This means you'll get a static framework, which can't be debugged, and will prevent being able to add multiple frameworks to a single project. There has also been difficulty configuring dependencies to be included in the generated header.

Not all of this is supported now, but by forking and removing the Cocoapods plugin, it will be much easier to add features as desired.

Usage

See Releases for current version.

Add the following to the buildscript section:

buildscript {
    dependencies {
        classpath 'co.touchlab:kotlinnativecocoapods:0.11'
    }
}

Apply the plugin in the shared code project, and configure the plugin

plugins {
  id("co.touchlab.native.cocoapods")
}

kotlin {
    cocoapodsext {
      summary = "Common library for the KaMP starter kit"
      homepage = "https://github.com/touchlab/KaMPStarter"
      isStatic = false
    }
}

kotlincocoapods's People

Contributors

ben-whit-ley avatar extmkv avatar jakewharton avatar kpgalligan avatar russhwolf avatar samhill303 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

Watchers

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

kotlincocoapods's Issues

Importing pods does not work when `isStatic = false`

I have added some cocoapods to the kmp code by using the plugin as such:

cocoapodsext {
        summary = "..."
        homepage = "..."
        framework {
            isStatic = false
            export(Deps.kermit)
            transitiveExport = true
        }

        pod("Socket.IO-Client-Swift", "~> 15.2.0", "SocketIO")
    }

however, when running I'm getting an error:

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

there's not a lot of information on how to use this, did I miss something?

Fails silently when adding dependencies

In my project, I added CouchbaseLite pod dependency, it gradle syncs correctly but after that I can't find the dependency. In my shared grade file, I have the following snippet

cocoapodsext {
        summary = "TBC"
        homepage = "TBC"
        pod("AFNetworking")
        pod("CouchbaseLite")
    }

After gradle sync (success), I can only find the AFNetworking but CouchbaseLite doesn't work. What could be wrong and how can I fix it? Thanks

Edit: I have tried several ios libraries with this plugin and even a wrong dependency like pod("fjsljfa;fnajfd") would gradle sync correctly. So it seems like errors are failing silently.

generateDummyFramework: resource must not be null

Hey all! Thanks for maintaining this plugin. I wanted to be able to export dependencies and use a dynamic framework for my project so this looks great.

I am having a problem integrating the plugin. For both my project and a clean clone of https://github.com/touchlab/KaMPKit I am unable to run the generateDummyFramework gradle task, which causes the podspec task to fail. I am using the Android Studio 4.2 Preview to work around some Big Sur issues. Here is a stacktrace:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':shared:generateDummyFramework'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:200)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:198)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:179)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
	at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.IllegalStateException: resource must not be null
	at co.touchlab.kotlin.gradle.tasks.DummyFrameworkTask.copyResource(CocoapodsTasks.kt:159)
	at co.touchlab.kotlin.gradle.tasks.DummyFrameworkTask.copyFrameworkFile(CocoapodsTasks.kt:174)
	at co.touchlab.kotlin.gradle.tasks.DummyFrameworkTask.copyFrameworkFile$default(CocoapodsTasks.kt:173)
	at co.touchlab.kotlin.gradle.tasks.DummyFrameworkTask.create(CocoapodsTasks.kt:200)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...

Not sure why the dummy task is failing, it's working okay with the upstream Cocoapods plugin. Please let me know if there is any other information you need to help with debugging. Thanks!

Support for frameworkName property

The multiplatform cocoapods plugin supports the frameworkName property, could this be added?

cocoapodsext {
    frameworkName = "frameworkname"
}

fatal error: module 'PromisesSwift' not found

Hi, I'm trying to add this pod to my project using the following code:

cocoapodsext {
        summary = "Common library for the KaMP starter kit"
        homepage = "https://github.com/touchlab/KaMPKit"
        framework {
            isStatic = false
            export(Deps.kermit)
            transitiveExport = true
        }
        pod("PromisesSwift")
    }

and I'm getting the following error:

> Task :shared:cinteropPromisesSwiftIos FAILED
Exception in thread "main" java.lang.Error: /var/folders/y7/yrztdhk977d4nh8t12ks9bkc0000gn/T/1754490655123836472.m:1:9: fatal error: module 'PromisesSwift' not found
	at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
	at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68)
	at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:506)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:264)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:74)
	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
	at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:41)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:cinteropPromisesSwiftIos'.

I've tried adding version, and then also module name, but nothing changed. I also get the same error adding frameworks like Alamofire or AFNetworking, I would say that I'm not able to add any pod at all. What am I doing wrong?

Ref: touchlab/KaMPKit#192

Error during a build with createPodspecGenerationTask() method

KotlinCocoapods v0.9

Caused by: java.lang.IllegalArgumentException: Collection has more than one element.
at kotlin.collections.CollectionsKt___CollectionsKt.single(_Collections.kt:506)
at co.touchlab.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.createPodspecGenerationTask(KotlinCocoapodsPlugin.kt:170)
at co.touchlab.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.access$createPodspecGenerationTask(KotlinCocoapodsPlugin.kt:46)
at co.touchlab.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin$apply$$inlined$with$lambda$1$1.execute(KotlinCocoapodsPlugin.kt:270)
at co.touchlab.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin$apply$$inlined$with$lambda$1$1.execute(KotlinCocoapodsPlugin.kt:46)

Maybe it's related to that I have two native apple targets..iOS and tvOS

The build speed

When I change the Kotlin native code , it will cost a lot of time to finish the build task (Xcode)

task named :shared:linkDebugFrameworkIos will cost about two minutes

any advice to improve the build speed ?

Dynamic framework rebuild needs to be cleaned

When the framework is static, you can change Kotlin, rebuild in Xcode, and the change will be seen. When the framework is dynamic, Kotlin will be rebuilt, but you'll only see the change when you clean the build folder.

Ideally changing Kotlin and running won't need a clean build.

Ability To Update Framework Name

It would be nice if the frameworkName attribute was exposed as a mutable field like the jetbrains version. It's kind of annoying that the framework is just called shared in XCode and having import shared is a bit ambiguous in the source code.

How to configure external libraries?

I already contacted the Kotlin team here and here about the problem and they told me to ask here.

I am using the KaMPKit template to add SQLCipher to my project which already uses moko-resources. Before adding your custom cocoapods plugin, everything worked fine and I could get the resources under iOS. Now KaMPKit uses your cocoapods plugin fork. With these changes, I can't make it work again. Either the project does not build at all because it can't find the SQLCiper headers or it crahes at runtime as the bundle is not found.

Could you please have a look at my example project so see if I miss any configuration step? Thanks in advance!

Cannot configure the framework

I did setup the cocoapodsext plugin correctly but I can't seem to configure the iOS framework correctly.

cocoapodsext {
        summary = "Common shared project"
        homepage = "https://github.com/sebleclerc"
        framework {
            isStatic = false
            embedBitcode = 'ENABLE'
        }
    }

I get this error: Could not set unknown property 'isStatic' for object of type co.touchlab.kotlin.gradle.plugin.cocoapods.CocoapodsExtension. Same for the embedBitcode.

Anything I am missing? Is this something that should be possible?

Thanks!

Can't add pods to iosMain source set

While using "co.touchlab.native.cocoapods" plugin in project, I tried to add AFNetworking pod for iosMain source set by doing this:

cocoapodsext {
    summary = Podspec.summary
    homepage = Podspec.homepage
    isStatic = false
    pod(name = "AFNetworking", version = "~> 4.0")
}

When run pod install and tried to rebuild project in Xcode it failed with stacktrace:

> Task :common:cinteropAFNetworkingIos FAILED
Exception in thread "main" java.lang.Error: /var/folders/tx/90l_s4xn5hz1g4q3bnq_d1400000gn/T/tmp9058487730325846355.m:1:9: fatal error: module 'AFNetworking' not found
	at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
	at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:67)
	at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:13)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:446)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:228)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:46)
	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:44)
	at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)

Jetbrains documentation on this: https://kotlinlang.org/docs/reference/native/cocoapods.html#interoperability

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.