Sync Kotlin files with an Xcode project

Overview

Kotlin Xcode Sync

Note Soon to be deprecated. You can add folder references instead. See here.

Import kotlin files into an Xcode project. This is used in conjunction with the Xcode Kotlin plugin to allow for Kotlin/Native debugging in an iOS application.

Importing Kotlin files into Xcode is somewhat tricky to do manually. This plugin will facilitate that.

It is called "Sync", but currently it will only add new files. Renamed or removed files will need to be handled manually in Xcode.

We're Hiring!

Touchlab is looking for Android-focused mobile engineers, experienced with Kotlin and looking to get involved with Kotlin Multiplatorm in the near future. More info here.

Usage

Add the following to the buildscript section:

buildscript {
    dependencies {
        classpath 'co.touchlab:kotlinxcodesync:0.2'
    }
}

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

apply plugin: 'co.touchlab.kotlinxcodesync'


xcodeSync {
  projectPath = "../../iosApp/iosApp.xcodeproj"
  target = "iosApp"
}

The 'projectPath' points at the Xcode project folder. 'target' is the target inside the Xcode project. There's also the optional parameter 'group', which by default is set to 'Kotlin'. That is the group folder that files are copied into.

Issues
  • Incompatibility with Jetbrains xcode-compat plugin

    Incompatibility with Jetbrains xcode-compat plugin

    Jetbrains publishes the xcode-compat plugin to ease some setup, including generating an Xcode project and auto-generating a buildForXcode gradle task. You can see it in-use in the AppCode new project templates.

    This plugin conflicts with it because they both define an extension named "xcode". As far as I know this means it's impossible to use both on the same project.

    opened by russhwolf 2
  • Need instructions for ruby fails

    Need instructions for ruby fails

    If missing 'xcodeproj', run gem install xcodeproj

    opened by kpgalligan 0
  • MacOS Catalina does weird things with paths

    MacOS Catalina does weird things with paths

    Adding files to Xcode produces some huge and apparently incorrect relative paths. See tail end of this: https://kotlinlang.slack.com/archives/C3SGXARS6/p1561103800227400

    opened by kpgalligan 1
  • clarify install and run instructions

    clarify install and run instructions

    opened by karottenreibe 0
  • Not able to run plugin without sudo (or rather install dependencies)

    Not able to run plugin without sudo (or rather install dependencies)

    My work laptop is partially locked and I can't use sudo to install xcodeproj globally. I can however use bundler to install it locally into vendor/bundle. So a workaround for me is to include a Gemfile in my project:

    gem 'xcodeproj', '1.7.0'
    

    Install it with bundle install --path vendor/bundle. And then modify plugin to change ruby build/projimport.rb for bundle exec ruby build/projimport.rb:

    ...
    val scriptArgs = mutableListOf(
            "exec",
            "ruby",
            "build/projimport.rb",
            config.projectPath!!,
            config.target!!,
            config.group,
            File(project.projectDir, "src").path)
    
        val std = ByteArrayOutputStream()
        val err = ByteArrayOutputStream()
        val result = projectExec(project,
            "bundle",
            null,
            scriptArgs,
            std,
            err
        )
    ...
    

    Would be good if the plugin could support this, either via a flag in plugin config or by scanning project files to check if a bundler is used. I could raise a PR if you could advice a preferred way to implement this.

    opened by aleksey-chugaev 0
  • Sync should remove missing files

    Sync should remove missing files

    We currently add files that aren't in Xcode yet, but we don't remove files that have been renamed or deleted from the Kotlin sourceset.

    opened by kpgalligan 0
  • Debug dependency sources

    Debug dependency sources

    After much research, importing dep sources is not that simple. The binaries are built with references to absolute source paths.

    For example, I built sqliter on this machine, so adding those exact source files allows the debugger to work, but adding the same files in a different folder does not. The absolute paths must be in the IR output, and would need a way to be changed.

    Possibly change KN compilation and include sources in the klib file.

    It's a lot of work and not just in this plugin (unless there's a way to alter the binary and change paths).

    opened by kpgalligan 0
  • Kotlin files are added to compile phase

    Kotlin files are added to compile phase

    Kotlin files are added as compile targets. We can turn that off and only the file to the group, but breakpoints don't work.

    Xcode doesn't attempt to compile Kotlin, so it doesn't impact functionality. However, there's a warning.

    warning: no rule to process file 'xxx' of type 'text' for architecture 'x86_64' (in target 'yyy')
    

    We should either figure out how to avoid adding files to compile, or a way to disable the error.

    opened by kpgalligan 0
