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

High Xcode CPU usage #2

Open
aregler opened this issue Aug 11, 2022 · 8 comments
Open

High Xcode CPU usage #2

aregler opened this issue Aug 11, 2022 · 8 comments

Comments

@aregler
Copy link

aregler commented Aug 11, 2022

Hey!
First of all I wanted to thank you for providing an official plugin 🤗
When I add the plugin via the remote dependency,

dependencies: [
    .package(url: "https://github.com/SwiftGen/SwiftGenPlugin", from: "6.6.0")
 ]

the CPU usage of Xcode rises constantly to 100%+. In contrast, when I add the package locally all is fine.

I created a minimal example to show the problem.
SwiftgenSPM.zip

Do you have any ideas where the problem could lie?
Thanks for everything, have a nice day,

Arsatius

@djbe
Copy link
Member

djbe commented Aug 11, 2022

I'm not sure TBH, what Xcode does is a bit of a black box. I also can't open that project file, I assume because it's made using the Xcode beta (which I don't have yet).

What I did notice is that your swiftgen.yml file seems to be in a weird place? Make sure to read the docs for the plugin, you must place the file in the root of your project, or in the folder for a module. Not sure how that works with this though, as your Package.swift is also in a subfolder… Shouldn't that also be in the root of your project?

Another note: your swiftgen config looks wrong as well, those paths, such as Strings/Base.lproj don't exist? Does your config work with normal SwiftGen?

Edit: what do you mean with "add the package locally"?

@aregler
Copy link
Author

aregler commented Aug 11, 2022

Hi! Thank you for your reply.
Yeah my bad for uploading a Xcode beta project and for the wrong path in the SwiftGen config. Sorry.
Here is a sample using the current stable Xcode version:
SwiftGenSPM.zip

I think the place of my swiftgen.yml should be ok (no?) as it should be placed on the root level or at the module level:

image

By "add the package locally" I mean to remove the remote dependency .package(url: "https://github.com/SwiftGen/SwiftGenPlugin", from: "6.6.0"), download the SwiftGenPlugin project and drop it into the Xcode project and just add the dependency as .package("SwiftGenPlugin).

Thank you for your time and help!

@iwt-dahlborn
Copy link

I have a similar problem with Xcode having high cpu usage when I add the package as a dependency. My guess is that it might be an issue with the artifactbundle (or an Xcode bug), because when I unfold the plugin in the package dependencies in the navigator the downloaded artifactbundle blinks in and out of existance as if it is repeatedly getting deleted and redownloaded. When selecting the package.swift file the organizer is also blinking.

This also happens when using another plugin https://github.com/lukepistrol/SwiftLintPlugin who also uses a remote artifactbundle, so it might very well be an Xcode issue. I tested it with Xcode 13.4, Xcode 13.4.1 and Xcode 14.0 beta 5.

@mtzaquia
Copy link

mtzaquia commented Aug 15, 2022

I am also experiencing this issue, which seems to clearly an issue with Xcode itself. Adding the plugin will immediately set CPU usage at 130%. Tested on Xcode 13.x and Xcode 14 betas.

@iwt-dahlborn
Copy link

Adding the artifactbundle to the package and referencing it locally "solves" the issue. But of course that would not be as elegant as having a remote dependency.

@pchmelar
Copy link

If anyone is using the temporary workaround from DroidKaigi/conference-app-2022#88, please note that in Xcode 14 you have to add .filter { FileManager.default.fileExists(atPath: $0.string) } 🙂

@weakfl
Copy link

weakfl commented Nov 2, 2022

Looks like this has been resolved in Xcode 14.1

@markltownsend
Copy link

I just created a Swift Package with SwiftGenPlugin as a dependency and build plugin. I am still getting the high cpu in Xcode 14.2, but that is only when I first open the project. Xcode shows a beachball cursor for about 10 secs before being done with whatever it's doing. My guess is that it's compiling the xcasset catalog and running SwiftGen. Not ideal, but I don't think there is anything that this project can do about it. I think it's a requirement to have the build plugins works better in the background when it's setup as a pre-build Swift Package plugin.

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

7 participants