Fix compilation issues on iOS platform
Resolves https://github.com/tuist/XcodeProj/issues/1015
Short description 📝
Currently, XcodeProj is not compilable on iOS platform. This is an issue when attempting to compile products that have XcodeProj as a (transitive) dependency
Solution 📦
Add appropriate iOS compiler flag and version check to ensure symbols are available and guarantee successful compilation.
Implementation 👩💻👨💻
Detail in a checklist the steps that you took to implement the PR.
- [x] Add compiler flags
- [x] Add iOS version checks
- [x] Build XcodeProj target
- [x] Compile XcodeProj tests
@fortmarek @cschmatzler @asmitbm could you please take a look at this and let me know your thoughts? Thanks a lot
@nmcc24 this package was not designed for running on non-macOS platforms, so even if you make it compile, some features might not work. I'd suggest to use conditional linking when declaring a dependency on this package to specify that it should only link it when building against the macOS platform.
Hi @pepicrft thanks for your comment.
I completely understand and appreciate it, and in all honesty I don't think it would make any sense to run the targets on iOS.
However, it is impossible to restrict a swift package from being compiled on iOS ( if we don't declare the platform, it will fallback to a minimum version).
Having said that, and in the context of my problem where this transitive dependency is not allowing the compilation of a build plugin that will run at compile time of a product targeting the iOS platform, this suggested approach would solve this problem without bringing any side effect that doesn't already exist on any swift package.
I'm of course open to any other approaches that come to mind :)
@nmcc24 thanks a lot for the context, I appreciate it.
Wouldn't TargetDependencyCondition be useful in this case, where you can declare a dependency conditionally based on the platform:
Target(name: "MyTarget", dependencies: [
.product(name: "XcodeProj, condition: .when([.macOS]))
])