Sync Kotlin files with an Xcode project

Kotlin Xcode Sync Note Soon to be deprecated. You can add folder references instead. See here. Import kotlin files into an Xcode project. This is used

null 24 May 1, 2021
AppCode helper for Kotlin/Native and Xcode

Kotlin Xcode compatibility Gradle plugin The plugin is used by AppCode to set up Kotlin/Native project along with Xcode Sources A multi-build sample w

Kotlin 22 Feb 15, 2021
KaMP Kit by Touchlab is a collection of code and tools designed to get your mobile team started quickly with Kotlin Multiplatform.

KaMP Kit Welcome to the KaMP Kit! About Goal The goal of the KaMP Kit is to facilitate your evaluation of Kotlin Multiplatform (aka KMP). It is a coll

Touchlab 1.2k Aug 2, 2021
Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Newsout Android and iOS mobile client for Nextcloud news App. The Android client is already available to download in the Play Store. F-Droid and Apple

Simon Schubert 117 Apr 16, 2021
Kotlin Multiplatform Mobile App Template

KMMT : Kotlin Multiplatform Mobile Template Kotlin Multiplatform Mobile Development Simplified KMMT is a KMM based project template designed to simpli

Jitty Andiyan 117 Jul 19, 2021
Generic AST parsing library for kotlin multiplatform

kotlinx.ast kotlinx.ast is a generic AST (Abstract Syntax Tree) parsing library, Kotlin is currently the only supported language. The library is desig

null 140 Jul 27, 2021
Design Patterns implemented in Kotlin

Design Patterns In Kotlin ⚠️ New article about testing: Unit Testing with Mockito 2 Project maintained by @dbacinski (Dariusz Baciński) Inspired by De

Dariusz Baciński 4.8k Jul 28, 2021
Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.

Codename One - Cross Platform Native Apps with Java or Kotlin Codename One is a mobile first cross platform environment for Java and Kotlin developers

Codename One 1k Aug 5, 2021
Koi, a lightweight kotlin library for Android Development.

Koi - A lightweight Kotlin library for Android Koi include many useful extensions and functions, they can help reducing the boilerplate code in Androi

Hello World 507 Jul 11, 2021
BuildConfig for Kotlin Multiplatform Project

BuildKonfig BuildConfig for Kotlin Multiplatform Project. It currently supports embedding values from gradle file. Table Of Contents Motivation Usage

Yasuhiro SHIMIZU 187 Jul 28, 2021
The most complete and powerful data-binding library and persistence infra for Kotlin 1.3, Android & Splitties Views DSL, JavaFX & TornadoFX, JSON, JDBC & SQLite, SharedPreferences.

Lychee (ex. reactive-properties) Lychee is a library to rule all the data. ToC Approach to declaring data Properties Other data-binding libraries Prop

Mike 104 May 28, 2021
StaticLog - super lightweight static logging for Kotlin, Java and Android

StaticLog StaticLog is a super lightweight logging library implemented in pure Kotlin (https://kotlinlang.org). It is designed to be used in Kotlin, J

Julian Pfeifer 27 Apr 10, 2021
A collection of hand-crafted extensions for your Kotlin projects.

Splitties Splitties is a collection of small Kotlin multiplatform libraries (with Android as first target). These libraries are intended to reduce the

Louis CAD 1.8k Aug 4, 2021
Android + Kotlin + Github Actions + ktlint + Detekt + Gradle Kotlin DSL + buildSrc = ❤️

kotlin-android-template ?? A simple Github template that lets you create an Android/Kotlin project and be up and running in a few seconds. This templa

Nicola Corti 1.1k Jul 27, 2021