intitni / XccurateFormatter

An Xcode code formatter that reads the project specific configurations. Supports SwiftFormat, swift-format, ClangFormat, and Prettier.
MIT License
19 stars 1 forks source link

Hope to support Ruby formatting. #5

Closed uclort closed 1 year ago

uclort commented 1 year ago

The project uses Cocoapods for integration, and it's inevitable that we'll write scripts in the Ruby language. We hope for support in formatting Ruby code.

thanks.

intitni commented 1 year ago

Prettier plugins are now supported in 0.7.0, please read README.md for details.

uclort commented 1 year ago

Prettier plugins are now supported in 0.7.0, please read README.md for details.

Thanks, but I'm still having trouble formatting ruby, Xcode says "The command " Format File " is still busy." CleanShot 2023-08-22 at 09 10 17 Xnip2023-08-22_09-07-33 CleanShot 2023-08-22 at 09 11 14

intitni commented 1 year ago

You can try running the command in terminal to see if it works.

There is also a chance that the interactive logged-in shell (-ilc flags) is blocking the app. One user reported it from another project, but I was never able to reproduce it. The fix is simple for that project because I know where the dependencies are. But this project is different.

It would be great if you can run the app and test it in Xcode. Here is the suspicious code: https://github.com/intitni/XccurateFormatter/blob/3b829cb221aecfe0ed3ab557f9d1d58ab12cdae5/EditorExtensionXPCService/Formatters.swift#L184

To run the extension, you need to run both the EditorExtensionXPCCLI and EditorExtension target. When the EditorExtension target runs, you will need to select Xcode from a list of application, a new instance of Xcode for test will be created. You should run the commands inside Xccurate Formatter Dev instead.

The dev settings are shared with the released build.

uclort commented 1 year ago

您可以尝试在终端中运行该命令看看是否有效。

交互式登录 shell(-ilc 标志)也有可能阻止该应用程序。一位用户从另一个项目报告了它,但我永远无法重现它。对于该项目来说修复很简单,因为我知道依赖项在哪里。但这个项目不同。

如果您可以运行该应用程序并在 Xcode 中进行测试,那就太好了。这是可疑的代码:

https://github.com/intitni/XccurateFormatter/blob/3b829cb221aecfe0ed3ab557f9d1d58ab12cdae5/EditorExtensionXPCService/Formatters.swift#L184

要运行扩展,您需要运行 EditorExtensionXPCCLI 和 EditorExtension 目标。当 EditorExtension 目标运行时,您需要从应用程序列表中选择 Xcode,将创建一个用于测试的新 Xcode 实例。您应该改为在 Xccurate Formatter Dev 中运行命令。

开发设置与已发布的版本共享。

The console output is as follows:

