mxcl/swift-sh

Running script in iOS project as build-script fails

Jeehut opened this issue · 8 comments

I've just tried to run a Swift script using swift-sh in the Xcode build scripts step in an iOS project and it failed with the following output:

using sysroot for 'iPhoneSimulator' but targeting 'MacOSX'
'Swift' was created for incompatible target x86_64-apple-ios13.0: /var/folders/c_/pt8g6s3x3h5gg4gznvyqthmc0000gn/C/org.llvm.clang.user/ModuleCache/Swift-3LLGH9HFMRPI6.swiftmodule

This seems to be a known issue (SR-9216 – feel free to click the "Vote for this issue" button) but it's open for over a year now, so I suggest we add a workaround into swift-sh and don't wait for it to be fixed.

The simplest workaround seems to be using #!/usr/bin/xcrun --sdk macosx swift, so we might want to use that to execute Swift as well somehow. See also this Swift Forums thread.

c0diq commented

I'm having the same problem after updating to Xcode 11.4

c0diq commented

Any update?

@mxcl Do you think you'll have time to take a look into this sometime soon? Build scripts are a very useful feature, I'd love to see this fixed, it's currently the biggest blocker for a version 1.0.0 release of AnyLint. I'd be willing to help if you can give me some guidance.

Try using /usr/bin/xcrun --sdk macosx swift-sh <path to script> instead of swift <path to script>.

mxcl commented

Hi everyone, I have finally got some time together to fix this.

I’m pretty sure the fix is a one liner.

It's depressing to me that my open source is totally dependent on what time I have to give it 😞

I'm not sure really what I could do to have made any of you felt confident enough to submit a PR.

mxcl commented

So, in theory #113 fixes it, but I could use a test-case.

mxcl commented

2.0.1 has the fix. Please try!

@mxcl I just ugpraded to 2.0.1 but I'm still having the same issue:

/Users/Jeehut/Library/Developer/swift-sh.cache/6cfae87d4ff40300d031fc7f93264221: error: manifest parse error(s):
<unknown>:0: warning: using sysroot for 'iPhoneSimulator' but targeting 'MacOSX'
<unknown>:0: error: unable to load standard library for target 'x86_64-apple-macosx10.15'
error: 1 <(/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift build -Xswiftc -suppress-warnings)

The funny thing is, when I switch to my macOS target, build (same build script there, running swift-sh lint.swift), then switch back to the iOS target, it seems to be magically working for a while. Really weird.