SwiftPackageIndex-Server
SwiftPackageIndex-Server copied to clipboard
Packages that contain tools (e.g. swift-markdown) don't seem to build on iOS
unable to resolve product type 'com.apple.product-type.tool' for platform 'iphoneos'
To follow up our discussion in https://github.com/SwiftPackageIndex/PackageList/pull/1356#issuecomment-944908922
E.g.: https://swiftpackageindex.com/builds/40779886-68B0-4CA9-9B6E-EE3F6797CF42
env DEVELOPER_DIR="/Applications/Xcode_13.0_beta_5.app" xcrun xcodebuild -IDEClonedSourcePackagesDirPathOverride="$PWD/.dependencies" -derivedDataPath "$PWD/.derivedData" build -scheme "swift-markdown-Package" -destination "generic/platform=ios"
Resolved source packages:
swift-argument-parser: https://github.com/apple/swift-argument-parser @ 0.4.4
cmark-gfm: https://github.com/apple/swift-cmark.git @ gfm
swift-markdown: ${cwd}
note: Using new build system
note: Planning
Analyze workspace
Create build description
Build description signature: 2f1f100b39dada6c69a72028a2d09291
Build description path: ${cwd}/.derivedData/Build/Intermediates.noindex/XCBuildData/2f1f100b39dada6c69a72028a2d09291-desc.xcbuild
note: Build preparation complete
note: Building targets in parallel
error: unable to resolve product type 'com.apple.product-type.tool' for platform 'iphoneos' (in target 'markdown-tool' from project 'swift-markdown')
Resolve Package Graph
** BUILD FAILED **
FAILURE 5.5 ios
Do you know what the build command should look like? If it's something that we could run generally it should be quite easy to fix. If we need to make it dependent on particular contents of Package.swift that'll be a but trickier.
No idea either. If I'm working w/ such a project within Xcode, the "default" just seems to work. So I'm not sure what is different.
This seems to be affecting both iOS and tvOS targets. For instance also for swift-parsing:
These both fail with errors like
error: unable to resolve product type 'com.apple.product-type.tool' for platform 'appletvos' (in target 'swift-parsing-benchmark' from project 'swift-parsing')
I've searched the web a bit but didn't find anything useful. This issue here was the fourth result, giving me high hopes when I scanned the title! :D
I've asked on the SwiftPM slack if anyone has any pointers: https://swiftpm.slack.com/archives/C0XFJBKUL/p1635405297012400
Boris seems to think this is a bug and advised me to file a FB: FB9775323
I'm keep seeing packages fail with this, for instance swift-json is right now:
error: unable to resolve product type 'com.apple.product-type.tool' for platform 'iphoneos' (in target 'examples' from project 'swift-json')
error: unable to resolve product type 'com.apple.product-type.tool' for platform 'appletvos' (in target 'examples' from project 'swift-json')
error: unable to resolve product type 'com.apple.product-type.tool' for platform 'watchos' (in target 'examples' from project 'swift-json')
I've just run the test case I reported via Feedback with Xcode 13.3.0b3 and that actually starts the build but then fails with
** BUILD FAILED **
The following build commands failed:
CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler (in target 'ParsingTests' from project 'swift-parsing')
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'ParsingTests' from project 'swift-parsing')
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'swift-parsing-benchmark' from project 'swift-parsing')
Ld /Users/sas/Library/Developer/Xcode/DerivedData/swift-parsing-fwlawalatglidnevlwqdczqotaen/Build/Intermediates.noindex/swift-parsing.build/Debug/swift-parsing-benchmark.build/Objects-normal/arm64/Binary/swift-parsing-benchmark normal arm64 (in target 'swift-parsing-benchmark' from project 'swift-parsing')
(4 failures)
which is cryptic. Re-running the command just hangs indefinitely 🤷
Test is:
git clone --branch 0.3.1 https://github.com/pointfreeco/swift-parsing && cd swift-parsing
env DEVELOPER_DIR=/Applications/Xcode-13.3.0-Beta.3.app xcodebuild build -scheme "swift-parsing-Package" -destination "generic/platform=ios"
is there anything swift-json can do to get the builds working again?
I think this is related to plugins. I'm not sure if it's an option for swift-json to drop the plugin from the manifest or make it conditional somehow but I'd image that might help.
Other than that duplicating the Feedback or prodding someone who might be able to address it in xcodebuild seems to be our only option at this point :(
i don’t think this is related to plugins, because the swift-grammar package uses the same plugin swift-json uses, and its 5.6 builds are working
if it’s related to plugins, it would have to be in combination with another factor...
It seems to be some weirdness with Xcode. If you build the Package for (any iOS) in Xcode, it will still build all executables, and cause all kinds of weird issues.
One way to solve this is to add target in .spi.yml so the build command instead of doing XXX-Package, can do XXXX directly, and side-step this issue: https://github.com/SwiftPackageIndex/SPIManifest/blob/main/Sources/SPIManifest/Manifest.swift#L21
Ah, that's good to know as a work-around - thank you @liuliu !
One thing to note: you'll want to set scheme, not target. We still need to document this better: target controls the target for SPM builds (swift build), while scheme controls the scheme for Xcode builds (via xcodebuild).
It doesn't look like this is happening anymore. Both swift-parsing and swift-json build on iOS and swift-markdown fails for another reason.
I'll go ahead and close this for now, please reopen if this continues to be an issue!