I would like to import [libphonenumber] into the 'common' part of a KMP project, but Kotlin can't import it. I see the library added twice to the external libraries after I added the maven url. But, the import in Kotlin can't resolve the library, so I can't use the libraries classes. What am I missing?
libphonenumber isn't a Kotlin Multiplatform library. It seems to support many platforms, so you could write library wrappers for Kotlin.
I gave a talk about writing platform wrapper libraries: https://vimeo.com/371460823
If the target for native is C++, you'll likely need to write some C wrappers. Just FYI.
Related
I have a C library that contains other C library (WolfSSL, nanopb) dependencies.
I want to (ideally) build a swift package that contains my code referencing the main C library. I would then be able to distribute this package for others to integrate my library into their code.
There is a lot of information between using SPM, XCFramework, and other avenues but nothing that points to the scenario that I am trying to work with.
Is there a standardized way of accomplishing what I want?
I have a project that is fully built using SPM. There's one specific library that I want to use that only provides support to CocoaPods. I thought about sending a PR adding support to SPM to that library, but the library also depends on other libraries that also don't provide support to SPM.
In this scenario, there's something that can be done to stick with an SPM project structure and also be able to access the Cocoapods dependency?
I am new to iOS development. I have ample experience with Android Development.
In Android, I have a bunch of pre-built C static libraries. I also have C source code for another component. I build with the help of Android.mk in Android. As a part of the make file, I build a shared library(.so) by linking the static libraries and in turn use with JNI.
The following is a sample code in Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE:= module_name
LOCAL_C_INCLUDES := $(LOCAL_PATH)/filepath/include
LOCAL_SRC_FILES:= $(LOCAL_PATH)/filePath/filename1.c
LOCAL_SRC_FILES:= $(LOCAL_PATH)/filePath/filename2.c
LOCAL_LDLIBS:= -lm
LOCAL_STATIC_LIBRARIES:= static_lib1 static_lib2 ssl crypto
include $(BUILD_SHARED_LIBRARY)
I am porting the same project to iOS. SO, I am trying to use the same C source code and prebuilt C static libraries.
I have placed the files in Linked libraries in Build Phases but not use. I have read about module map, swift package manager, bridging header but not very clear.
Can anyone kindly help me with step by step process of this linking with the swift code?
Thank you
I'm little bit confused about which style of import should I use when importing implementation libraries (code under src/lib) from another libraries (and tests) in my own package?
The docs recommends the opposite options.
In pub docs, it says:
When you use libraries from within your own package, even code in src, you can (and should) still use package: to import them.
But in "Effective Dart", it says:
When referencing a library inside your package’s lib directory from another library in that same package, use a relative URI, not an explicit package: URI.
In the end, which style should I use in such cases:
import implementation library (under lib/src/) from with public library (under just lib/)?
import implementation library (lib/src/foo.dart) from within its test (test/src(?)/foo_test.dart)?
import public library (lib/foo.dart) from within its test (test/foo_test.dart)?
I have a static library, lets call it S - which is written in Objective-C. Now few people who support iOS-7 have started using Swift, as a result of which I have to give the interface to my functions also in Swift.
I know that we can use bridging headers to directly import Objective-C code into Swift (within same project), but how should I do it for my static library?
Also, I cannot have Swift files in my static library - as Swift is only supported by dynamic frameworks. So, if I make dynamic frameworks, I cannot then deploy this library for iOS-7.
The static library will become an integral part of the binary generated by the project linking to it. Therefore, including the headers of the static library in the bridging header should make its' functionality available from Swift code in that same project.
I figured it out. We need to make module.modulemap in the SDK (static library) and then the path to this module.modulemap needs to be added to Import Paths in Swift Compiler - Search Paths in Build Settings. Also, if the static library is being distributed via CocoaPods, podspec can be altered to do this setting automatically.