I has a SDK named ProductSDK. This SDK also have two dependency sdks.
- CommonDependencySDK
- AdvanceDependencySDK
And try to generate XCFramework in ProductSDK. My use case is, 2 types of use case in this ProductSDK. One is ProductSDK with CommonDependencySDK and another one is ProductSDK with CommonDependencySDK and AdvanceDependencySDK. Handle this case using some macros in my ProductSDK.
But now i need two version of XCFramework for my ProductSDK. One version is compiled ProductSDK source with CommonDependencySDK and another one is ProductSDK source with CommonDependencySDK and AdvanceDependencySDK.
Anyone have any ideas to this use case?
Or what is a alternative way of handling optional dependency instead of macros.
#if canImport(SDKName)
// Some codes
#else
// Some codes
#endif
CodePudding user response:
XCFrameworks
are supposed to replace universal frameworks by incorporating binaries of the target library for different platforms. Nothing changed in regards to including dependencies under the frameworks, however. Such approach is commonly called "umbrella" frameworks and are considered a bad practice.
What you are supposed to do instead is to instruct your end-users to link their projects against dependencies your framework relies on, and suggesting that only one dependency is required, while the other just expands the functionality.
For the part how to implement optionally linked frameworks, it was already answered here and here.