emqx / CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
https://www.emqx.com/en
Other
1.58k stars 413 forks source link

XCFramework support #464

Open hhrvoic opened 2 years ago

hhrvoic commented 2 years ago

When exporting this library as a .xcframework users will get errors inside inside .swiftinterface file when including it in the project:

image

The name of the type/class (CocoaMQTT) and the module (CocoaMQTT) are the same so they clash in the .swiftinterface file. Compiler thinks that all the types are under CocoaMQTT class, not under the CocoaMQTT module => limitation where if a module and a type have the same name, as usage is assumed to be the type first. One of the simpler ways of avoiding this is to rename the CocoaMQTT class to something else. This would however be the breaking change.

Similar issue: https://github.com/parse-community/Parse-SDK-iOS-OSX/issues/1601

leeway1208 commented 2 years ago

Hi, I guess you want to call swift method in OC language?

hhrvoic commented 2 years ago

Hi, no, using CocoaMQTT in Swift project, the issue is when you want to export this library as a .xcframework and embed it as such in the project. These ⬆️ are the errors that pop up since the class name (CocoaMQTT) is the same as the library name (CocoaMQTT).

leeway1208 commented 2 years ago

I think the quickest way is change the class name from (CocoaMQTT) to (project)CocoaMQTT or something else.

hhrvoic commented 2 years ago

Yeah, not sure about naming conventions on this project so I guess it's anything that works :) I see there is a CocoaMQTT5 class for the v5 of the protocol, maybe the original one which is used for the 3.1.1. could be renamed the CocoaMQTT3?

hhrvoic commented 1 year ago

This is also now represented as a warning in Xcode. https://github.com/apple/swift/issues/56573

Screenshot 2023-07-06 at 15 50 53

Any plans with this?