alpaca-core / ac-local

Alpaca Core local inference SDK
MIT License
1 stars 0 forks source link

swift: Add ObjC wrapper of the API #136

Closed pminev closed 1 month ago

pminev commented 1 month ago

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:

@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

So now we have:

pminev commented 1 month ago

I'll close this PR, since we decided we're going to make a swift wrapper only with additional cocoa wrapper for the Dict.