How can I use the content of a .a static objc library file in a Swift static library project

Hi!

I have a objc static lib with some depending framework files. I want to build a kind of wrapper to intercept some functions of the objc library. How can this be done? It's no problem to use the static lib and the framework files within a App-Target but I don't understand what to do to build a Swift static lib that uses this lib?

Thanks!

I don't understand what to do to build a Swift static lib that uses this lib?

There’s nothing fundamentally impossible about using an [Objective-]C static library from Swift. The approach I recommend is that you package the library and its headers into an XCFramework, which you can then import and use directly from Swift. The only potential roadblock is that the [Objective-]C must be modularised.

I want to build a kind of wrapper to intercept some functions of the objc library.

What do you mean by “intercept”? To intercept a call there must be a caller and a callee. The callee is the static library, obviously. But who is the caller?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Okay... I expressed myself a little misleadingly. I have a static lib (objc) which itself has several framework files as dependencies. I want to create a static lib, in Swift or Objc, that has the same functionality however I want to wrap some functions. For example, there is a Connect method in the library that connects to a device via BLE. Here I would then like to do a database query in addition for example. Is there a way to do this?

For example, there is a Connect method in the library that connects to a device via BLE.

So, to summarise:

  • Your static library contains an Objective-C class.

  • That class has a connect method that calls a framework.

  • You want to direct that call to your own code.

Is that right?

Is the framework a system framework, so Core Bluetooth? Or some other framework that wraps the system framework?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How can I use the content of a .a static objc library file in a Swift static library project
 
 
Q