Skip to content

Conversation

@kkebo
Copy link

@kkebo kkebo commented Oct 23, 2025

IMHO, it would be better to use $(xcrun -f swift) ("find" mode) instead of xcrun swift ("run" mode).

xcrun swift is fine with packages that do not contain executableTarget, but it causes the following errors with packages that contain executableTarget:

clang: warning: using sysroot for 'MacOSX' but targeting 'iPhone'
[-Wincompatible-sysroot]

To prevent this, we can use $(xcrun -f swift) instead of xcrun swift.

Related discussion:
https://forums.swift.org/t/getting-incompatible-sysroot-warning-when-compiling-for-ios-with-sdk-and-target-set/80584

You can easily reproduce this issue by the following steps:

mkdir foo && cd foo
swift package init --type executable --name Foo
xcrun swift build --sdk "$(xcrun --sdk iphoneos --show-sdk-path)" --triple arm64-apple-ios

IMHO, it would be better to use `$(xcrun -f swift)` ("find" mode)
instead of `xcrun swift` ("run" mode).

`xcrun swift` is fine with packages that do not contain
`executableTarget`, but it causes the following errors with packages
that contain `executableTarget`:

```
clang: warning: using sysroot for 'MacOSX' but targeting 'iPhone'
[-Wincompatible-sysroot]
```

To prevent this, we can use `$(xcrun -f swift)` instead of `xcrun
swift`.

Related discussion:
https://forums.swift.org/t/getting-incompatible-sysroot-warning-when-compiling-for-ios-with-sdk-and-target-set/80584
@kkebo kkebo requested a review from a team as a code owner October 23, 2025 15:41
@shahmishal
Copy link
Member

@grynspan would like to get you feedback here

@grynspan
Copy link
Contributor

Fine with me!

@jakepetroules
Copy link
Contributor

jakepetroules commented Oct 24, 2025

To be clear, building for iOS isn't really supported with swift build today, so this is kind of a best-effort situation at the moment and a bit clunky to get it to build at all. Once we have the new Swift Build backend in place, it will become formally supported though (and I already got it working in main). The correct invocation will then become:

swift build --build-tests --triple arm64-apple-ios

without needing to mess with xcrun or manually pass down the sysroot.

I'm fine with having the workflow up in the meantime though, as it's still useful for the cases where it does work. The invocation you have now looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants