swift-sh icon indicating copy to clipboard operation
swift-sh copied to clipboard

Running script in iOS project as build-script fails

Open Jeehut opened this issue 5 years ago • 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.

Jeehut avatar Mar 28 '20 09:03 Jeehut

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

c0diq avatar Apr 01 '20 18:04 c0diq

Any update?

c0diq avatar Apr 07 '20 23:04 c0diq

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

Jeehut avatar May 21 '20 02:05 Jeehut

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

saijithendrag avatar Jul 10 '20 03:07 saijithendrag

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 avatar Jul 26 '20 21:07 mxcl

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

mxcl avatar Jul 26 '20 21:07 mxcl

2.0.1 has the fix. Please try!

mxcl avatar Jul 26 '20 22:07 mxcl

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

Jeehut avatar Jul 28 '20 07:07 Jeehut