Has anyone been able to use the <new shared lib in...
# multiplatform
m
Has anyone been able to use the new shared lib integration method in iOS apps with multiple projects? My app is made of a few projects and all of them depend on the shared lib, currently I have a target for a shared framework where I call
copyFramework
in its build phases, this target is then included in all projects. I have tried adding it by changing
copyFramework
to the new
embedAndSignFrameworkForXCode
which didn’t work (project won’t compile because it can’t find the shared lib
No such module 'shared'
. Also tried removing this target entirely and recreating the steps in the blog post in every project, but it also didn’t work.
i
I was able to make it work by following the directions but calling the Gradle tasks directly fails
r
The instructions don't call it out, but the Xcode setup needs to change slightly if you have a different module name or framework name. Is your shared module called something other than
shared
?
m
Yeah the task is supposed to be called from Xcode only. It doesn't work from the CLI. @russhwolf Yeah my module is called differently from
shared
but I've adjusted that in gradle by setting the framework's
baseName
and making the adjustments in Xcode where appropriate
r
So are you getting
No such module 'shared'
or is the error reporting your actual module name?
m
It's reporting the actual name, sorry if it wasn't clear
For example
Copy code
import MobileCommonLib              --> No such module 'MobileCommonLib'
r
oh it's the Swift side giving the error, not the gradle build. I misunderstood
m
The projects setup in XCode is something like this:
Copy code
ios_common_X
ios_common_Y
ios_feature_A
ios_feature_B
app
where all the projects depend on the shared lib.
Yes, it's the iOS side that's giving me headaches
I also tried setting up with cocoapods instead, but adding the pod to all projects causes another set of errors: A warning for all classes:
Copy code
Class X is implemented in both module A and mobule B. One of the two will be used, which one is undefined
and this runtime exception
Copy code
Unable to add 'toKotlin:' method to NSBLock class
r
Did you have it working with copyFramework? There are a lot of limitations when you try to include Kotlin in multiple ios modules
m
It's working with
copyFramework
. Under the
app
project we have a target called
MobileCommonLib
which calls
copyFramework
in its build phases. Then, every module in iOS have it as a dependency.
r
Does the
embedAndSignFrameworkForXCode
task succeed? Maybe there's just a name mismatch somewhere
m
Is there any way to check that from XCode? Since the task doesn't run from cli
r
You should be able to see build outputs in the report navigator. It's the rightmost tab in the left pane
m
It says
Task :common:embedAndSignAppleFrameworkForXcode UP-TO-DATE
but I don't see the compiled framework anywhere in my iOS folder
Also ran after a
./gradlew clean
and it completes successfully
r
I'm not sure, then. Maybe the framework is being generated with the wrong name or something?
m
In my shared module build folder I can find it under
xcode-frameworks/Debug/iphonesimulator14.5/
with the correct name a folder
MobileCommonLib.framework
and a file
MobileCommonLib.framework.dSYM
I guess it's expected now that the framework isn't copied anymore, since we set
Framework search path
to the build folder
Just noticed that the
SDK_NAME
folder from
Copy code
$(SRCROOT)/../shared/$(CONFIGURATION)/$(SDK_NAME)
is resolved as
iphoneos14.5
in XCode, while it's generating
iphonesimulator14.5
not sure it makes a difference.
Manually changing the folder name still doesn't work