https://kotlinlang.org logo
Title
a

albertgao

01/31/2018, 1:47 AM
How to setup the project dependencies for platform specific code? When I
import platform.Foundation.*
, IDEA said
cant resolve platform
. I think maybe it’s because I have not setup the
dependencies
in the
build.gradle
? But can’t find them in the
kotlin-conf
and KN
samples
either, I can’t get the auto-completion there, but at least they seem to resolve the kotlin native libs without problem. Basically the same
build.gradle
. Anything I missed here?
g

gildor

01/31/2018, 2:01 AM
Hmm, I don’t think that Idea supports platform frameworks, the only supported IDE is CLion for now
a

albertgao

01/31/2018, 2:02 AM
😂
g

gildor

01/31/2018, 2:05 AM
Can you build it from console gradle?
a

albertgao

01/31/2018, 3:17 AM
@gildor I can’t. 😞
g

gildor

01/31/2018, 3:17 AM
Because of platform import?
a

albertgao

01/31/2018, 3:18 AM
Yes. Can’t resolve the
platform
If I just work with the raw kotllin std api. the iOS framework could be built flawlessly. But not when using the
platform.*
Because it can’t resolve the dependencies of
platform
g

gildor

01/31/2018, 3:30 AM
Do you use
import platform.Foundation
only in K/N sources?
a

albertgao

01/31/2018, 3:30 AM
Yes.
And no auto complete in Clion either.. At least for Kotlincof and kotlin native samples. And build will have error, But not this can’t resolve, but a path error
warning: directory not found for option ‘-F/Users/albertgao/Library/Developer/Xcode/DerivedData/konan-eagojejctmwfaofzoiynfjarikts/Build/Products/Debug-iphoneos’
ld: framework not found helperlib
error: linker invocation reported errors
o

olonho

01/31/2018, 6:01 AM
do you use git tree or redistributable? are platform libs built at all in the first case? Think if you will use IDEA gradle support running K/N gradle build shall be possible. What kind of problem do you have?
a

albertgao

01/31/2018, 7:41 AM
@olonho Thanks for the reply! I setup this project via gradle. This is my
build.gradle
. https://gist.github.com/Albert-Gao/10c3d8c801b5d303ca81202847cc1976 Via this settings, I could generate iOS framework, and consumes from the Swift side without any problem. But the limitation is that I could only use API which resides in kotlin-std-lib. Today I want to implement some library which using kotlin native api, something like
platform.Foundation.*
But via this settings, I don’t know how to add project dependencies for kotlin native lib. Such that: 1. IDEA can’t resolve the
platform.Foundation.*
API, no auto completion. 2. Gradle can’t build because it can’t resolve the
platform.Foundation.*
as well
o

olonho

01/31/2018, 9:11 AM
1. is expected , 2. is not, if platform libraries are available. Make sure you did
gradlew bundle
if you use your own build of Kotlin/Native
a

albertgao

01/31/2018, 10:27 AM
Thanks! After I ran that
bundle
command, it will generate a file named
kotlin-native-macos-0.5.tar.gz
? How to use that? I currently created a project which is not inside the
kotlin native repo/samples
folder. Is it possible? I saw there is a
buildSamplesWithPlatformLibs
in the KN repo, but it’s just some
dependsOn
, don’t how to use that bundle file. Any hints?
o

olonho

01/31/2018, 11:40 AM
you may want to use composite build, like is being done in samples
👍 1