hi,
I'm trying to add AFNetworking to IDEA sample Kotlin/Native project.
AFNetworking is built with carthage and saved as iosApp/Carthage/Build/iOS/AFNetworking.framework.
My AFNetworking.def contains the following:
language = Objective-C
package = com.afnetworking
headers = AFNetworking.h
headerFilter = **
compilerOpts = -framework AFNetworking
compilerOpts = -I /absolute/path/for/AFNetworking.framework/Headers
linkerOpts = -framework AFNetworking
linkerOpts = -F /absolute/path/for/AFNetworking.framework
and my build.gradle like this:
def iOSPath = new File('../iosApp/Carthage/Build/iOS').absolutePath
interop('AFNetworking') {
defFile 'src/nativeInterop/cinterop/AFNetworking.def'
compilerOpts "-F${iOSPath}"
linkerOpts "-F${iOSPath}"
includeDirs "${iOSPath}/AFNetworking.framework/Headers"
}
framework('app') {
libraries {
artifact 'AFNetworking'
}
linkerOpts '-rpath', '@executable_path/Frameworks'
linkerOpts "-F${iOSPath}"
}
then I invoke AFNetworking API at iosMain Module, but throw error like this:
Task :app:linkDebugFrameworkIos
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_AFHTTPResponseSerializer", referenced from:
objc-class-ref in combined.o
"_OBJC_CLASS_$_AFHTTPSessionManager", referenced from:
objc-class-ref in combined.o
ld: symbol(s) not found for architecture x86_64
How to solve this problem???
I checked your docs, but didn't manage to find an answer.
Any help is appreciated.
In your .def file there are two lines:
linkerOpts = -framework AFNetworking
linkerOpts = -F /absolute/path/for/AFNetworking.framework
The problem is that the second one overrides the first one, so the linker doesn't get -framework AFNetworking option.
Thx for SvyatoslavScherbina, I'll keep trying...
another small question... how can I use relative path in .def file??
You can define just frameworks names in a def file and then a path where to look for frameworks in a gradle file. The same works with headers.
Thx ildarsharafutdinov, it works...
@AalenLuLu mind to share how you made it works? :)
Most helpful comment
@AalenLuLu mind to share how you made it works? :)