https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
g

Garret Yoder

03/27/2024, 7:23 PM
Alright so I'm having one of the weirder issues I've ever had, So I had my ios build working fine 2-3 weeks ago, have made some changes (to the code, not the build) since, and now that I tried building it again I'm getting some really weird behavior. Details are below: • Initially, I was getting a vague error saying that one of my actual vars (platform expect class) didn't exist. This var was just the iOS actual for the SQLlite Database object. Desktop and android were fine, the IDE recognized the class, etc. I cleared cache, regenerated the sqldelight interfaces, no change. ◦ The even stranger thing - is this exact line of code - same object same method call etc appears in multiple places in my code, however it only complained about that one single call. • I temporarily commented out that single section, and the build proceeded a bit further (remember - there were still other instances of the same var and call) and it eventually failed complaining about missing linked libraries from sqlite. I did some googling and came across some older slack chats about changing the linking from static to dynamic & manually adding the linker flag for sqlite. Didn't have to do that before, but whatever I did it and the build proceeded and the app launched. (old thread - https://slack-chats.kotlinlang.org/t/522582/hi-all-i-am-using-issue-integrating-sqldelight-with-kmm-with) • I still can't get it to not error any time this single method call (remember, that happens in multiple places) exists in this one specific file. I cannot for the life of me figure out whats different between this class and the other six places it appears. Specific error message it gives:
Copy code
error: This declaration needs opt-in. Its usage must be marked with @kotlin.experimental.ExperimentalNativeApi or @OptIn(kotlin.experimental.ExperimentalNativeApi::class)
error: Unresolved reference: database
This is actually kind of funny. Additional things I did: • Create a new file ◦ Add a blank test() function that just calls the same sqldelight object - failed ◦ add the exact same function to a different file (one of the ones it wasn't complaining about) - pass
Holy I just figured out what it was finally. The only difference between those files was
import Platform
- which is my expect/actual class So I guess on android/JVM that's not neccesary (it's part of the same module afterall), and it's not neccesary for any other actual object held in that class - but for sqldelight it is for some reason. That was a really obscure issue.