Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages that contain tools (e.g. swift-markdown) don't seem to build on iOS #1299

Closed
helje5 opened this issue Oct 16, 2021 · 12 comments
Closed

Comments

@helje5
Copy link

helje5 commented Oct 16, 2021

unable to resolve product type 'com.apple.product-type.tool' for platform 'iphoneos'

To follow up our discussion in SwiftPackageIndex/PackageList#1356 (comment)

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
@helje5
Copy link
Author

helje5 commented Oct 16, 2021

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.

@finestructure
Copy link
Member

This seems to be affecting both iOS and tvOS targets. For instance also for swift-parsing:

CleanShot 2021-10-28 at 08 56 34@2x

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')

@finestructure
Copy link
Member

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

@finestructure
Copy link
Member

Boris seems to think this is a bug and advised me to file a FB: FB9775323

@finestructure
Copy link
Member

I'm keep seeing packages fail with this, for instance swift-json is right now:

CleanShot 2022-03-02 at 15 54 22@2x

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')

@finestructure
Copy link
Member

finestructure commented Mar 2, 2022

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"

@tayloraswift
Copy link

is there anything swift-json can do to get the builds working again?

@finestructure
Copy link
Member

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 :(

@tayloraswift
Copy link

tayloraswift commented Apr 7, 2022

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

@liuliu
Copy link

liuliu commented Jun 10, 2022

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

@finestructure
Copy link
Member

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

@finestructure
Copy link
Member

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!

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

No branches or pull requests

4 participants