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

Fix SwiftGen Plugin high CPU usage issue #46

Merged
merged 1 commit into from
Sep 8, 2022
Merged

Conversation

pchmelar
Copy link
Member

@pchmelar pchmelar commented Sep 8, 2022

📝 Description

  • This PR fixes an issue with high CPU usage when using Swift Plugins

💡 What’s new?

  • We recently started using SwiftGen via SPM Plugin - Use SwiftGen via SPM Plugin #42
  • Apparently, Apple fucks up this function, resulting in high CPU usage and unusable Xcode 🙃
  • Temporary solution is to use the plugin locally instead of having it as a remote dependency

😶 What’s missing?

  • Change back to remote dependency once Apple fixes this issue

📚 References

@pchmelar pchmelar merged commit e503a2e into develop Sep 8, 2022
@pchmelar pchmelar deleted the fix/swiftgen-plugin branch September 8, 2022 14:47
Copy link
Contributor

@Carrione Carrione left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there two configuration locations?

@main
struct SwiftGenPlugins: BuildToolPlugin {
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
let configurations: [Path] = [context.package.directory, target.directory]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there two configurations?

Copy link
Contributor

@Carrione Carrione left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why more possible configuration locations is used. But the configuration is only one therefore you need to filter them.

func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
let configurations: [Path] = [context.package.directory, target.directory]
.map { $0.appending("swiftgen.yml") }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you need to filter configuration locations

.filter { FileManager.default.fileExists(atPath: $0.string) }

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

Successfully merging this pull request may close these issues.

2 participants