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

Add iOS and MacOS support #3

Merged
merged 11 commits into from
Aug 10, 2024
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
29 changes: 25 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,40 @@ on:
- "README.md"
jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java

- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
distribution: 'zulu'
check-latest: true
java-version: 22
cache: 'gradle'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@v3

- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest

- name: Cache konan directory
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('*.gradle.kts', 'buildSrc/*') }}
restore-keys: |
${{ runner.os }}-konan-

- name: Build using Gradle
run: ./gradlew assemble

- name: Prepare artifacts
run: |
mkdir build/artifacts
Expand Down
29 changes: 26 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,46 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java

- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
distribution: 'zulu'
check-latest: true
java-version: 22
cache: 'gradle'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@v3

- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest

- name: Cache konan directory
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('*.gradle.kts', 'buildSrc/*') }}
restore-keys: |
${{ runner.os }}-konan-

- name: Build docs
run: |
mkdir docs
./gradlew :dokkaHtmlMultiModule

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './docs'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
31 changes: 27 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,47 @@ permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java

- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
distribution: 'zulu'
check-latest: true
java-version: 22
cache: 'gradle'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@v3

- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest

- name: Cache konan directory
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('*.gradle.kts', 'buildSrc/*') }}
restore-keys: |
${{ runner.os }}-konan-

- name: Write new version
run: |
VERSION="${{ github.ref }}"
VERSION=${VERSION#*v}
sed -i "s/^VERSION_NAME\=.*$/VERSION_NAME=$VERSION/g" gradle.properties
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Build using Gradle
run: ./gradlew assemble

- name: Publish to GitHub Packages and Maven Central
run: ./gradlew publish
env:
Expand All @@ -35,6 +57,7 @@ jobs:
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_PWD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PWD }}

- name: Publish release
uses: softprops/action-gh-release@v2
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
local.properties
/kotlin-js-store
/docs
**/xcshareddata/**
**/xcuserdata/**
/.idea/detekt.xml
/.idea/studiobot.xml
10 changes: 10 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/runConfigurations/Test_App__iOS_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
![Maven Central Version](https://img.shields.io/maven-central/v/dev.tclement.fonticons/core?style=for-the-badge)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/tclement0922/compose-font-icons/build.yml?style=for-the-badge)


Makes possible to use icons from a font in JetBrains Compose Multiplatform.
Currently supported targets are Android, Desktop (JVM) and Web (JS and WASM). An additional library is available for
AndroidX Glance (Android App Widgets / WearOS Tiles).
Makes possible to use icons from a font in JetBrains Compose Multiplatform.
Currently supported targets are Android, Desktop (JVM), Web (JS and WASM), MacOS, and iOS.
An additional library is available for AndroidX Glance (Android App Widgets / WearOS Tiles).

This library supports the [Compose Multiplatform Common resources API](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html)
alongside platform-specific resources like resource IDs for Android, classpath resources for JVM...
Expand Down Expand Up @@ -36,13 +35,15 @@ dependencies {
<th rowspan="2">
Artifact description
</th>
<th colspan="4">Supported platforms</th>
<th colspan="6">Supported platforms</th>
</tr>
<tr>
<th>Android</th>
<th>Desktop (JVM)</th>
<th>Kotlin/JS</th>
<th>Kotlin/WASM</th>
<th>iOS</th>
<th>MacOS</th>
</tr>
</thead>
<tbody>
Expand All @@ -53,14 +54,18 @@ dependencies {
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr align="center">
<td align="start">core-glance</td>
<td>AndroidX Glance support</td>
<td>✔️</td>
<td>❎</td>
<td>❎</td>
<td>❎</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
<td>❌</td>
</tr>
<tr align="center">
<td align="start">font-symbols</td>
Expand All @@ -69,34 +74,39 @@ dependencies {
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr align="center">
<td align="start">font-symbols-outlined</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr align="center">
<td align="start">font-symbols-rounded</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr align="center">
<td align="start">font-symbols-sharp</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
</tr>
</tbody>
</table>

> [!NOTE]
> IOS won't be supported unless I get a Mac (or someone else contributes)

# Usage

Set the default icon parameters:
Expand Down Expand Up @@ -130,7 +140,7 @@ Read the full doc [here](https://tclement0922.github.io/compose-font-icons).
# License

```
Copyright 2024 T. Clément (@tclement0922)
Copyright 2024 T. Clément (@tclement0922) and contributors
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
Expand Down
18 changes: 17 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.dokka.gradle.AbstractDokkaParentTask
import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.kotlin.konan.properties.loadProperties
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import java.net.URL

plugins {
Expand All @@ -40,6 +41,21 @@ buildscript {
}
}

subprojects {
tasks {
withType<KotlinJvmCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
// Kotlin requires the Java compatibility matches despite have no sources.
withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}
}
}

fun Project.configureDokka() {
tasks.withType(AbstractDokkaTask::class) {
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
Expand Down
3 changes: 0 additions & 3 deletions core-glance/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
Expand Down
3 changes: 2 additions & 1 deletion core/src/commonMain/kotlin/dev/tclement/fonticons/Logger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package dev.tclement.fonticons
/**
* Internal logger class, each target has its own implementation (Log for Android, System.err/out for desktop, console for JS/WASM)
*/
// todo: remove logging from production code and use kmp-compatible logging library (e.g. kermit)
internal expect object Logger {
fun v(tag: String, message: String)
fun v(tag: String, message: String, throwable: Throwable)
Expand All @@ -30,4 +31,4 @@ internal expect object Logger {
fun w(tag: String, message: String, throwable: Throwable)
fun e(tag: String, message: String)
fun e(tag: String, message: String, throwable: Throwable)
}
}
20 changes: 20 additions & 0 deletions core/src/nativeMain/kotlin/dev/tclement/fonticons/Logger.native.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package dev.tclement.fonticons

import platform.Foundation.NSLog

/**
* Internal logger class, each target has its own implementation (Log for Android, System.err/out for desktop, console for JS/WASM)
*/
internal actual object Logger {

actual fun v(tag: String, message: String) = NSLog("$tag: $message")
actual fun v(tag: String, message: String, throwable: Throwable) = NSLog("$tag: $message\n$throwable")
actual fun d(tag: String, message: String) = NSLog("$tag: $message")
actual fun d(tag: String, message: String, throwable: Throwable) = NSLog("$tag: $message\n$throwable")
actual fun i(tag: String, message: String) = NSLog("$tag: $message")
actual fun i(tag: String, message: String, throwable: Throwable) = NSLog("$tag: $message\n$throwable")
actual fun w(tag: String, message: String) = NSLog("$tag: $message")
actual fun w(tag: String, message: String, throwable: Throwable) = NSLog("$tag: $message\n$throwable")
actual fun e(tag: String, message: String) = NSLog("$tag: $message")
actual fun e(tag: String, message: String, throwable: Throwable) = NSLog("$tag: $message\n$throwable")
}
5 changes: 2 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
org.gradle.workers.max=1

kotlin.daemon.jvmargs=-Xmx4096m
# When configured, Gradle will run in incubating parallel mode.
Expand All @@ -25,11 +24,11 @@ kotlin.code.style=official
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
kotlin.mpp.applyDefaultHierarchyTemplate=false

GROUP=dev.tclement.fonticons
VERSION_NAME=1.2.3
VERSION_NAME=1.3.0

POM_CORE_NAME=Compose Font Icon
POM_CORE_DESCRIPTION=Font icons composables for Compose Multiplatform
Expand Down
Loading