Skip to content

Instantly share code, notes, and snippets.

View Ribesg's full-sized avatar
🇫🇷

Gael Ribes Ribesg

🇫🇷
View GitHub Profile
@Ribesg
Ribesg / !README.md
Last active June 20, 2022 15:00
How to use a Kotlin MPP library depending on an iOS Framework in a XCode iOS App

This gist demonstrates how to use a Kotlin MPP library which depends on an iOS Framework in a native iOS application (XCode project).

First, see [how the Kotlin MPP Library is built][lib-build].

Key ideas:

  • We can currently only use a single Kotlin MPP library in an iOS project, so we need to create a MPP project local to our iOS XCode project whose sole purpose is to aggregate multiple MPP dependencies into a single Framework.
  • To keep our working environment clean, we create the gradle project in a subdirectory instead of at the root of our iOS XCode project. I name my subdirectory mpp.
  • We need to have the Frameworks used by our dependencies locally, as we only have bindings provided by the cinterop klibs, so we use [Carthage] again.
  • As the only goal of our gradle project is to create a Framework, we only use ios* targets.
  • Our project won't have any source code, but we NEED at least one source file, or Gradle will refuse to build anything, returning just a rude NO-SOURCE. Just create
@Ribesg
Ribesg / !README.md
Last active June 20, 2022 15:00
How to use an iOS Framework in a Kotlin MPP library published to Maven

This gist demonstrates how to build a Kotlin MPP library so that the iOS sourceSet depends on and uses an iOS Framework as a dependency.

Key ideas:

  • We use [Carthage] to retrieve/build the iOS Framework.
  • We use [cinterop] to create bindings allowing us to use the iOS Framework from Kotlin
  • We build and publish the library using ./gradlew publishToMavenLocal
  • We build and publish [klib] artifacts for both the arm64 and x86_64 architectures, you can easily add arm32 if you need.
  • Note that the publish process also publishes a cinterop klib artifact, allowing dependents to also know about the iOS Framework headers.

You can find a gist explaining how to use such library in an iOS app [here][ios-app].

@Ribesg
Ribesg / doge.kt
Last active August 29, 2015 14:22
import kotlin.platform.platformStatic as such
such fun wow() = println("very doge")
@dumptruckman
dumptruckman / ArgumentJoiner.java
Last active December 21, 2015 17:59
A utility class that will take an array of string arguments and return an array where any arguments surrounded in quotes (single or double) are joined into single strings.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* A utility which will join together arguments based on the use of quotations.
*/
public class ArgumentJoiner {
/**
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"