antlr4 icon indicating copy to clipboard operation
antlr4 copied to clipboard

Building Swift runtime failed when running `swift package generate-xcodeproj` in boot.py

Open youny626 opened this issue 1 year ago • 3 comments

I am building the Swift runtime by running python boot.py --gen-xcodeproj in antlr4/runtime/Swift (following the instructions in https://github.com/antlr/antlr4/blob/master/doc/swift-target.md) I got this error:

warning: 'antlr4': Invalid Exclude '/Users/zhiruzhu/Desktop/Apple-Escrow/antlr4/runtime/Swift/Tests/Antlr4Tests/runtime/Swift/Tests/VisitorCalc.g4': File not found.
warning: 'antlr4': Invalid Exclude '/Users/zhiruzhu/Desktop/Apple-Escrow/antlr4/runtime/Swift/Tests/Antlr4Tests/runtime/Swift/Tests/VisitorBasic.g4': File not found.
warning: 'antlr4': Invalid Exclude '/Users/zhiruzhu/Desktop/Apple-Escrow/antlr4/runtime/Swift/Tests/Antlr4Tests/runtime/Swift/Tests/LexerA.g4': File not found.
warning: 'antlr4': Invalid Exclude '/Users/zhiruzhu/Desktop/Apple-Escrow/antlr4/runtime/Swift/Tests/Antlr4Tests/runtime/Swift/Tests/Threading.g4': File not found.
warning: 'antlr4': Invalid Exclude '/Users/zhiruzhu/Desktop/Apple-Escrow/antlr4/runtime/Swift/Tests/Antlr4Tests/runtime/Swift/Tests/LexerB.g4': File not found.
error: Unknown subcommand or plugin name ‘generate-xcodeproj’
Usage: swift package <options> <subcommand>
  See 'package -help' for more information.
Error: command 'swift package generate-xcodeproj' exited with status 64

Here's my swift version

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0

It seems like generate-xcodeproj is already removed from Swift. Could you help solve this?

youny626 avatar Feb 05 '24 21:02 youny626

For a quick fix, I suspect you might have to fallback to a version of Swift that supports this command. See https://medium.com/xcblog/switching-swift-versions-inside-xcode-using-toolchains-755b28831c43

But you are also welcome to provide a PR that updates boot-py to support recent versions of Swift that no longer require or support ‘generate-xcodeproj’

ericvergnaud avatar Feb 05 '24 21:02 ericvergnaud

According to https://forums.swift.org/t/rfc-deprecating-generate-xcodeproj/42159 generate_package is deprecated. So I commented out the call "swift package generate-xcodeporj" on line 172. However I don't see a Package.swift file which should have been generated by: check_call([java, "-jar", a4, "-Dlanguage=Swift", grammar, "-visitor", "-o", grammar_folder + "/gen"]) Otherwise what would the call "swift package generate-xcodeporj" have to generate an Xcode project from?

digitalloophole avatar Feb 23 '24 02:02 digitalloophole

According to https://forums.swift.org/t/rfc-deprecating-generate-xcodeproj/42159 generate_package is deprecated. So I commented out the call "swift package generate-xcodeporj" on line 172. However I don't see a Package.swift file which should have been generated by: check_call([java, "-jar", a4, "-Dlanguage=Swift", grammar, "-visitor", "-o", grammar_folder + "/gen"]) Otherwise what would the call "swift package generate-xcodeporj" have to generate an Xcode project from?

I actually figured it out. I also commented out the line swift package generate-xcodeproj and ran boot.py. Then I manually created the swift package by roughly following this guide https://developer.apple.com/documentation/xcode/creating-a-standalone-swift-package-with-xcode and configuring the Package.swift file. Then I added the package as a local package dependency to my own xcode project.

youny626 avatar Feb 23 '24 02:02 youny626