https://kotlinlang.org logo
#ios
Title
# ios
a

Andrea Prearo

07/07/2020, 5:24 PM
I’m trying to build an umbrella framework that bundles two subprojects. Here’s my project structure:
Copy code
|- shared-libraries
 \- network
  |- network-core
  |  |- src
  |  |  \- commonMain
  |  \- build.gradle.kts
  |
  |- network-ktor
  |  |- src
  |  |   \- commonMain
  |  \- build.gradle.kts
  |
   \- build.gradle.kts
The
network
module build script has the following dependencies: •
api(project(":shared-libraries:network:network-core"))
api(project(":shared-libraries:network:network-ktor"))
Basically,
network
is an umbrella module that contains no source code. For Android, all works fine. I’m able to import
:shared-libraries:network
without issues. For iOS, I’m leveraging
FatFrameworkTask
(registered as
fatFramework
) to build the umbrella framework. When I run
./gradlew :shared-libraries:network:fatFramework
, Gradle compiles the code but it doesn’t create any iOS framework. I’m not sure why. Is there a better/easier way to create an iOS umbrella framework for a project structure like the one above?
r

russhwolf

07/07/2020, 5:56 PM
You might need to add a source file to
network
. Can be empty.
a

Andrea Prearo

07/07/2020, 5:56 PM
Will try that. Thanks!
r

russhwolf

07/07/2020, 5:57 PM
Alternatively, you might need to explicitly export the project dependencies in your framework block
a

Andrea Prearo

07/07/2020, 6:01 PM
I have
export(project(":shared-libraries:network:network-core"))
and
export(project(":shared-libraries:network:network-ktor"))
in the
network
script file. Gradle compiles the source code but it look like the link step is never executed.
Adding a source file to
network
is actually triggering
linkDebugFrameworkIosSim
. simple smile Now, I need to solve the following error:
Copy code
Following dependencies exported in the debugFramework binary are not specified as API-dependencies of a corresponding source set
r

russhwolf

07/07/2020, 6:04 PM
oh yeah I guess you needed both those things 🙂
That error sounds like it's not seeing your framework exports as the same thing as the project dependencies. Not sure why that would be off-hand
Might be you need to use the groupartifactversion syntax instead of project
a

Andrea Prearo

07/07/2020, 6:06 PM
I’ll try that and see what happens.
Actually, during my tests, I ended up adding
export(project(":shared-libraries:network:network-core"))
. Which was likely the reason of the above Gradle error (I guess due to a circular dependency).
Adding an empty source file, as you initially suggested, appears to do the trick. Gradle is now generating
granular_auth.framework
.
r

russhwolf

07/07/2020, 6:15 PM
nice!
a

Andrea Prearo

07/07/2020, 6:16 PM
Thanks again @russhwolf!
👍 1
s

svyatoslav.scherbina

07/08/2020, 11:02 AM
Also please avoid using
network
as module name. There are known issues in stable releases, it might clash with
Network
platform library.
a

Andrea Prearo

07/08/2020, 1:29 PM
Will do. Thanks!
35 Views