Hi, we are trying to adopt KMP in an existing iOS ...
# multiplatform
d
Hi, we are trying to adopt KMP in an existing iOS / Android project. When we import the KMP project in iOS (adding the KMP build to the compilation phase) it compiles but… ---> we have no auto-completion in XCode <--- I’m an Android developer and my coworker is an iOS developer. Both of us have no idea how to debug this. We have no errors that stands out. Can someone help? Thank you Before trying this we did it with a toy iOS project and autocompletion worked, it maybe something in the real iOS project that is different but we do not know what it can be. Maybe there’s something the KMP project creation wizard does that we didn’t do in the real iOS project? Anything I can do to provide you with useful information to help you help me? Thank you in advance
f
The auto-completion performance is a real issue. Xcode doesn’t like the generated objc header who can have thousand of lines. You can reduce the size of the header by using explicitApi() in the shared code side. Set your shared code as public if it’s really needed by the iOS/Android app.
t
When I'm debugging these issues I usually start Xcode from commandline with
SOURCEKIT_LOGGING=3
env property like this:
Copy code
SOURCEKIT_LOGGING=3 /Applications/Xcode.app/Contents/MacOS/Xcode
And then go to the file where I expect code completion to work and invoke it using Ctrl+Space at the place where I want to get the code completion. For example:
Copy code
import KMPFramework

func helloWorld() {
  Foo<<Ctrl+Space>>
}
And then I copy the output I get in terminal to VS Code (or other text editor) and go through the log to find any errors.
d
What configuration do you have selected in XCode? We've found that we needed to create a new one named just "Debug" (i.e. similar to what you'd have for a new hello world project) and have that selected when developing to get the best experience
j
I wonder if we can leverage GitHub CoPilot Code Completion for Xcode? I can see it scanning the generated ObjC headers and building out the code completion model much better than Xcode Predictive code completion. https://github.com/github/CopilotForXcode
d
I’m really sorry for all this time I didn’t provide any follow up. Me and my coworker had been very busy with multiple stuff to do, however we didn’t forget this. Thank you so much for your answers! @François thanks I hadn’t think of that. The issue I’m having right now isn’t slowness but this is a great suggestion! We’ll try to explore the use of explicitApi as soon as we fix the main issue we have @Tadeas Kriz nor me nor my iOS coworker knew about this command line argument, thank you! My coworker didn’t yet had a chance to go back to our KMP branch to test this out but we plan to try it and get back here with some information if we find it - we did however discover the issue is tied to the name of the targets (suggested by dorche) @dorche You were rigth, setting a “Debug” target allowed us to have autocompletion - this isn’t ideal for us tho’ so we’ kinda “stopped” the integration focusing on other stuff for now but we’ll get back to this relatively soon. Do you know if there’s already a bug open for this? I searched in YouTrack but couldn’t find one @Jason while this might help (does Copilot go and look in side-folders?) my iOS coworker is used to the XCode autocompletion and we’d like to fix that before exploring this route! Thank you for the suggestion!
🙌 1
f
Thank @Tadeas Kriz for the SOURCEKIT_LOGGING, I missed this one.