kkharji/xbase

Swift Compile Commands are Never Parsed

spenceryr opened this issue · 2 comments

Hello! I'm not sure if you've been using this tool when building with XCode 14, but I can't seem to get things to work with Swift files. I am building a Swift/Obj-C iOS framework but only the Obj-C files have a corresponding compile command in the .compile file. I think I can possibly attribute this to the XCode logs not matching up with the expected parseable outout. Here is my compile command:

xcodebuild build -configuration Debug -project MyProject.xcodeproj -target MyProject

and here is an example XCode log for compiling one of the files (I put things on new lines to make it prettier):

CompileSwift normal arm64 /Users/spencer/Documents/Repos/myproject/MyProject/Source/File1.swift (in target 'MyProject' from project 'MyProject')
    cd /Users/spencer/Documents/Repos/myproject
    /Applications/Xcode_14_0_1/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend 
      -c /Users/spencer/Documents/Repos/myproject/MyProject/Source/File1.swift 
      /Users/spencer/Documents/Repos/myproject/MyProject/Source/File2.swift 
      /Users/spencer/Documents/Repos/myproject/MyProject/Source/File3.swift  
      -emit-dependencies-path /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/arm64/ObjCDebugDescription.d 
      -emit-reference-dependencies-path /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/arm64/ObjCDebugDescription.swiftdeps 
      -serialize-diagnostics-path /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/arm64/ObjCDebugDescription.dia 
      -emit-dependencies-path /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/arm64/File1.d 
      -emit-reference-dependencies-path /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/arm64/File1.swiftdeps 
      -serialize-diagnostics-path /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/arm64/File1.dia 
      -target arm64-apple-ios13.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check 
      -sdk /Applications/Xcode_14_0_1/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk 
      -I /Users/spencer/Documents/Repos/myproject/build/Debug-iphoneos 
      -F /Users/spencer/Documents/Repos/myproject/build/Debug-iphoneos 
      -no-color-diagnostics -application-extension -enable-library-evolution -enable-testing -g -import-underlying-module -swift-version 5 -enforce-exclusivity\=checked -Onone -D DEBUG -serialize-debugging-options -enable-bare-slash-regex 
      -Xcc -working-directory -Xcc /Users/spencer/Documents/Repos/myproject 
      -resource-dir /Applications/Xcode_14_0_1/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift 
      -enable-anonymous-context-mangled-names 
      -Xcc -I/Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/swift-overrides.hmap 
      -Xcc -iquote -Xcc /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/MyProject-generated-files.hmap 
      -Xcc -I/Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/MyProject-own-target-headers.hmap 
      -Xcc -I/Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/MyProject-all-non-framework-target-headers.hmap 
      -Xcc -ivfsoverlay -Xcc /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/all-product-headers.yaml 
      -Xcc -iquote -Xcc /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/MyProject-project-headers.hmap 
      -Xcc -I/Users/spencer/Documents/Repos/myproject/build/Debug-iphoneos/include 
      -Xcc -I/Users/spencer/Documents/Repos/myproject/helper-library/include 
      -Xcc -I/Users/spencer/Documents/Repos/myproject/helper-library/include/helper-library  
      -Xcc -I/Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/DerivedSources-normal/arm64 
      -Xcc -I/Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/DerivedSources/arm64 
      -Xcc -I/Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/DerivedSources 
      -Xcc -DDEBUG\=1 
      -Xcc -ivfsoverlay -Xcc /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/unextended-module-overlay.yaml 
      -module-name MyProject 
      -frontend-parseable-output -disable-clang-spi 
      -target-sdk-version 16.0 
      -o /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/arm64/ObjCDebugDescription.o 
      -o /Users/spencer/Documents/Repos/myproject/build/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/arm64/File1.o

Here is the output from xbase.log:

INFO Runtime{name="MyProject"}: targets: {"MyProject": TargetInfo { platform: "iOS", configurations: ["Debug", "Release"] }, "MyProjectTests": TargetInfo { platform: "iOS", configurations: ["Debug", "Release"] }}
 INFO Broadcaster{name="MyProject"}: Connected [88492]
 INFO Runtime{name="MyProject"}: Connected [88492]
 INFO Runtime{name="MyProject"}: [Initialized] -------------------------
 INFO FSWatcher{name="MyProject"}: Watching
 INFO Client{fd=13}: Disconnected

And the output from xbase-build-server.log

INFO xbase_sourcekit_helper: Started
 INFO xbase_sourcekit_helper: Initialized
DEBUG xbase_sourcekit_helper: [File1.swift] Querying compile_db
ERROR xbase_sourcekit_helper: Missing compile arguments for "/Users/spencer/Documents/Repos/myproject/MyProject/Internals/File1.swift"

My theory is that the log parser is not looking for the swift-frontend executable, but rather the swiftc executable. Also, sometimes the output starts like this (notice the buildin-swiftTaskExecution before the executable):

SwiftCompile normal arm64 Compiling\ File1.swift /Users/spencer/Documents/Repos/myproject/MyProject/Source/File1.swift (in target 'MyProject' from project 'MyProject')
    cd /Users/spencer/Documents/Repos/myproject
    builtin-swiftTaskExecution -- /Applications/Xcode_14_0_1/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend

Has anyone tried using this plugin with XCode 14 and had success? Any help is appreciated, thanks!

Were you able to get this working? I'm running into the same issue.

If I am not mistaken #173 fixed that no? Anyways latest commits fixed issues caused by swift-frontend. Please repoen if you still face this issue