IIn the beginning I tried to do it with small objC wrap of the Dict only since I needed to transfer ac::Dict which was impossible in Swift due to type incompatibility. So I decided that I the rest will be in Swift to be more user-friendly. However, I started to hit another problems such as the types from the ObjC++ which were used as return types from the Swift library were not visible to the final application.
I had the following code:
@interface ACModel
@end
// ModelDesc comes from C++ struct
func createModel(desc:ModelDesc, params:Dictionary<String,Any>) -> ACModel {
...
}
When I had the ACModel* as return type the function was not exported, when I removed it, the function was visible. So, I couldn't figure out what was the original problem.
After some more thinking I decided that maybe 2 depending libraries are too much for a start plus the problem above, so what about to have single ObjC wrapper which was fully compatible with Swift. This will reduce dependencies and make my life easier, so that's why I decided to continue with that approach.
More context of how is the infrastructure
CAlpacaCore - ObjC wrapper of ac::local
depends on AC api - must have include dirs + library
DummyInference - ObjC wrapper of ac::local-dummy
DummyExample - Swift example of the AC ObjC wrapper
depends on ObjC wrapper
depends on local AC api to use ModelDesc struct - we need to provide module.modulemap which exposes the C++ structure to Swift
depends on ObjC DummyInference library - in order to provide a ModelLoader for the ModelFactory
So now we have:
ObjC wrapper of AlpacaCore SDK
ObjC wrapper of DummyInference library
Swift console application with an Example which uses the DummyInference with AlpacaSDK
Tests for the wrapping/unwrapping of the ac::Dict into NSDictionary (fully compatible with Swift's Dictionary)
the issue is: #120,
Swift wrapper
IIn the beginning I tried to do it with small objC wrap of the Dict only since I needed to transfer ac::Dict which was impossible in Swift due to type incompatibility. So I decided that I the rest will be in Swift to be more user-friendly. However, I started to hit another problems such as the types from the ObjC++ which were used as return types from the Swift library were not visible to the final application.
I had the following code:
When I had the ACModel* as return type the function was not exported, when I removed it, the function was visible. So, I couldn't figure out what was the original problem.
After some more thinking I decided that maybe 2 depending libraries are too much for a start plus the problem above, so what about to have single ObjC wrapper which was fully compatible with Swift. This will reduce dependencies and make my life easier, so that's why I decided to continue with that approach.
More context of how is the infrastructure
ModelDesc
struct - we need to provide module.modulemap which exposes the C++ structure to SwiftModelLoader
for theModelFactory
So now we have: