Giter VIP home page Giter VIP logo

kotlinxcodesync's Introduction

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.

kotlinxcodesync's People

Contributors

kpgalligan 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

karottenreibe

kotlinxcodesync's Issues

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.

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).

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.

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.

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.

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.