"fatalError" when generating Xcode project with Xcode 10.2/Swift 5

I've updated swift-format to support the Swift 5 version of SwiftSyntax in this branch, but I've hit a problem when I try to generate the Xcode project. When I run swift package generate-xcodeproj, it gets through fetching some of the dependencies but then dies with fatalError and no other information.

I've pinpointed the problem down to the CCommonMark target; if I comment it (and its dependents) out, the project is generated correctly.

Did something change in the expected layout of C modules or the generation of Xcode targets for them that would cause it to die here? I haven't had a chance to dig into debugging it further, but my hunch is that the failing line is this one, but there aren't any other error diagnostics emitted so there's nothing to indicate what's happening.

(If you check out the format-swift5 branch to reproduce, make sure you grab the git submodules as well to pick up the swift-cmark sources.)

cc: @Aciid

Nvm, I can reproduce. I am taking a look now.

1 Like

Ok, I've figured out the cause of the issue. It's because SwiftPM is incorrectly querying git for ignored files in the submodule. You can workaround this by using --skip-extra-files flag which will bypass the code path that has the bug. Another option is converting cmark into an actual package dependency. I'll file a JIRA for the underlying bug.

Edit: Filed [SR-10181] Xcodeproj's skip extra file feature doesn't work correctly when there are submodules · Issue #4721 · apple/swift-package-manager · GitHub


Sounds good, I'll try that. Thanks!

@Aciid Is this the same thing I filed a coupla weeks ago? [SR-10103] SPM generate-xcodeproj fails on Swift 5 with "fatalError" · Issue #4724 · apple/swift-package-manager · GitHub

1 Like

Could be, do you have a submodule? Does this go away if you use --skip-extra-files?

Just hit this bug with Xcode 10.2 on one of my SPM packages that uses git submodules.

$ swift package generate-xcodeproj 
error: fatalError

Can confirm that using this command works around the issue:

$ swift package generate-xcodeproj --skip-extra-files
generated: ./ENetSwift.xcodeproj
1 Like

Seems to be in building order with --skip-extra-files, yup!

1 Like

Cool, I’ll fix this soon.

Just confirmed that this resolved it for us too. Thanks again!