├── .buildscript └── deploy_snapshot.sh ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE.txt ├── README.md ├── RELEASING.md ├── build.gradle ├── gradle-plugin ├── build.gradle ├── gradle.properties └── src │ └── main │ ├── kotlin │ └── co │ │ └── touchlab │ │ └── kotlinxcodesync │ │ ├── SyncExtension.kt │ │ ├── SyncPlugin.kt │ │ ├── SyncTask.kt │ │ └── Utils.kt │ └── resources │ └── projimport.rb ├── gradle.properties ├── gradle ├── dependencies.gradle ├── gradle-mvn-push.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew └── settings.gradle /.buildscript/deploy_snapshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Deploy a jar, source jar, and javadoc jar to Sonatype's snapshot repo. 4 | # 5 | # Adapted from https://coderwall.com/p/9b_lfq and 6 | # http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/ 7 | 8 | SLUG="AlecStrong/kotlin-native-cocoapods" 9 | JDK="oraclejdk8" 10 | BRANCH="master" 11 | 12 | set -e 13 | 14 | if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then 15 | echo "Skipping snapshot deployment: wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'." 16 | elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then 17 | echo "Skipping snapshot deployment: wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'." 18 | elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then 19 | echo "Skipping snapshot deployment: was pull request." 20 | elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then 21 | echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'." 22 | else 23 | echo "Deploying snapshot..." 24 | ./gradlew $1 25 | echo "Snapshot deployed!" 26 | fi -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | out 7 | 8 | .idea -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - osx 3 | 4 | osx_image: xcode9.3 5 | 6 | language: java 7 | 8 | jdk: 9 | - oraclejdk8 10 | 11 | after_success: 12 | - .buildscript/deploy_snapshot.sh 13 | 14 | branches: 15 | except: 16 | - gh-pages 17 | 18 | notifications: 19 | email: false 20 | 21 | sudo: false 22 | 23 | cache: 24 | directories: 25 | - $HOME/.gradle/caches/ 26 | - $HOME/.gradle/wrapper/ 27 | - $HOME/.gradle/native/ 28 | - $HOME/.gradle/daemon/native/ 29 | 30 | env: 31 | global: 32 | secure: "AvNOCxZ5/QThkyHeh+txThK29tLC66goQfpSv1BGCgcrpaLx5ZlGaCQJ+JRIunewg/uZwY3Yl6dWX1ggNnGysySX2dXDObNAvxYqG8UCA8nu/qYEUlWMAc7JxhGZDBOJzNZSVZJ8aL2egMl4P1ZISDMH3HkKcMUcoFNxocTrZeDhCFZW2nwqes62RfsAmntKn2uDSxvEIe65CQ5TOpC2MZyM7f6d3ZVE5/5i6f3XfP5jX0SvloL0WxzueSYCMohAiX04iDY46mXCLcPvDR1A5cykh8egHkAOIHYU3xUcug5/1wIJJZoKX6R7ApM4cRBUsBsxaedL4/ZTZn6LeIoUKi1ioW82A0X5VAZ47y8uQXb6P79pj5i4j4lNK5McyO97rLPEt1RLqFsVlKSaSDq4gDXAwiUDwwV+aFMOE1HTwzXfqjXdVq51btgRr1Qbi7ZyZPdcZT4aHY/lbP/SL31AJgK57+xKoa//ubWl9Xl1LNMS1+cGgKO5/UmbxScB87ql3fLIifDpgSZNa5HwItI6C3gG/kSnAjaWcU6hI8P0kTnJAfLn4vAlfrBs6rb4orCA6qunSVOSOQCVzWoHSLd8S6l6YElnXxzb4GzmfphluLuBdBNqIxeLKaK3UWwLe41mwn5ugWmDn3JY1oEWJP1vRmiq0WAc7Fd1fjuCaqkK0sE=" 33 | secure: "PvT/zPTqzBN0rvLwN6ISSVSTQjU8Hk0i3wwshKR2j0pL6zosukB9NSpYGsmEF5l7acEXiBq5QJjCRCgoGbEyXumIonxcSHvtXgN2aQwBKUHO5hBww6e3kHYpkqVRYQHvLaZP5pLs7XvQwpGrgKkqHGZ6FZRGTteNY+O5Pq4Vu1YHmVGgn5DZf1biPC+53IkVvqvLFUAACb+33to8S9loKZ1IQHDIpWleN4qv2AvgQasdPZQ0kLeifKLes1W13PzYS9gdMmHr5jyaE5iRrUe79yIwTJ+PCpN//Mjm065hveB5UVYP+L0CTQweVqa/YOH1+HuIDejJOmdWF0JY2bvaEQP7zEXfEOtK9YZyDW91k136Te5ZCasYPpl50HRhNWiSns/ycc5oQrIX1P6Ebh9+mvH5tK/Bih65L+EkcuiL5MN2q26ywJGCgORHvoTcXXIPqOmLQypUjs1DGjJCP7IaxG2Q9aLI8uY9vToKh4QURgw8Vu3jJJl7de6NH4BAFBepx5NNfOaVV0rqKErhXgyoEFtOI0Jm4S+d+yP9A9y156197kP0ZC9nTKqC3839buOWuo03bhEvv5qCtkeZiTgIMkHXnFezfMsg3wVLZ0Ts+JBJjtNOeg3ssM4ZLR4l8pPcZi5ChbdxGpJiGajDSu7eeQbImsw2IOchGnjG1E5B7d8=" 34 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Change Log 2 | ========== 3 | 4 | Version 0.2.0 *(2019-01-26)* 5 | ---------------------------- 6 | 7 | * New: Add custom preset 'cocoapodsPreset' for settings up ios source set 8 | * Fix: Compatibility with kotlin 1.3.20 9 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kotlin Xcode Sync 2 | 3 | *Note* Soon to be deprecated. You can add folder references instead. [See here](https://github.com/touchlab/xcode-kotlin/issues/16). 4 | 5 | Import kotlin files into an Xcode project. This is used in conjunction with the [Xcode 6 | Kotlin plugin](https://github.com/touchlab/xcode-kotlin) to allow for Kotlin/Native debugging in an iOS application. 7 | 8 | Importing Kotlin files into Xcode is somewhat tricky to do manually. This plugin will facilitate 9 | that. 10 | 11 | It is called "Sync", but currently it will only add new files. Renamed or removed files will 12 | need to be handled manually in Xcode. 13 | 14 | > ## **We're Hiring!** 15 | > 16 | > Touchlab is looking for Android-focused mobile engineers, experienced with Kotlin and 17 | > looking to get involved with Kotlin Multiplatorm in the near future. [More info here](https://on.touchlab.co/2NrAhB8). 18 | 19 | ## Usage 20 | 21 | Add the following to the buildscript section: 22 | 23 | ```groovy 24 | buildscript { 25 | dependencies { 26 | classpath 'co.touchlab:kotlinxcodesync:0.2' 27 | } 28 | } 29 | ``` 30 | 31 | Apply the plugin in the shared code project, and configure the plugin 32 | 33 | ```groovy 34 | apply plugin: 'co.touchlab.kotlinxcodesync' 35 | 36 | 37 | xcodeSync { 38 | projectPath = "../../iosApp/iosApp.xcodeproj" 39 | target = "iosApp" 40 | } 41 | ``` 42 | 43 | The 'projectPath' points at the Xcode project folder. 'target' is the target inside the Xcode project. There's also the optional 44 | parameter 'group', which by default is set to 'Kotlin'. That is the group folder that files are copied into. 45 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | Releasing 2 | ========= 3 | 4 | 1. Change the version in `gradle.properties` to a non-SNAPSHOT verson. 5 | 2. Update the `CHANGELOG.md` for the impending release. 6 | 3. Update the `README.md` with the new version. 7 | 4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version) 8 | 5. `./gradlew clean uploadArchives`. 9 | 6. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact. 10 | 7. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version) 11 | 8. Update the `gradle.properties` to the next SNAPSHOT version. 12 | 9. `git commit -am "Prepare next development version."` 13 | 10. `git push && git push --tags` 14 | 15 | 16 | Prerequisites 17 | ------------- 18 | 19 | In `~/.gradle/gradle.properties`, set the following: 20 | 21 | * `SONATYPE_NEXUS_USERNAME` - Sonatype username for releasing to `com.squareup`. 22 | * `SONATYPE_NEXUS_PASSWORD` - Sonatype password for releasing to `com.squareup`. 23 | * `SQLDELIGHT_BUGSNAG_KEY` - Bugsnag API key for crash reporting. 24 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | apply from: "$rootDir/gradle/dependencies.gradle" 3 | 4 | repositories { 5 | mavenCentral() 6 | maven { 7 | url "${project.rootDir.path}/build/localMaven" 8 | } 9 | } 10 | 11 | dependencies { 12 | classpath deps.plugins.kotlin 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | tasks.withType(Test) { 22 | testLogging { 23 | events = ["failed", "skipped", "passed"] 24 | exceptionFormat "full" 25 | } 26 | } 27 | 28 | group = GROUP 29 | version = VERSION_NAME 30 | } 31 | -------------------------------------------------------------------------------- /gradle-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'org.jetbrains.kotlin.jvm' 2 | apply plugin: 'java-gradle-plugin' 3 | 4 | sourceCompatibility = JavaVersion.VERSION_1_7 5 | targetCompatibility = JavaVersion.VERSION_1_7 6 | 7 | gradlePlugin { 8 | plugins { 9 | sqlDelight { 10 | id = 'co.touchlab.kotlinxcodesync' 11 | implementationClass = 'co.touchlab.kotlinxcodesync.SyncPlugin' 12 | } 13 | } 14 | } 15 | 16 | configurations { 17 | fixtureClasspath 18 | } 19 | 20 | // Append any extra dependencies to the test fixtures via a custom configuration classpath. This 21 | // allows us to apply additional plugins in a fixture while still leveraging dependency resolution 22 | // and de-duplication semantics. 23 | tasks.getByName('pluginUnderTestMetadata'). 24 | getPluginClasspath(). 25 | from(configurations.fixtureClasspath) 26 | 27 | dependencies { 28 | implementation deps.kotlin.stdlib.jdk 29 | 30 | compileOnly gradleApi() 31 | compileOnly deps.plugins.kotlin 32 | 33 | testImplementation deps.junit 34 | testImplementation deps.truth 35 | 36 | fixtureClasspath deps.plugins.kotlin 37 | } 38 | 39 | apply from: "$rootDir/gradle/gradle-mvn-push.gradle" 40 | -------------------------------------------------------------------------------- /gradle-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_ARTIFACT_ID=kotlinxcodesync 2 | POM_NAME=Xcode Kotlin File Sync 3 | POM_DESCRIPTION=Gradle plugin to sync Kotlin source files with an Xcode project 4 | POM_PACKAGING=jar 5 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/kotlin/co/touchlab/kotlinxcodesync/SyncExtension.kt: -------------------------------------------------------------------------------- 1 | package co.touchlab.kotlinxcodesync 2 | 3 | open class SyncExtension( 4 | var projectPath: String? = null, 5 | var target: String? = null, 6 | var group: String = "Kotlin" 7 | ) -------------------------------------------------------------------------------- /gradle-plugin/src/main/kotlin/co/touchlab/kotlinxcodesync/SyncPlugin.kt: -------------------------------------------------------------------------------- 1 | package co.touchlab.kotlinxcodesync 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | 6 | open class SyncPlugin : Plugin { 7 | override fun apply(project: Project) { 8 | val extension = project.extensions.create("xcodeSync", SyncExtension::class.java) 9 | 10 | project.afterEvaluate { 11 | project.tasks.register("xcodeSync", SyncTask::class.java) { task -> 12 | task.group = "xcode" 13 | task.description = "Sync Kotlin files with an Xcode project" 14 | task.config = extension 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /gradle-plugin/src/main/kotlin/co/touchlab/kotlinxcodesync/SyncTask.kt: -------------------------------------------------------------------------------- 1 | package co.touchlab.kotlinxcodesync 2 | 3 | import org.gradle.api.DefaultTask 4 | import org.gradle.api.tasks.TaskAction 5 | import java.io.ByteArrayOutputStream 6 | import java.io.File 7 | 8 | open class SyncTask : DefaultTask() { 9 | lateinit var config: SyncExtension 10 | 11 | @TaskAction 12 | fun syncProject() { 13 | copyRubyFile() 14 | 15 | /*val ktExt = project.extensions.findByType(KotlinProjectExtension::class.java) 16 | val mpExt = project.extensions.findByType(KotlinMultiplatformExtension::class.java) 17 | 18 | mpExt?.let { 19 | it. 20 | } 21 | mpExt?.sourceSets?.let { ssList -> 22 | ssList.forEach { ss -> 23 | ss.dependencies() 24 | } 25 | }*/ 26 | 27 | val projectPath = config.projectPath 28 | val target = config.projectPath 29 | 30 | if(projectPath.isNullOrEmpty() || target.isNullOrEmpty()){ 31 | throw IllegalArgumentException("projectPath and target required") 32 | } 33 | 34 | val scriptArgs = mutableListOf( 35 | "build/projimport.rb", 36 | config.projectPath!!, 37 | config.target!!, 38 | config.group, 39 | File(project.projectDir, "src").path) 40 | 41 | val std = ByteArrayOutputStream() 42 | val err = ByteArrayOutputStream() 43 | val result = projectExec(project, 44 | "ruby", 45 | null, 46 | scriptArgs, 47 | std, 48 | err 49 | ) 50 | 51 | logger.info(String(std.toByteArray())) 52 | if(result.exitValue != 0){ 53 | logger.error(String(err.toByteArray())) 54 | } 55 | } 56 | 57 | fun copyRubyFile() { 58 | val rbFile = File(project.buildDir, "projimport.rb") 59 | // if (!rbFile.exists()) { 60 | val rbText = javaClass.getResource("/projimport.rb").readText() 61 | rbFile.writeText(rbText) 62 | // } 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /gradle-plugin/src/main/kotlin/co/touchlab/kotlinxcodesync/Utils.kt: -------------------------------------------------------------------------------- 1 | package co.touchlab.kotlinxcodesync 2 | 3 | import org.gradle.api.InvalidUserDataException 4 | import org.gradle.api.Project 5 | import org.gradle.process.ExecResult 6 | import org.gradle.process.ExecSpec 7 | import java.io.ByteArrayOutputStream 8 | import java.io.File 9 | import java.lang.Exception 10 | 11 | fun projectExec( 12 | proj: Project, 13 | executable: String, 14 | workingDir: File?, 15 | args:List, 16 | stdout: ByteArrayOutputStream, 17 | stderr:ByteArrayOutputStream): ExecResult { 18 | 19 | var execSpec:ExecSpec ? = null 20 | var execResult:ExecResult? = null 21 | var execSucceeded = false 22 | 23 | /* 24 | args "@${Utils.relativePath(project.projectDir, javaBatch)}" 25 | 26 | setStandardOutput stdout 27 | setErrorOutput stderr 28 | 29 | setWorkingDir project.projectDir 30 | */ 31 | try { 32 | execResult = proj.exec { 33 | it.executable = executable 34 | if (workingDir != null) 35 | it.workingDir = workingDir 36 | it.args = args 37 | it.standardOutput = stdout 38 | it.errorOutput = stderr 39 | } 40 | execSucceeded = true 41 | /*if (matchRegexOutputsRequired) { 42 | if (!matchRegexOutputs(stdout, stderr, matchRegexOutputsRequired)) { 43 | // Exception thrown here to output command line 44 | throw new InvalidUserDataException( 45 | 'Unable to find expected expected output in stdout or stderr\n' + 46 | 'Failed Regex Match: ' + escapeSlashyString(matchRegexOutputsRequired)) 47 | } 48 | }*/ 49 | 50 | } catch (e:Exception) { // NOSONAR 51 | // ExecException is most common, which indicates "non-zero exit" 52 | val exceptionMsg = projectExecLog(/*execSpec, */stdout, stderr, execSucceeded, e) 53 | throw InvalidUserDataException(exceptionMsg, e) 54 | } 55 | 56 | // log.debug(projectExecLog(execSpec, stdout, stderr, execSucceeded, null)) 57 | 58 | return execResult 59 | } 60 | 61 | fun projectExecLog( 62 | /*execSpec:ExecSpec, */stdout: ByteArrayOutputStream, stderr:ByteArrayOutputStream , 63 | execSucceeded:Boolean, exception:Exception?):String { 64 | // Add command line and stderr to make the error message more useful 65 | // Chain to the original ExecException for complete stack trace 66 | 67 | var msg = if (execSucceeded) { 68 | "Command Line Succeeded:\n" 69 | } else { 70 | "Command Line Failed:\n" 71 | } 72 | 73 | /*msg += execSpec.commandLine.join(" ") + '\n' 74 | 75 | // Working Directory appears to always be set 76 | if (execSpec.getWorkingDir() != null) { 77 | msg += "Working Dir:\n" 78 | msg += execSpec.getWorkingDir().absolutePath + '\n' 79 | }*/ 80 | 81 | // Use 'Cause' instead of 'Caused by' to help distinguish from exceptions 82 | if (exception != null) { 83 | msg += "Cause:\n" 84 | msg += exception.toString() + '\n' 85 | } 86 | 87 | // Stdout and stderr 88 | msg += stdOutAndErrToLogString(stdout, stderr) 89 | return msg 90 | } 91 | 92 | fun stdOutAndErrToLogString(stdout:ByteArrayOutputStream , stderr:ByteArrayOutputStream ):String { 93 | return "Standard Output:\n" + 94 | stdout.toString() + '\n' + 95 | "Error Output:\n" + 96 | stderr.toString() 97 | } 98 | internal fun List.join(separator:String = ","):String{ 99 | val sb = StringBuilder() 100 | this.forEach { 101 | if(sb.isNotEmpty()) 102 | sb.append(separator) 103 | sb.append(it) 104 | } 105 | return sb.toString() 106 | } -------------------------------------------------------------------------------- /gradle-plugin/src/main/resources/projimport.rb: -------------------------------------------------------------------------------- 1 | require 'xcodeproj' 2 | 3 | project_file = ARGV[0] 4 | targetName = ARGV[1] 5 | groupName = ARGV[2] 6 | 7 | project = Xcodeproj::Project.open(project_file) 8 | 9 | target = project.targets.find {|target| target.name == targetName} 10 | 11 | if target == nil 12 | puts "target #{targetName} not found" 13 | exit(false) 14 | end 15 | 16 | kot_group = project.groups.find do |group| 17 | group.name == groupName 18 | end 19 | 20 | if kot_group == nil 21 | kot_group = project.new_group(groupName) 22 | end 23 | 24 | kt_files = kot_group.recursive_children.select do |elem| 25 | elem.kind_of? Xcodeproj::Project::Object::PBXFileReference 26 | end.map do |file_ref| 27 | file_ref.real_path.to_s 28 | end.select do |path| 29 | path.end_with?(".kt") and File.exists?(path) 30 | end 31 | 32 | group_index = {} 33 | 34 | def dlog(str) 35 | if false 36 | puts str 37 | end 38 | end 39 | 40 | def walkGroups (group_index, pathBase, groups) 41 | groups.each do |group| 42 | if group.name != nil 43 | groupPathName = pathBase + '/' + group.name 44 | group_index[groupPathName] = group 45 | walkGroups(group_index, groupPathName, group.groups) 46 | end 47 | end 48 | end 49 | 50 | walkGroups(group_index, "", kot_group.groups) 51 | 52 | def addfiles (existingFiles, group_index, direc, pathBase, current_group, main_target) 53 | 54 | Dir.glob(direc).sort.each do |item| 55 | next if item == '.' or item == '.DS_Store' 56 | new_folder = File.basename(item) 57 | 58 | if File.directory?(item) 59 | 60 | groupPathName = pathBase + '/' + new_folder 61 | foundGroup = group_index[groupPathName] 62 | if foundGroup == nil 63 | foundGroup = current_group.new_group(new_folder) 64 | group_index[groupPathName] = foundGroup 65 | dlog "creating #{groupPathName}" 66 | else 67 | dlog "existing #{groupPathName}" 68 | end 69 | addfiles(existingFiles, group_index, "#{item}/*", groupPathName, foundGroup, main_target) 70 | else 71 | 72 | if item.end_with? ".kt" 73 | projectPath = "#{pathBase}/#{new_folder}" 74 | fileFound = existingFiles.any? { |path| 75 | path.end_with? projectPath 76 | } 77 | if fileFound 78 | dlog "File #{projectPath} exists" 79 | else 80 | dlog "File #{projectPath} created" 81 | current_group.new_file(item) 82 | end 83 | end 84 | end 85 | end 86 | end 87 | 88 | srcDirIndex = 3 89 | 90 | while srcDirIndex < ARGV.length do 91 | importPath = ARGV[srcDirIndex] 92 | addfiles(kt_files, group_index, "#{importPath}/*", "", kot_group, target) 93 | srcDirIndex +=1 94 | end 95 | 96 | project.save(project_file) 97 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | GROUP=co.touchlab 2 | VERSION_NAME=0.2 3 | 4 | POM_URL=https://github.com/touchlab/KotlinXcodeSync/ 5 | POM_SCM_URL=https://github.com/AlecStrong/kotlin-native-cocoapods/ 6 | POM_SCM_CONNECTION=scm:git:git://github.com/touchlab/KotlinXcodeSync.git 7 | POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/touchlab/KotlinXcodeSync.git 8 | 9 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 10 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 11 | POM_LICENCE_DIST=repo 12 | 13 | POM_DEVELOPER_ID=kpgalligan 14 | POM_DEVELOPER_NAME=Kevin Galligan 15 | -------------------------------------------------------------------------------- /gradle/dependencies.gradle: -------------------------------------------------------------------------------- 1 | ext.versions = [ 2 | kotlin: '1.3.50', 3 | ] 4 | 5 | ext.deps = [ 6 | plugins: [ 7 | kotlin: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}", 8 | ], 9 | 10 | kotlin: [ 11 | stdlib: [ 12 | jdk: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}", 13 | ], 14 | test: [ 15 | common: "org.jetbrains.kotlin:kotlin-test-common:${versions.kotlin}", 16 | commonAnnotations: "org.jetbrains.kotlin:kotlin-test-annotations-common:${versions.kotlin}", 17 | ], 18 | ], 19 | junit: 'junit:junit:4.12', 20 | truth: 'com.google.truth:truth:0.42', 21 | ] 22 | -------------------------------------------------------------------------------- /gradle/gradle-mvn-push.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Chris Banes 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'maven' 18 | apply plugin: 'signing' 19 | 20 | version = VERSION_NAME 21 | group = GROUP 22 | 23 | def isReleaseBuild() { 24 | return VERSION_NAME.contains("SNAPSHOT") == false 25 | } 26 | 27 | def getReleaseRepositoryUrl() { 28 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL : 29 | "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 30 | } 31 | 32 | def getSnapshotRepositoryUrl() { 33 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL : 34 | "https://oss.sonatype.org/content/repositories/snapshots/" 35 | } 36 | 37 | def getRepositoryUsername() { 38 | return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : "" 39 | } 40 | 41 | def getRepositoryPassword() { 42 | return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : "" 43 | } 44 | 45 | def configurePom(pom) { 46 | pom.groupId = GROUP 47 | pom.artifactId = POM_ARTIFACT_ID 48 | pom.version = VERSION_NAME 49 | 50 | pom.project { 51 | name POM_NAME 52 | packaging POM_PACKAGING 53 | description POM_DESCRIPTION 54 | url POM_URL 55 | 56 | scm { 57 | url POM_SCM_URL 58 | connection POM_SCM_CONNECTION 59 | developerConnection POM_SCM_DEV_CONNECTION 60 | } 61 | 62 | licenses { 63 | license { 64 | name POM_LICENCE_NAME 65 | url POM_LICENCE_URL 66 | distribution POM_LICENCE_DIST 67 | } 68 | } 69 | 70 | developers { 71 | developer { 72 | id POM_DEVELOPER_ID 73 | name POM_DEVELOPER_NAME 74 | } 75 | } 76 | } 77 | } 78 | 79 | afterEvaluate { project -> 80 | uploadArchives { 81 | repositories { 82 | mavenDeployer { 83 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 84 | 85 | repository(url: getReleaseRepositoryUrl()) { 86 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 87 | } 88 | snapshotRepository(url: getSnapshotRepositoryUrl()) { 89 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 90 | } 91 | 92 | configurePom(pom) 93 | } 94 | } 95 | } 96 | 97 | tasks.create("installLocally", Upload) { 98 | configuration = configurations.archives 99 | 100 | repositories { 101 | mavenDeployer { 102 | repository(url: "file://${rootProject.buildDir}/localMaven") 103 | 104 | configurePom(pom) 105 | } 106 | } 107 | } 108 | 109 | signing { 110 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } 111 | sign configurations.archives 112 | } 113 | 114 | if (project.getPlugins().hasPlugin('com.android.application') || 115 | project.getPlugins().hasPlugin('com.android.library')) { 116 | task install(type: Upload, dependsOn: assemble) { 117 | repositories.mavenInstaller { 118 | configuration = configurations.archives 119 | 120 | configurePom(pom) 121 | } 122 | } 123 | 124 | task androidJavadocsJar(type: Jar) { 125 | classifier = 'javadoc' 126 | from "$buildDir/dokkaJavadoc" 127 | } 128 | 129 | task androidSourcesJar(type: Jar) { 130 | classifier = 'sources' 131 | from android.sourceSets.main.java.source 132 | } 133 | } else { 134 | install { 135 | repositories.mavenInstaller { 136 | configurePom(pom) 137 | } 138 | } 139 | 140 | task sourcesJar(type: Jar, dependsOn: classes) { 141 | classifier = 'sources' 142 | from sourceSets.main.allSource 143 | } 144 | 145 | task javadocJar(type: Jar, dependsOn: javadoc) { 146 | classifier = 'javadoc' 147 | from javadoc.destinationDir 148 | } 149 | } 150 | 151 | if (JavaVersion.current().isJava8Compatible()) { 152 | allprojects { 153 | tasks.withType(Javadoc) { 154 | options.addStringOption('Xdoclint:none', '-quiet') 155 | } 156 | } 157 | } 158 | 159 | artifacts { 160 | if (project.getPlugins().hasPlugin('com.android.application') || 161 | project.getPlugins().hasPlugin('com.android.library')) { 162 | archives androidSourcesJar 163 | archives androidJavadocsJar 164 | } else { 165 | archives sourcesJar 166 | archives javadocJar 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/KotlinXcodeSync/678c99a20625d6dfb3dc3b75aaeb9f54babbd35f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS='"-Xmx64m"' 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'kotlin-xcode-sync' 2 | 3 | include ':gradle-plugin' 4 | --------------------------------------------------------------------------------