Comments (17)
Hi @netbe
The feature is still definitely in our roadmap, and we actually renamed the storyboard
subcommand to ib
in the latest 6.0 release, and rearranged the parsers in SwiftGenKit too⦠in order to better prepare for supporting that (as this won't be limited to storyboards anymore, and parsers are better arranged now to be more flexible for that)
The previous Pull Requests though won't probably completely fit anymore the new code organization, so we might need to rewrite those, but that should actually be easier now, hopefully.
I won't give you a deadline though, as I'm not sure how much free time we'll have between all contributors to work on this, so when this will be done, but any contribution in that direction is welcome
from swiftgen.
Probably better wait for #24 before starting to work on this issue
from swiftgen.
Hey @AliSoftware ! In developing a tool with similar features to SwiftGen I built a library that makes extracting (eventually) everything, including UITableViewCell and UICollectionViewCell identifiers in Storyboards much easier. It may be overkill for your use but the library is StoryboardKit.
To see UITableView Identifier extraction check seguecode's usage here: ViewControllerClassInfo+seguecode.swift Line 35-66
from swiftgen.
Hey @yoiang
Thanks for the input, will take a look later in the week!
from swiftgen.
+1 on this. I suggest adding UICollectionViewCell
to the issue title (they are easy to forget about π).
from swiftgen.
+1
from swiftgen.
Feel free to make a PR to make this be implemented and released faster, as I'm pretty busy those days and won't have much time implementing it that soon.
from swiftgen.
No worries :-)
#66
from swiftgen.
My comment is not related to SwiftGen
, but as its user I'll comment anyway.
For UITableViewCell
and UICollectionViewCell
it's quite good practice to use class names as identifiers.
You can do it with extenstion like this one:
extension UITableView {
public func dequeueReusableCell<T:UITableViewCell>(type: T.Type) -> T {
let tableCell : T
let cellIdentifier = String(T)
if let cell = self.dequeueReusableCellWithIdentifier(cellIdentifier) as? T {
tableCell = cell
} else if let _ = NSBundle(forClass: T.classForCoder()).pathForResource(cellIdentifier, ofType:"nib") {
registerNib(UINib(nibName: cellIdentifier, bundle: nil), forCellReuseIdentifier: cellIdentifier)
if let cell = NSBundle(forClass: T.classForCoder()).loadNibNamed(cellIdentifier, owner: nil, options: nil)[0] as? T {
tableCell = cell
} else {
//if anyone had better suggestion for fallback, you're welcome to comment
tableCell = T(style: .Default, reuseIdentifier: cellIdentifier)
}
} else {
tableCell = T(style: .Default, reuseIdentifier: cellIdentifier)
}
return tableCell
}
}
In code you use it like this:
let cell = tableView.dequeueReusableCell(CommentVideoCell)
This actually solves 3 problems:
- XIB naming
- Identifier naming
- Do don't need to register your cells explicitly
So you can avoid magic string in both cases.
Of course, there are cases when you need more than 1 identifier for some cell, but truly, during few years of iOS development I haven't found too many cases like this.
As for UICollectionViewCell
you can find similar code here:
https://gist.github.com/krodak/25680b1ec18e750f6ddd
from swiftgen.
@krodac I guess you didn't read about my comment on #66 and my pod Reusable library then π
from swiftgen.
@aisoftware - yes, I missed it ;-) But looking at it now it's not exactly the same approach, is it?
from swiftgen.
Just had a great idea for a template once this is implemented. Since Reusable looks up the cell identifier based on the value of the reuseIdentifier
property, a swiftgen template could generate an extension for every custom *Cell
class found, simply supplying the reuseIdentifer
that was found in the storyboard. I think this would eliminate the possibility of the two getting out of sync.
from swiftgen.
@phatblat Sounds good to me! Don't hesitate to piggy-back on #66 to discuss that and make it happen the way you just described!
from swiftgen.
I'm on it! π
from swiftgen.
The new reference PR to implement that is now SwiftGen/SwiftGenKit#16
from swiftgen.
@AliSoftware is that still wip ?
from swiftgen.
@AliSoftware thanks for the update
from swiftgen.
Related Issues (20)
- FatalError when trying to set Asset.color as foregroundColor into NSMutableAttributedString attribute HOT 2
- Unprintable ASCII character found in Swift Source Code HOT 1
- SVG images being ignored in assets HOT 1
- The SwiftGen configuration automatically substitutes fileprivate in the initialization of ColorAsset HOT 1
- Adding Extra parameter when running SwiftGen through Xcode HOT 1
- Error: `swiftgen.yml` is not a config file HOT 3
- String template is not able to generate a function with a string parameter and a plural int HOT 2
- Make `SwiftUI` types the default and not `UIKit` types. HOT 1
- Color Generated with SwiftUI HOT 2
- disable Font typealias? HOT 1
- Addition of .string file changes all previous strings usage HOT 1
- Ability to change Locale HOT 6
- Feature Request: Public access to either the fallback string or the ability to specify locale HOT 2
- Add ability to refer file name of JSON HOT 3
- Support for visionOS HOT 2
- Is this repo deprecated? HOT 4
- Add an XcodeBuiltToolPlugin for swiftgen HOT 5
- [Homebrew] Error: swiftgen has been disabled because it does not build! HOT 10
- Apple privacy manifest support HOT 2
- SwiftGen Errors on Swift 6 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftgen.