How debug Kotlin on iOS with Xcode - ios

Currently I am working on one KMM project. It would be really useful to be able to debug the shared code which is in kotlin in xcode project.
I am aware of this solution but I have problem to tell Xcode that *.kt files are source files
to be more specific in the above github link it is written :
You need to tell Xcode that *.kt files are source files, and run an lldb formatter script when debugging starts. Advanced users may want to do this manually, but if you have Xcode installed in the default place, you can run the setup script.
Unless you're using Xcode 11 (in which case look here for help), the following script will install both debugging and formatting support:
./setup.sh
I do not know where and how I should run the ./setup.sh or if there is another way to do it?

The setup script is included in the github repository: https://github.com/touchlab/xcode-kotlin/blob/main/setup.sh
The above plugin is great if you want to debug on Xcode and I highly recommend it.
Just an FYI, in case you didn't notice, there is also a plugin for debugging shared code on iOS for Android Studio: https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile

Related

How can I make Kotlin-native executable with runtime debug information?

In Personally, I am modifying and testing some features of the kotlin-native memory manager.
But, I am struggling to find a way to create an OSX XCode executable, including debugging information of the C++ sources in kotlin-native runtime.
'kotlinc -g ..' generates only debug informations for Kotlin sources.
Please let me know how to build debugging version of runtime and link the debug information into sample kotlin apps.
I am using Kotlin-native 1.3.72, and Xcode 11.5
I think the only available option here is to re-build Kotlin/Native runtime with adding -g compiler option to the Gradle script. See this file and line, probably it should be the correct place.

libGDX RoboVM fork iOS build error

I always get the same strange error when I try to run the iOS version of my libGDX game. The error only shows this message: Error:com.android.tools.idea.gradle.util.Projects.lastGradleSyncFailed(Lcom/intellij/openapi/project/Project;)Z
I can sync gradle successfully but the error message stays the same. It was suggested to use the same android studio version as the RoboVM fork version, so I did that. Now I use version 2.3.0 for them both, but it wasn't fixed by doing this. To set up RoboVM I followed the instructions from the RoboVM fork website: http://robovm.mobidevelop.com/.
Does someone know how to fix this problem?
RoboVM having some incompatibly issue with Android Studio/IDEA, version 2.3.0.
Try to use MobiDevelop RoboVM 2.3.2-SNAPSHOT version that having fixes for the same.
There is a pull request for this problem in master branch, you can check that.
You can work-around this problem with Android Studio higher than 2.2 (I am using AS 3.0 Canary 3, which supports Java 8 features) by splitting your project into two separate projects, one for Android and one for iOS, sharing an imported module where all the common code is.
To set this up you will need to copy your iOS app module into a separate folder. I use this structure:
Toplevel
android
androidApp
lib
ios
iosApp
Each project should have a copy of the gradle.build, gradlew script and gradle folders - easiest way is just to duplicate the tree then remove androidApp from one and iosApp from the other.
Both the android and ios folders contain a top level build.gradle, and a settings.gradle file. The common code is in the lib directory, so the ios folder will need a settings.gradle like this
include ':iosApp', ':lib'
project(':lib').projectDir = new File('../android/lib')
while the android project settings.gradle looks like this:
include ':lib', ':androidApp'
Open each project in its own window in AS, you can now build and run them independently. You can test from the command line (often easier to debug gradle issues) by using
gradlew androidApp:assembleDebug
for the android project and
gradlew iosApp:assemble
for the ios version.
The only issue I currently have with AS 3 is an occasional null pointer error during the dexing phase in the android project. Building from the command line makes this go away for a while. You can of course use AS 2.3 which does not have this issue (but doesn't support Java 8 features like lambdas in Android.)

How can I debug carthage (owned) dependencies in my iOS application?

I have an iOS application project with couple of private(owned) carthage dependencies, sometimes I'm in the need of debugging bugs or to know what is the code executed by certain methods.
I'd like to know if there is an easy way to setup the framework source code in Carthage/Checkouts using a run script, so that if I do a carthage update and run my app a can debug the frameworks source code without the need of adding sub projects.
Can this be done by including the debugging symbols in the framework build if so what would I need to do, to make it work?
Did you tried to copy the dsym files as mentioned in Carthage - Getting Started?
With the debug information copied into the built products directory, Xcode will be able to symbolicate the stack trace whenever you stop at a breakpoint. This will also enable you to step through third-party code in the debugger.

Why do I need to clean the xcode project everytime I build the project?

I have an iOS app written in Swift. Whenever I run the project, it gives Shell Script Invocation Errors:
When I clean the project, the subsequent build performs ok. But again, if I build the project next time, it again gives the same error.
Cleaning and rebuilding the project takes a lot of time. Is there some way around it?
It's difficult to know exactly what is causing this issue as it could be a number of things, So the question is quite broad.
Few things to try...
Check your build phases in the project and look for anything that might not be expected
Try checking out your project (if using version control) in another location such as your Documents folder to make sure there isn't a permissions issue.
Try cleaning the build folder using alt, cmd, shift + k.
If your still having issues after that try providing additonal information.
What version of xcode are you using?
Are you using any xcode plugins?
Are you using any package management solutions? carthage? pods?
Have you tried to build your project on another computer?
Are you using the latest version of the command line tools?

PLCrashReporter frameworks integration produce "Could not inspect the application package." error

I am actually trying to integrate PLCrashReport using either a Framework (the one given on the official website) or Carthage.
Carthage won't compile the framework, and the manual drag & drop with the one downloaded from the website would produce the following error when installing the app on the device (Run build)
App installation failed
Could not inspect the application package.
I use a build target of iOS8, I linked the framework as an embedded binary to ship it with the app ; and this error is very annoying.
Xcode is in 7.3
Right now, I tried manual build for the framework, clean of the project. None would work.
By curiosity, I tried Cocoapod integration for this library, it worked, but Cocoapod is NOT an option on my project so I can't go with it.
Does anyone have had the same issue, any ideas for correcting it ?
Finally found a way to make it work :
PLCrashReporter should NOT be in embedded frameworks, just in linked frameworks. Works like a charm now, debug and release builds !

Resources