https://kotlinlang.org logo
Title
a

albertgao

05/14/2018, 4:42 AM
Having a problem. I have a project set up in IDEA (
common
, and
android
for android lib, and
ios
for ios framework), but when I open this project in AppCode, nothing shows in the
Project
panel… I assume it might be something to do with the
.idea
folder between IDEA and AppCode is different. So, in order to make the multiplatform works for iOS, I need to create the projects in AppCode from scratch?
o

olonho

05/14/2018, 7:00 AM
@Vyacheslav Karpukhin [JB] wdyt?
v

Vyacheslav Karpukhin [JB]

05/14/2018, 7:03 AM
At the moment yes, you need to create a separate project from an AppCode template.
a

albertgao

05/14/2018, 7:34 AM
@Vyacheslav Karpukhin [JB] Thanks. What about a multiplatform project? Can I add a
settings.gradle
in this AppCode template in order to import my
common
module?
v

Vyacheslav Karpukhin [JB]

05/14/2018, 7:56 AM
Yes, but AppCode is not going to pick it up yet.
a

albertgao

05/14/2018, 7:57 AM
@Vyacheslav Karpukhin [JB] I can live with it, as long as AppCode could pick up my
platform-ios
module, thanks. Will try it tomorrow
@Vyacheslav Karpukhin [JB] One more question, why there is a xcode project file after I creating a
KN framework
, does it mean that I need to put my iOS app in this template too?
v

Vyacheslav Karpukhin [JB]

05/14/2018, 12:38 PM
No, you don't need to. You can use your existing project and add a new K/N framework target to it (File -> Project settings -> "plus" icon in the lower left corner).
a

albertgao

05/14/2018, 11:41 PM
Thanks, I set up a project with the AppCode. One problem, it only generates the
x64
build but not the
arm64
, I want to generate this two builds at the same time. How to do that? This is my gradle settings
framework('kmoblib', targets: ['iphone', 'iphone_sim']) {
      enableMultiplatform true
      srcDir 'main'
      enableDebug true
    }
I just call the
build
from AppCode menu
Sorry for the trouble, solved it by calling the gradle task explicitly
v

Vyacheslav Karpukhin [JB]

05/14/2018, 11:59 PM
It's not possible to build both for the simulator (x64) and the device (arm64) simultaneously, but you can build for arm64 by switching the build destination to "iOS Device" in the run configuration drop down list in the toolbar.
a

albertgao

05/14/2018, 11:59 PM
Thanks! 🙂
> Task :ios:compileKonanKmoblibIos_arm64
file or directory '/Users/albertgao/codes/work/kmoblib/common/src/main/kotlin', not found
T
Got this info in the output when using
--info
with gradle command. It seems it expects the
common
module to follow the standard while I already set another rule in
build.gradle
in `common`:
sourceSets {
    main.kotlin.srcDirs += 'main/'
    test.kotlin.srcDirs += 'test/'
}
So, is this
not found
info fine to ignore? Seems it can still find the code in
common
@Vyacheslav Karpukhin [JB] One more, after changed the framework name in build.gradle and from command line the building works fine, but in the AppCode, it still tries to invoke the compile command with old name, restart won’t help. Worth an issue?
v

Vyacheslav Karpukhin [JB]

05/15/2018, 7:35 AM
The current solution is temporary, it's going to be replaced by a proper gradle support, so not worth filing an issue.
a

albertgao

05/15/2018, 7:37 AM
@Vyacheslav Karpukhin [JB] Thanks! And one more question, when building, it will find the
expect
in
common
and link to the
actual
in the according module. But I can’t
import
any module from
common
module, the compiler will say
can't resolve reference a.b.c
, any ideas how?
s

svyatoslav.scherbina

05/15/2018, 7:54 AM
Could you clarify: where is
a.b.c
declared and where do you try to use it?
a

albertgao

05/15/2018, 7:55 AM
@svyatoslav.scherbina It’s in the
common
module. I added a settings.gradle to include this
common
module to the AppCode
framework
project
s

svyatoslav.scherbina

05/15/2018, 8:02 AM
Do I understand correctly that
a.b.c
is declared in common module and imported into your platform iOS module (i.e. into framework project source)?
a

albertgao

05/15/2018, 8:11 AM
Yes, in the
common
there is a
package a.b.c
, and I try to
import a.b.c
in platform iOS module
s

svyatoslav.scherbina

05/15/2018, 8:25 AM
In Kotlin you can’t import the package itself. It’s possible to import a member of the package:
import a.b.c.MyClass
or all of its members:
import a.b.c.*
i

ilya.matveev

05/15/2018, 8:26 AM
Couple of words about the
'/Users/albertgao/codes/work/kmoblib/common/src/main/kotlin', not found
message. It is expected in your case. The main sourceset in the
common
project contains
src/main/kotlin
as a default source root. Then you add one more source directory into the sourceset but the default directory still remains in it. So when the Kotlin compiler compiles the sources, it iterates over all directories in the sourceset, face this default directory and cannot open it since it doesn't exist. To remove the default directory you may use
=
instead of `+=`:
sourceSets {
    main.kotlin.srcDirs = ['main/']
}
a

albertgao

05/15/2018, 8:26 AM
@svyatoslav.scherbina Sorry, my bad. Yes, I import a member rather than the module. 😄
@ilya.matveev Thanks! I think this might be the cause! Will try tomorrow morning when I back to work! Thanks!
s

svyatoslav.scherbina

05/15/2018, 8:30 AM
@albertgao can you post here your
build.gradle
,
settings.gradle
, the declaration you import and the import statement itself?