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

Enhance code completion in swift file with errors #68

Open
fireplusteam opened this issue Oct 11, 2024 · 6 comments
Open

Enhance code completion in swift file with errors #68

fireplusteam opened this issue Oct 11, 2024 · 6 comments

Comments

@fireplusteam
Copy link

Currently it provides pure support if a file has a compile errors in a module
I ran xcode like
export SOURCEKIT_LOGGING=3 && /Applications/Xcode.app/Contents/MacOS/Xcode

to investigate the compile flags sending to sourcekitd and found interesting flag that is sending to sourcekitd which are not set when you are building the app

-experimental-allow-module-with-compiler-errors
-detailed-preprocessing-record

It would be good if xcode-build-server append this flag by default so completion experience would be like in Xcode.

Here is a full log from Xcode sourcekitd of flags:

 key.compilerargs: [
    "-vfsoverlay",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/index-overlay.yaml",
    "-module-name",
    "Test_ios",
    "-Onone",
    "-enforce-exclusivity=checked",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/ContentView.swift",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/Test_iosApp.swift",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/Subfolder/NewFile.swift",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/Subfolder/NextSubfolder/SubSubFile.swift",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/Subfolder/NextSubfolder/Better.swift",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/DerivedSources/GeneratedAssetSymbols.swift",
    "-DDEBUG",
    "-enable-bare-slash-regex",
    "-enable-experimental-feature",
    "DebugDescriptionMacro",
    "-sdk",
    "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk",
    "-target",
    "arm64-apple-ios17.2-simulator",
    "-g",
    "-module-cache-path",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/ModuleCache.noindex",
    "-Xfrontend",
    "-serialize-debugging-options",
    "-enable-testing",
    "-Xcc",
    "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG",
    "-swift-version",
    "5",
    "-I",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Products/Debug-iphonesimulator",
    "-F",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Products/Debug-iphonesimulator",
    "-Xfrontend",
    "-experimental-allow-module-with-compiler-errors",
    "-Xfrontend",
    "-empty-abi-descriptor",
    "-Xcc",
    "-fretain-comments-from-system-headers",
    "-Xcc",
    "-Xclang",
    "-Xcc",
    "-detailed-preprocessing-record",
    "-Xcc",
    "-Xclang",
    "-Xcc",
    "-fmodule-format=raw",
    "-Xcc",
    "-Xclang",
    "-Xcc",
    "-fallow-pch-with-compiler-errors",
    "-Xcc",
    "-Xclang",
    "-Xcc",
    "-fallow-pcm-with-compiler-errors",
    "-Xcc",
    "-Wno-non-modular-include-in-framework-module",
    "-Xcc",
    "-Wno-incomplete-umbrella",
    "-Xcc",
    "-fmodules-validate-system-headers",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/swift-overrides.hmap",
    "-Xcc",
    "-iquote",
    "-Xcc",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Test_ios-generated-files.hmap",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Test_ios-own-target-headers.hmap",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Test_ios-all-target-headers.hmap",
    "-Xcc",
    "-iquote",
    "-Xcc",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Test_ios-project-headers.hmap",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Products/Debug-iphonesimulator/include",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/DerivedSources-normal/arm64",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/DerivedSources/arm64",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/DerivedSources",
    "-Xcc",
    "-DDEBUG=1",
    "-working-directory",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios"
  ],

and here is from with xcode-build-server

ey.compilerargs: [
    "-module-name",
    "Test_ios",
    "-Onone",
    "-enforce-exclusivity=checked",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/ContentView.swift",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/Test_iosApp.swift",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/Subfolder/NewFile.swift",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/Subfolder/NextSubfolder/SubSubFile.swift",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios/Test_ios/Subfolder/NextSubfolder/Better.swift",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/DerivedSources/GeneratedAssetSymbols.swift",
    "-DDEBUG",
    "-enable-bare-slash-regex",
    "-enable-experimental-feature",
    "DebugDescriptionMacro",
    "-sdk",
    "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk",
    "-target",
    "arm64-apple-ios17.2-simulator",
    "-g",
    "-module-cache-path",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/ModuleCache.noindex",
    "-Xfrontend",
    "-serialize-debugging-options",
    "-profile-coverage-mapping",
    "-profile-generate",
    "-enable-testing",
    "-index-store-path",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Index.noindex/DataStore",
    "-enable-experimental-feature",
    "OpaqueTypeErasure",
    "-Xcc",
    "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG",
    "-swift-version",
    "5",
    "-I",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Products/Debug-iphonesimulator",
    "-F",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Products/Debug-iphonesimulator",
    "-c",
    "-j10",
    "-enable-batch-mode",
    "-incremental",
    "-Xcc",
    "-ivfsstatcache",
    "-Xcc",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator18.0-22A3362-db63dc9361471f152f572502bdbfe70a.sdkstatcache",
    "-output-file-map",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Objects-normal/arm64/Test_ios-OutputFileMap.json",
    "-save-temps",
    "-no-color-diagnostics",
    "-serialize-diagnostics",
    "-emit-dependencies",
    "-emit-module",
    "-emit-module-path",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Objects-normal/arm64/Test_ios.swiftmodule",
    "-validate-clang-modules-once",
    "-clang-build-session-file",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/swift-overrides.hmap",
    "-emit-const-values",
    "-Xfrontend",
    "-const-gather-protocols-file",
    "-Xfrontend",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Objects-normal/arm64/Test_ios_const_extract_protocols.json",
    "-Xcc",
    "-iquote",
    "-Xcc",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Test_ios-generated-files.hmap",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Test_ios-own-target-headers.hmap",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Test_ios-all-target-headers.hmap",
    "-Xcc",
    "-iquote",
    "-Xcc",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Test_ios-project-headers.hmap",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Products/Debug-iphonesimulator/include",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/DerivedSources-normal/arm64",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/DerivedSources/arm64",
    "-Xcc",
    "-I/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/DerivedSources",
    "-Xcc",
    "-DDEBUG=1",
    "-emit-objc-header",
    "-emit-objc-header-path",
    "/Users/Ievgenii_Mykhalevskyi/Library/Developer/Xcode/DerivedData/Test_ios-caxuiboehwkaurgzvolmbidupwvv/Build/Intermediates.noindex/Test_ios.build/Debug-iphonesimulator/Test_ios.build/Objects-normal/arm64/Test_ios-Swift.h",
    "-working-directory",
    "/Users/Ievgenii_Mykhalevskyi/tests/Test_ios",
    "-experimental-emit-module-separately",
    "-disable-cmo"
  ]
}
@fireplusteam
Copy link
Author

also -fallow-pch-with-compiler-errors

@SolaWing
Copy link
Owner

what the detail difference if not have this flag?

@fireplusteam
Copy link
Author

Just add them to find out if they produce any difference.

@SolaWing
Copy link
Owner

you may change it here to see difference?

return final_flags

@SolaWing
Copy link
Owner

According to the swift documentation, the corresponding flag function is:

https://github.com/swiftlang/swift/blob/087676da1125f88a467a401899d7a84d962632a4/include/swift/Option/FrontendOptions.td#L1194
Ignore errors and force the generation of swiftmodules. The consumer of swiftmodules is the upper-level framework. so code with error may can be perceived by the upper-level frameworks.

-detailed-preprocessing-record: No document found. It seems to be related to preprocessing. More details may be output?
-fallow-pch-with-compiler-errors: is estimated to have a similar effect and does not affect product generation.

@fireplusteam
Copy link
Author

It looks like we need also to pass this parameter into xcodebuild to actually build a project with such flags to make it working.

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

2 participants