bustoutsolutions / siesta

The civilized way to write REST API clients for iOS / macOS
https://bustoutsolutions.github.io/siesta/
MIT License
2.19k stars 159 forks source link

Siesta works with Objective-C++ with the exception of BOSService #239

Open enzuru opened 6 years ago

enzuru commented 6 years ago

Some background: I work for a company that has created an SDK in Swift that is being used by an Objective-C++ videogame.

While I know Objective-C++ is not supported officially (as per the comment here: http://codejaxy.com/q/327866/ios-objective-c-xcode7-siesta-swift-how-to-get-started-using-siesta-with-objective-c) it would appear that our Swift-wrapped Siesta-based SDK works perfectly for the videogame with the exception of importing the BOSService into the mm file.

With so much of Siesta working, addressing this small issue would appear to get us to complete Objective-C++ support. For now, we are simply manually changing the header by commenting this section out to get it to work:

/*
SWIFT_CLASS("_TtC9VersusSDK6SDKAPI")
@interface SDKAPI : BOSService
@end
*/

I'd be more than willing to lend my hand to any solution that needed to be coded. I'm presently doing research on the problem, and would love any feedback that you may have.

pcantrell commented 6 years ago

One thought: it looks like your SDKAPI class subclasses Service. Instead of subclassing, try holding an internal Service reference inside SDKAPI and making it a facade for Siesta’s Service API, much as the GithubBrowser example does. Based on what you commented out, that might solve your issue.

I'm afraid I have no other useful feedback: I have not investigated Objective-C++ support for Siesta, have no knowledge of Obj-C++ / Swift interop, and know nothing about this issue in particular. You are pretty much on your own figuring it out! But I would happily accept a pull request if you do find a solution.

wildthink commented 6 years ago

Umm.. This is a shot in the dark but if this works in a .m file have you tried adding a level of indirection? Something like...

ObjCSDKAPI.h (with a .m)

@interface ObjCSDKAPI : BOSService
@end

Then use the ObjCSDKAPI in your ObjC++ .h/.mm.