XcodeProj icon indicating copy to clipboard operation
XcodeProj copied to clipboard

Fix compilation issues on iOS platform

Open nmcc24 opened this issue 1 month ago • 3 comments

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

nmcc24 avatar Nov 25 '25 11:11 nmcc24

@fortmarek @cschmatzler @asmitbm could you please take a look at this and let me know your thoughts? Thanks a lot

nmcc24 avatar Dec 01 '25 10:12 nmcc24

@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.

pepicrft avatar Dec 05 '25 16:12 pepicrft

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 avatar Dec 12 '25 11:12 nmcc24

@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]))
])

pepicrft avatar Dec 19 '25 15:12 pepicrft