https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
z

zalewski.se

06/02/2020, 4:05 PM
Does anyone knows why if I will set iOS target like this:
Copy code
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
        if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
            ::iosArm64
        else
            ::iosX64

    iOSTarget("ios") {
        binaries {
            framework(uniqueName)
        }
    }
Then everything works in
iosMain
, I can see whole syntax highlighting correctly. Although if I set it like here:
Copy code
ios {
        binaries {
            framework(uniqueName)
        }
    }
Everything related to iOS is red, I can’t see any import (although it compiles correctly) and syntax highlighting is broken.
r

russhwolf

06/02/2020, 4:09 PM
Using
ios {}
sets up an intermediate source-set and the IDE currently has trouble detecting what platform APIs are available there. Expect that to improve over time as this family of issues is worked: https://youtrack.jetbrains.com/issue/KT-27801
z

zalewski.se

06/02/2020, 4:22 PM
I see, thanks for clearing up my doubts!
k

Kris Wong

06/02/2020, 4:35 PM
to be more clear - the source set name needs to match a target name. so if you have
iosMain
, then you need a target named
ios
the second code block creates
iosX64
and
iosArm64
r

russhwolf

06/02/2020, 4:37 PM
The
ios {}
builder creates an
ios
source in addition to
iosX64
and
iosArm64
, but the IDE interprets it as common
z

zalewski.se

06/02/2020, 4:44 PM
Interesting 🧐 Is it possible to see all the sources that has been generated?
r

russhwolf

06/02/2020, 4:45 PM
sorry - it's configuration, not actual source code. It means the compiler will read things in the
src/iosMain
directory, for example, and apply them to both
iosArm64
and
iosX64
targets
🆗 1
which is why you were seeing that it compiles correctly
but the IDE still has trouble with it
k

Kris Wong

06/02/2020, 5:14 PM
sorry, I was stating what targets it creates
the problem is there's no target with the name
ios
@zalewski.se you can navigate fully through the plugin source code and see what it is doing
z

zalewski.se

06/03/2020, 5:25 AM
Got it! Thanks guys for a detailed explanation, I’m gonna dive deep into plugin source code now to find out more 🙂
3 Views