other("/Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler/definition.rb:540:in `materialize\': Could not find cocoapods-hmap-prebuilt-0.0.7, fastlane-2.204.3, fastlane-plugin-pgyer-0.2.2, CFPropertyList-3.0.5, addressable-2.8.0, artifactory-3.0.15, aws-sdk-s3-1.113.0, babosa-1.0.4, colored-1.2, commander-4.6.0, dotenv-2.7.6, emoji_regex-3.2.3, excon-0.91.0, faraday-1.10.0, faraday-cookie_jar-0.0.7, faraday_middleware-1.2.0, fastimage-2.2.6, gh_inspector-1.1.3, google-apis-androidpublisher_v3-0.16.0, google-apis-playcustomapp_v1-0.7.0, google-cloud-storage-1.36.1, highline-2.0.3, json-2.6.1, jwt-2.3.0, mini_magick-4.11.0, multipart-post-2.0.0, naturally-2.2.1, optparse-0.1.1, plist-3.6.0, rubyzip-2.3.2, security-0.1.3, simctl-1.6.8, terminal-notifier-2.0.0, terminal-table-1.8.0, tty-screen-0.8.1, tty-spinner-0.9.3, word_wrap-1.0.0, xcodeproj-1.21.0, xcpretty-0.3.0, xcpretty-travis-formatter-1.0.1, public_suffix-4.0.6, aws-sdk-core-3.129.0, aws-sdk-kms-1.55.0, aws-sigv4-1.4.0, faraday-em_http-1.0.0, faraday-em_synchrony-1.0.0, faraday-excon-1.1.0, faraday-httpclient-1.0.1, faraday-multipart-1.0.3, faraday-net_http-1.0.1, faraday-net_http_persistent-1.2.0, faraday-patron-1.0.0, faraday-rack-1.0.0, faraday-retry-1.0.3, http-cookie-1.0.4, google-apis-core-0.4.2, digest-crc-0.6.4, google-apis-iamcredentials_v1-0.10.0, google-apis-storage_v1-0.11.0, google-cloud-core-1.6.0, googleauth-1.1.2, mini_mime-1.1.2, unicode-display_width-1.8.0, tty-cursor-0.7.1, atomos-0.1.3, claide-1.1.0, colored2-3.1.2, nanaimo-0.3.0, rouge-2.0.7, aws-eventstream-1.2.0, aws-partitions-1.565.0, jmespath-1.6.1, domain_name-0.5.20190701, httpclient-2.8.3, representable-3.1.1, retriable-3.1.2, webrick-1.7.0, google-cloud-env-1.5.0, google-cloud-errors-1.2.0, memoist-0.16.2, multi_json-1.15.0, os-1.1.4, signet-0.16.1, unf-0.1.4, declarative-0.0.20, trailblazer-option-0.1.2, uber-0.1.0, unf_ext-0.0.8 in locally installed gems (Bundler::GemNotFound)\n\tfrom /Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler/definition.rb:200:in `specs\'\n\tfrom /Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler/definition.rb:266:in `specs_for\'\n\tfrom /Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler/runtime.rb:18:in `setup\'\n\tfrom /Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler.rb:162:in `setup\'\n\tfrom /Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler/setup.rb:23:in `block in <top (required)>\'\n\tfrom /Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler/ui/shell.rb:159:in `with_level\'\n\tfrom /Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler/ui/shell.rb:111:in `silence\'\n\tfrom /Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/lib/bundler/setup.rb:23:in `<top (required)>\'\n\tfrom <internal:/Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require\'\n\tfrom <internal:/Users/HouMeng/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require\'\n\tfrom /Users/HouMeng/.nvm/versions/node/v20.0.0/lib/node_modules/@prettier/plugin-ruby/src/server.rb:3:in `<main>\'\n[error] .xccurate_formatter_B673DDE1-E6F0-43C7-9072-B238AC4E4FF8.rb: Error: Failed to start parse server.\n[error]     at Timeout.<anonymous> (file:///Users/HouMeng/.nvm/versions/node/v20.0.0/lib/node_modules/@prettier/plugin-ruby/src/plugin.js:119:16)\n[error]     at listOnTimeout (node:internal/timers:573:17)\n[error]     at process.processTimers (node:internal/timers:514:7)")
0   XccurateFormatterService            0x0000000100008993 $s24XccurateFormatterService25EditorExtensionXPCServiceC17formatEditingFile7content5lines3uti9withReplyySS_SaySSGSSy10Foundation4DataVSg_s5Error_pSgtctFyyYaYbcfU_TY5_ + 1283
1   XccurateFormatterService            0x0000000100008c41 $s24XccurateFormatterService25EditorExtensionXPCServiceC17formatEditingFile7content5lines3uti9withReplyySS_SaySSGSSy10Foundation4DataVSg_s5Error_pSgtctFyyYaYbcfU_TATQ0_ + 1
2   XccurateFormatterService            0x0000000100005a81 $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTQ0_ + 1
3   XccurateFormatterService            0x0000000100005bb1 $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTATQ0_ + 1
4   libswift_Concurrency.dylib          0x00007ffc0d631c71 _ZL23completeTaskWithClosurePN5swift12AsyncContextEPNS_10SwiftErrorE + 1
intitni commented 1 year ago

看起来你没有安装 prettier-ruby 的依赖,它的 repo 里有一段 gem install 的你执行了吗?

uclort commented 1 year ago

看起来你没有安装 prettier-ruby 的依赖,它的 repo 里有一段 gem install 的你执行了吗?

全部安装了。

CleanShot 2023-08-23 at 09 56 22

uclort commented 1 year ago

看起来你没有安装 prettier-ruby 的依赖,它的 repo 里有一段 gem install 的你执行了吗?

全部推翻重来之后,命令行是可以正常格式化了,但是 XccurateFormatter 还是一样的错误提示。

intitni commented 1 year ago

建议吧 app 执行的命令 print 出来看看能不能在 terminal 中执行。按道理来说 -il 参数读取的配置文件和使用终端时是一样的,应该是能找到依赖的。

你也可以试试 /bin/zsh -ilc env 输出的 PATH 和你直接 env 输出的是不是一样 (zsh 换成你在用的 shell)

uclort commented 1 year ago

建议吧 app 执行的命令 print 出来看看能不能在 terminal 中执行。按道理来说 -il 参数读取的配置文件和使用终端时是一样的,应该是能找到依赖的。

你也可以试试 /bin/zsh -ilc env 输出的 PATH 和你直接 env 输出的是不是一样 (zsh 换成你在用的 shell)

感谢回复,谢谢你的项目,项目非常好,这个问题我放弃了,不整了,Xcode 太难用了,Run Extension 之后,控制台输出 Bootstrapping; external subsystem UIKit_PKSubsystem refused set,然后再也不输出东西,断点也不执行,重启 Xcode 重启电脑都不行,无语至极,折腾累了。

intitni commented 1 year ago

哈哈,欢迎体验 Xcode Source Editor Extension 开发