Skip to content

Update view/scene builders to support up to 20 views/scenes (fixes #198) #200

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stackotter
Copy link
Owner

Just updates SwiftCrossUI's view/scene builders to support up to 20 views/scenes by updating some constants in our gyb files.

I've tested build performance with and without these extra tuple views/scenes and builder methods, and build times don't seem to have been affected.

Unfortunately these changes do make CounterExample's binary 2mb larger in both debug mode and release mode (about 20% bigger for such a simple app). Perhaps I can gate this behind an 'SCUI_EXTENDED_BUILDERS` environment variable for now and then make it a trait once we bump to Swift 6.1?

Before I merge this, I'll also attempt to reduce the size of the generated files by moving repeated logic into generic helper methods, because this PR currently has 10,000 additions, which is a ridiculous amount of repetitive code.

This resulted in 7500 lines less code, 1mb smaller debug binaries and
0.5mb smaller release binaries
@stackotter
Copy link
Owner Author

My latest commit reduced repetition in the generated code quite significantly (7500 lines less code) and resulted in 1mb smaller debug binaries and 0.5mb smaller release binaries.

CounterExample binary size (AppKitBackend + Swift 6.0.3)

Debug

  • 10 builders: 8.7mb
  • 20 builders: 11.8mb
  • 20 builders (shrunk): 10.7mb

Release

  • 10 builders: 5.7mb
  • 20 builders: 7.4mb
  • 20 builders (shrunk): 6.9mb

Copy link
Contributor

@valeriyvan valeriyvan Jun 28, 2025

Choose a reason for hiding this comment

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

I don't think changes in this file belong to this PR.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I only made the change in this PR because it was required to get one of the size optimisations working. When I moved one of the repeated function bodies into
a helper method, I needed to make the helper MainActor and then started getting all sorts of concurrency warning about LayoutableChild.

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