Ksp multiplatform redeclaration of files - kotlin

I am implementing ksp processor in kotlin multiplatform targeting iOS and android applications, following documentation I'm defining multiple configuration names for KSP ie:
add("kspIosArm64", project(":test-processor"))
add("kspIosX64", project(":test-processor"))
However running those gives me file redeclaration error. Indeed files are created in separate locations:
build/generated/ksp/iosArm64/ and build/generated/ksp/iosX64/ but packages are the same.
And Im quite lost how to solve this issue, is there any way of getting this generated folder path for each generated file so that package can be modified?

I will try to partially answer your questions right now, not to make you stack and focus on making the project able to run. I assume that you are using XCode to run the project for iOS. The problem here is that (as you mentioned) all of those source sets are being generated with the same package name which is more a KSP issue (I think) that we have to wait for to be solved.
What you can do for now to run and test the project is:
Make sure to clean your build with ./gradlew clean before running the project (especially between Android and iOS runs)
I think clean can be added as a "step" before KMM framework task:
XCode Project file -> Build Phases -> Generate KMM framework -> add clean before running gradle task responsible for building framework (This can will make build time longer)
./gradlew :yourSharedModule:clean :yourSharedModuleName:embedAndSignAppleFrameworkForXcode
Selected only one architecture to be build when running the project
XCode Project -> Build Settings -> Architectures -> Build Active Architecture Only -> Yes
This solutions makes only one architecture to be build and run (it is probably a simulator in your case), issue here is you may have some problems with other architectures and will not be able to spot them easily on daily development.
Create some kind of env or a build config value to distinguish which ksp dependency to add (based on it's value) so not all of processors are added when running the project
XCode Project -> Build Phases -> Generate KMM framework -> pass it as gradle param -Parchitecture=someArchitecture
Or maybe it is even possible to do it within the build.gradle.kts file
Manually comment out some of ksp dependencies (iOS ones) so the only one against which you are building is left (remember to sync project and clean it)
I personally would try to implement the third solution, I do not know whether it is easy, but it seems to be the best one, other solutions should also work, but please consider them as a dirty walk-around.
I can provide more info or some kind of POC for that later, just let me know in the comments or somewhere else whether it is needed.

Related

How can I add a framework into Xcode project using fastlane or command line?

I have an app that is dependent on a framework file that I wrote. They're independent xcode project and has their own Github repo. I want to create a fastlane to automatically add the framework to the app project and do a build whenever I commit to the app repo. Right now I have to manually add the framework into Embedded Binaries and Linked Frameworks and Libraries inside the app project. I can't find any actions in fastlane to update the project's framework section.
Thanks
If I understand your question correctly you are wanting to manage an API framework project which you main project uses.
Fast lane (IMHO) is about building and managing built artefacts. Managing dependencies within your project is a different thing. To that end there are two options which I am aware of:
Cocoapods - The only option for a long time. Ruby based tool. Manages dependencies by adding builds and XCConfigs to your project. Does this by re-writing your project files. Rebuilds all dependencies when you build. My opinion - I've never been a fan. I don't like that you really need to know Ruby to use it, the way it hacks into your project and enforces it's build ideas on you.
Carthage - Newer option. OS X native tool. Updates and builds dependencies only when you tell it to. Zero impact on your project, but you have to do a little work to include the framework files. Only works with frameworks. My opinion - feels more natural that Cocoapods and the best option.

IntelliJ IDEA reorganizing dependencies

I'm developing for Android and have downloaded IDEA 13.1.3. The reason for that was the missing option in Android Studio to reorganize dependencies.
I'm going to ProjectStructure -> Modules -> MyModule -> Dependencies
But every time gradle rebuilds the project the imports are automatically reorganized bringing the Android API as the first dependency (i.e. the MyApp.iml is modified and <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" /> is moved to the top.
Additionally the project SDK is being changed to java (i.e. .idea\misc.xml is modified)
I'm using the latest InetelliJ Community Edition RC - that is v 13.1.3 build 135.909. I've tried android gradle plugin 0.9.+ and the most recent 0.10.4
For Gradle-based projects, setting order of entries in the classpath is not supported at this time. As you've seen, for Gradle-based projects it rewrites the .iml files every time it syncs the project with the Gradle files, which happens frequently. In this scenario, the .iml project files aren't considered to be user-editable and aren't intended to be checked into source control or treated as anything other than ephemeral. The same goes for everything in the .idea folder.
Where this is usually a problem for Android Studio users is for those who want to do plain Java unit testing (rather than the androidTest support in the Android Gradle plugin). This is known to not work very well at this time; you can track its progress at https://code.google.com/p/android/issues/detail?id=65186. I realize that bug doesn't mention anything specifically about classpath ordering, but it's all part of the same larger issue.

How can I check the build command for my JavafX app in IntelliJ IDEA

Im creating a JavaFX application in IntelliJ IDEA, and I am new to IntelliJ.
I would like to be able to compile my JavaFX application on a Raspberry Pi, but my app is quite complex and relies on 3rd party libraries, etc.
I would like to be able to see what exactly is going on in IntelliJ when I run "Make Project"
Is there a command line output screen that Im simply missing? I want the exact command that IntelliJ uses to compile the application.
Essentially, on the Pi, I want to get the code from my repo, run the compilation command and produce an executable JAR on demand.
I have of course read the doco on how to compile a JavaFX application, but if I could see what IntelliJ does, that would be fantastic.
So far I haven't found such an option but the process is most likely some sort of flow based on IntelliJ plugins and the documentation seems to support this theory.
Perhaps you'd consider using a software management and build tool such as maven or ant or something similar. This should give you (almost) unlimited options to configure your desired build sequence and 3rd party dependencies.

How do you link an eclipse project to an eclipse plug-in project?

I am building an eclipse plug-in project that acts as a front end. I also have a separate eclipse project that runs as a backend. Right now I can run each of them separately and they communicate just fine using sockets.
I would like the plug-in to create the major components of the back end when it starts but also keep the two projects separate so that I can use other editors to communicate with the back end. So, I added the back end eclipse project to the build properties of the plug-in project and I added some code from the back end driver to the plug-in activator's start(). However, when I run the plug-in project I am getting class not found exceptions for all back end references. It appears to compile fine, but I can't run it. I do not do anything to the MANIFEST.MF file in the plug-in project.
How does one add a second java project to an eclipse plug-in project?
There are several ways you can do this, going from best and most difficult to worst and easiest:
(1) Use a build tool (such as the built-in ANT, or tycho, or (as I'm sure there are) some other). This is by far the best solution, but is quite a bit more involved than the next 2.
(2) Convert your non-plugin project to a plugin project and add it as a plugin dependency in your plugin settings file's dependencies tab
(3) Export your non-plugin to a new .jar in your plugin project directory (e.g. $project_loc/lib/something.jar); go into plugin settings (plugin.xml) and include it in: The Build tab under binary build, and the Runtime tab under Classpath. (Or edit the corresponding entries in manifest.mf and build.properties)
For most cases I'd recommend approach (1); look up a few tutorials online, there are plenty. (3) is the quick-and-dirty non-flexible workaround to your particular situation, good for nothing other than seeing if it actually can run. (2) is somewhere in between -- obviously not ideal, but not as bad as 3.

Setting up Xcode for developing Plug-ins

I've never worked in XCode before but I am designing a plugin (objective-c) for an open source radiology program called OsiriX. I can get the thing to compile and I can even get the plugin to run in OsiriX. But, I'm not sure how to run/debug it from XCode. Run/Debug is grayed out on my xcode. Is it because there's no main program?
(1) "Clean all" your projects so that there isn't detritus left around when you do this.
(2) Set Xcode to use a common build products directory (I stick mine in /tmp/ so that it periodically gets nuked). The preference is under the "Building" section.
(3) Re-build OsiriX (so that it'll be built in the shared location).
(4) Make sure the active configuration in your plug-in project has the exact same name as the configuration in OsiriX that you built in (3). (It should probably be "Debug" or "Release", depending on which you build). The configurations can be edited in the build settings editor.
(5) Build your plug-in.
(6) Add a custom executable to your plug-in project and set the path to OsiriX (Project -> New Custom Executable...).
You should now be able to build-and-run or build-and-debug your project. It will launch OsiriX from the build products directory. You might also want to set OsiriX to look for bundles in your build products directory, if it doesn't already. Or you could create a symbolic link from one of OsiriX's plug-in directories to the bundle in your build products directory.
cd /path/to/OsiriX's/bundle/directory
ln -s /path/to/build/products/YourPlugin.bundle
This is a very standard way of ocnfiguring Xcode for development of plug-ins. For example, preference pane developers will set up a custom executable for SystemPreferences.app (even in /Applications -- there is no need to point to a "debug" build of the application).
In order to debug your plugin, you have to be running Osirix in Xcode as well. Download the Osirix source code from Github and compile and run it. You'll have to add the plugin to its plugin list and then when you run in Xcode your NSLog statements from the plugin source will print out in the Xcode console screen for the main Osirix program. I believe breakpoints work as well.
My experience with Xcode is also somewhat limited, but I've found that using the latest version (6.1.1) I can debug my plugin simply by attaching to a running OsiriX process via the Debug -> Attach Process menu. This does not require you to build OsiriX from source - I'm currently using the standard (non-MD) version as downloaded from their website.
Note that you still need to restart OsiriX to pick up any changes to your plugin.