rules_xcodeproj icon indicating copy to clipboard operation
rules_xcodeproj copied to clipboard

Add support to custom toolchains

Open 0xLucasMarcal opened this issue 11 months ago • 0 comments

Changes

This PR adds support for custom toolchains in rules_xcodeproj by replacing hardcoded references to $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain with the more flexible $TOOLCHAIN_DIR environment variable. This enhancement enables developers to use alternative toolchains with Xcode projects generated by rules_xcodeproj.

Key modifications include:

  • Updated script references in generated Xcode schemes to check for $TOOLCHAIN_DIR and use it when available
  • Modified toolchain path resolution in swiftc_stub to prioritize $TOOLCHAIN_DIR when set
  • Updated system lib symlink creation for sanitizer support to use the custom toolchain's libraries
  • Updated clang.sh and ld to respect custom toolchain configuration
  • Updated test fixtures to reflect the new scheme generation approach
  • For backward compatibility, the original Xcode default toolchain paths are maintained as a fallback when $TOOLCHAIN_DIR is not set, ensuring existing projects continue to work as expected.

Benefits

  • Allows projects to use custom Xcode toolchains
  • Enables sanitizer instrumentation with custom toolchains
  • Provides a more flexible development experience with rules_xcodeproj

Testing

All test fixtures have been updated and verified to work with both default and custom toolchains.

0xLucasMarcal avatar Mar 08 '25 17:03 0xLucasMarcal