Git Product home page Git Product logo

Comments (17)

AliSoftware avatar AliSoftware commented on May 17, 2024 2

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.

AliSoftware avatar AliSoftware commented on May 17, 2024

Probably better wait for #24 before starting to work on this issue

from swiftgen.

yoiang avatar yoiang commented on May 17, 2024

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.

AliSoftware avatar AliSoftware commented on May 17, 2024

Hey @yoiang

Thanks for the input, will take a look later in the week!

from swiftgen.

phatblat avatar phatblat commented on May 17, 2024

+1 on this. I suggest adding UICollectionViewCell to the issue title (they are easy to forget about πŸ˜‰).

from swiftgen.

jmacmullin avatar jmacmullin commented on May 17, 2024

+1

from swiftgen.

AliSoftware avatar AliSoftware commented on May 17, 2024

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.

jmacmullin avatar jmacmullin commented on May 17, 2024

No worries :-)
#66

from swiftgen.

krodak avatar krodak commented on May 17, 2024

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.

AliSoftware avatar AliSoftware commented on May 17, 2024

@krodac I guess you didn't read about my comment on #66 and my pod Reusable library then πŸ˜‰

from swiftgen.

krodak avatar krodak commented on May 17, 2024

@aisoftware - yes, I missed it ;-) But looking at it now it's not exactly the same approach, is it?

from swiftgen.

phatblat avatar phatblat commented on May 17, 2024

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.

AliSoftware avatar AliSoftware commented on May 17, 2024

@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.

phatblat avatar phatblat commented on May 17, 2024

I'm on it! πŸƒ

from swiftgen.

AliSoftware avatar AliSoftware commented on May 17, 2024

The new reference PR to implement that is now SwiftGen/SwiftGenKit#16

from swiftgen.

netbe avatar netbe commented on May 17, 2024

@AliSoftware is that still wip ?

from swiftgen.

netbe avatar netbe commented on May 17, 2024

@AliSoftware thanks for the update

from swiftgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.