Hello, I am trying to add a framework to my KMP l...
# kotlin-native
z
Hello, I am trying to add a framework to my KMP library in order to use it in an iOS app. I get the error message:
Undefined symbols for architecture x86_64
I am not really sure about the right way to link this framework. I tried to add the headers of this framework to
compilerOpts
as well but it did not change anything. Is there anything I need to change or add in the def file or build.gradle? For now the linkerOpts looks like that in my def file:
Copy code
linkerOpts= \
 -F/absolute/path/to/MyFramework.framework \
 -framework AVFoundation \
 -framework Foundation \
 -framework CoreGraphics \
 -framework CoreVideo \
 -framework QuartzCore \
 -framework UIKit \
 -framework CoreLocation \
 -framework Security \
 -framework CFNetwork \
 -framework CoreMedia \
 -framework SystemConfiguration \
 -framework AudioToolbox
in my build.gradle
Copy code
iosX64("ios") {
    binaries {
        framework('Shared'){
            linkerOpts "-F/absolute/path/to/MyFramework.framework"
        }
    }

    compilations.main {
        cinterops {
            myCinterop {
                linkerOpts "-F/absolute/path/to/MyFramework.framework"
            }
        }
    }
k
i am assuming MyFramework.framework was not built for x86_64
but the linker will tell you which symbols are missing
z
It is supposed to build for x86_64. The structure of the folder MyFramework.framework is as follow:
Copy code
- MyFramework.framework
    - Headers
        - x86_64-iphonesimulator-gcc
        - x86-iphonesimulator-gcc
        - etc. with different architectures
   - a binary file without any extension
I wonder if my def file might be wrong. Is
-F/absolute/path/to/MyFramework.framework
the correct way to pass this framework to the linker as it is in my KMP project? Or do I need to add the headers and the binary file somewhere?
k
you do need to specify -framework to link it
z
I tried
-F/absolute/path/to/MyFramework.framework -framework MyFramework
but I get an error saying
MyFramework not found
So I thought it was not the correct way to do it, was it?
Or is it just
-F/absolute/path/to/MyFramework.framework -framework
?
never tried this one yet
k
-F/absolute/path/to/ -framework MyFramework
the same as linking any library
z
I tried that but I got the error
framework not found
I'll give it a try again.
Forget my last message I understand now. The path is the one of the parent's folder not the folder of the framework itself?
k
the path that the framework resides in
👍 1
🎉 1
when you link libfoo.a, you don't specify -Lpath/to/libfoo.a
z
Yes indeed. Make sense
Thank you very much!!! It's working now. I can build and run the app. I think because MyFramework.framework is a folder I thought that I had to pass the path to the folder MyFramework.framework and did not think about passing the path to the parent's folder