I have now built a framework from a MPP project th...
# kotlin-native
c
I have now built a framework from a MPP project that in importing 2 framework via cinterops. However when I tried to import it into XCode the header seems to be generated with reserved words:
@property (readonly) Passport_reader_commonMapper *default;
or
@property (readonly) double double;
which prevent the frameword to be built in my iOS app. Any idea on a workaround?
r
I had such problems when using
export
incorrectly with
transitiveExport
s
Yes. Just rename corresponding Kotlin declarations.
c
I believe they come from the transitive options that I set. If I remove it I assume I'll have some issues at runtime
Since there come from transitive dependencies I can't really rename them...
r
transitiveExport = true
is evil.
s
If I remove it I assume I’ll have some issues at runtime
Why do you think so?
c
I thought I'd needed all the dependency so that the framework is 'standalone'?
Oh the transitive option is just about declaring/exposing the dependency in the result headers ?? And not about packaging
s
No. Exporting includes additional declarations to the framework API. If you don’t need these declarations to be included to the API, you don’t have to export anything explicitly.
c
Ok I understand thank you very much! I'll let you know if this solved the problem
it worked, at least for the reserved word, I am yet to execute it...other issues. Thx guys
👍 1
so now when I launched my app on iOS I have an error as one of the original framweork (binded via cinterops) is not found whereas it is referenced by the fat framework (as it should)
r
You need to include the iOS framework as a dependency of the XCode project
c
I thought I could create just one big framework and it will reference it indirectly. like a transitive dependency
r
It references it, but it’s not included. There are no transitive dependencies on iOS, you always have to add all dependencies of dependencies to XCode in the end. Your fat framework contains all Kotlin dependencies though.
c
Ok fair enough. Thanks a lot for the clarification. It now works
Because one of my framework (binded by
cinterops
) has a static library it is impossible to import the umbrella framework in the iOS project as I get warning a runtime where the definition comes from 2 places (the umbrella framework and the cocoapods - no choice there the Google library is only available via pods). And then at runtime I got some crashes because of wrong selectors. Those duplication message and the crashes are only caused by the google related methods. If you have any idea...
s
Why are you trying to import umbrella framework? Do you really need to use this Google library in both application and framework?
c
@svyatoslav.scherbina I only need the Google Lib in the initial
KotlinMppLib-Shared
, but I have to import in the ios app as all framework needs to be imported in the final app in iOS. Is there a better way? Here is the hierarchy:
Copy code
iOS app (import as framework: kotlinMPPLib-:Logic, Crypto, GoogleNearby via pods )
  ^
  |
  |-- KotlinMPPLib-Logic (published as Framework and aar) 
          ^
          |--  kotlinMPPLib-Shared(published as KLIB) 
                  ^
                  |--- Crypto Framework (in house built, cinterops bindings)
                  |
                  |--- Google Nearby (only available through cocoa pods, cinterops bindings)
s
but I have to import in the ios app as all framework needs to be imported in the final app in iOS
Why do you think so?
c
Because if I don't import the Google lib in my app, I have a startup crash where the implementation of a google method is not found I believe that creating a framework in Kotlin native only references the framework binded in cinteropds, it does not package them. Like a fat JAR would do.
Also I forgot to mention that this Google Lib contain a static library (
.a
) and has various transitive dependencies as framework
Perhaps the new feature
Static Apple frameworks can be produced
in 1.3.30-EAP could help in producing a jar with a static lib in it? but I have not found much info about how to use it?
s
Because if I don’t import the Google lib in my app, I have a startup crash where the implementation of a google method is not found
This doesn’t mean that all framework needs to be imported in the final app in iOS.
Static Apple frameworks can be produced
Yes, this would probably help. To use this feature, you can pass
-Xstatic-framework
to the compiler using
freeCompilerArgs
in Gradle.
o
From my experience static vs dynamic framework in Xcode projects brings a lot of confusion when dealing with transitive dependencies. To sum up: static binary is already embedded into whatever includes it (and hence does not need to be embedded in target App again). Dynamic framework has to always be embedded in target App (well, because it is only referenced but not embedded in the underlying frameworks). To quickly check what kind of binary you have in your dependency just run
file main.framework/main
and check output. Hope that helps
c
thanks guys, I was wondering if you could give me an example on how to use
freeCompilerArgs
I do not know which closure I can invoke this on
c
thank you