-
Notifications
You must be signed in to change notification settings - Fork 727
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
Add generation of Table and Collection cell reuseIdentifiers #134
Conversation
Change from stripysock:master by @jmacmullin # Conflicts: # UnitTests/fixtures/Message.storyboard
…dentifier For Reusable!
Poll: should we
|
@@ -93,6 +111,9 @@ struct XCTStoryboardsScene { | |||
return vc | |||
} | |||
} | |||
enum TableViewCell: StoryboardSceneType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels strange to conform a cell to some protocol named "…SceneType". Maybe it's time to rename that protocol StoryboardBasedType
instead of StoryboardSceneType
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is a little weird since XIBs don't have "scenes". I think in this case the TableViewCell
"scene" should just be suppressed because you can't instantiateInitialViewController
from a XIB.
|
case ReuseCellID = "ReuseCellID" | ||
} | ||
enum CollectionViewCell: String, StoryboardCellType { | ||
case XibCollectionViewCellReuseID = "XibCollectionViewCellReuseID" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think calling this CollectionViewCell
a StoryboardCellType
is the weird case as it was found in a XIB. Perhaps a XibCellType
that simply extends StoryboardCellType
?
Added the "WIP" label to the PR, don't hesitate to remove it once you consider it done and ready to review for merge 😉 |
As for the command, I'm still not settled. Having |
Testing this PR out in a real project and ran across a couple issues. Public
Example: extension RepoCollectionViewCell { static var reuseIdentifier: String { return "RepoCollectionViewCell" } } This is an easy fix to the template. InheritanceI've got a couple different prototype table cells in a table. They used to both use the same class FileTableViewCell: UITableViewCell, Reusable {
@IBOutlet var fileNameLabel: UILabel!
@IBOutlet var gitStatusLabel: UILabel!
@IBOutlet var dateLabel: UILabel!
}
class FolderTableViewCell: FileTableViewCell {} Here is are generated extensions which define the extension FileTableViewCell { static var reuseIdentifier: String { return "FileTableViewCell" } }
extension FolderTableViewCell { static var reuseIdentifier: String { return "FolderTableViewCell" } } These are the resulting errors, caused from
Unless I'm missing something, it seems like the only option for this issue is "don't do that". I can easily duplicate the properties in the |
# Conflicts: # UnitTests/fixtures/Message.storyboard
This PR is almost a year old. Any plans on merging it in? |
This is a really old PR, SwiftGen has changed quite a lot since then. In the meantime, I highly recommend https://github.com/AliSoftware/Reusable. |
Hi @phatblat First of all, thanks a lot again for taking the time to create this PR. I'd like to apologise for letting that feature stale for so long. SwiftGen goals and priorities, including a big refactoring and splitting the project into multiple repositories, took precedence at some point, and we let that PR a bit forgotten, and I'm very sorry for the feeling it might have given to people like you who took the time to contribute. Given that this PR is quite old and has gotten out of sync with how SwiftGen evolved, I'm gonna close this in favor of SwiftGen/SwiftGenKit#16. We can continue working on this feature in SwiftGenKit from this PR from now on. To be honest, the next main milestone for SwiftGen and what we're focusing on right now is migrating to a new major version 5.0, removing deprecated template variables and make some cleanup after all that refactoring we did in 4.2. But once it's released (which I hope we won't take too long doing), it'll be time again for adding new feature in this newly cleaned codebase 😉 To thank you for your work and for the time you took to improve the tool, I've invited you to join SwiftGen's GitHub organization's "CoreContributors" team. No pressure to accept nor any obligation in that, don't worry 😉 It will just give you the ability to help triage issues or push directly branches to the repo (instead of your fork)… in case you want to contribute again in the future or help finally make that feature happen 😉 For more information about contributing to SwiftGen in this new GitHub organisation and context, you can read the COMMUNITY.md and CONTRIBUTING.md documents, and if you have any questions don't hesitate to reach out! |
No worries at all :D. This PR is ancient now. I'd love to still contribute to SwiftGen from time to time |
Builds on the great work @jmacmullin started in #66. Addresses #19.
Adds collection of all
UITableViewCell
andUICollectionViewCell
reuse identifiers and generation of a newStoryboardCell
struct containing an enum of all the identifiers found on each storyboard.Cases handled
UITableViewCell
prototype cells in aUITableView
UICollectionViewCell
prototype cells in aUICollectionView
UITableViewCell
associated with a view controllerUICollectionViewCell
associated with a view controllerUITableViewCell
UICollectionViewCell
XIB file parsing has been added. This was trivial to add as the relevant XML is identical between the two Interface Builder file types. However, there are names all over like
StoryboardParser
andstoryboardsCells
which now seem weird. Even thestoryboards
command doesn't seem right now.API
Extensions to both
UITableView
andUICollectionView
to allow for dequeueing of cells using the SwiftGen generated enum values.That's a mouthful, but at least it's not using a string to retrieve the cells. As for the
as!
, that's not very safe. Better to use Reusable for this.Reusable
The default storyboards template has been updated to generate an extension for every cell that has a
customClass
and add a reuseIdentifier property with the value found in the storyboard.Out of Scope
Specifically not included (to be addressed in future PRs)
UITableViewHeaderFooterView
UICollectionReusableView
- need to figure out what to do withelementKind
MKAnnotationView
🗺dequeueReusableAnnotationViewWithIdentifier
WIP