krzyzanowskim / Natalie

Natalie - Storyboard Code Generator (for Swift)
http://blog.krzyzanowskim.com/2015/04/15/natalie-storyboard-code-generator/
MIT License
1.17k stars 74 forks source link

Some code is generated even when it's not used #42

Closed kostiakoval closed 9 years ago

kostiakoval commented 9 years ago

UICollectionViewController and UITableViewController extension is generated even when they are not used in the application. The code should be generated only when they are used. It would make code cleaner.

Steps :

The files contains 145 lines of code.

I see 2 improvements:

kostiakoval commented 9 years ago

One of the solution to merge natalie.swift would be run script before building it. Would be very useful for development.

cat a.swift b.swift > natalie.swift

phimage commented 9 years ago

Two way for Reusable 1 - print all stuff about UICollectionViewController and UITableViewController after calling processViewControllers (which know if reuseIdentifier has been detected) 2 - detect if there is a not empty "reuseIdentifier" attribute with something like that

let noReusable = [Reusable]()
let reusables = storyboards.flatMap{
  $0.storyboard?.scenes.flatMap{
    $0.viewController?.reusables?.filter{
        return $0.reuseIdentifier != nil
    } ?? noReusable
  } ?? noReusable
}
let hasReusable = !reusables.isEmpty

yes If we want to develop in separate files and want to concatenate all files in natalies.swift we can use a script like this https://github.com/evgenyneu/moa/blob/master/scripts/concatenate_swift_files.sh

phimage commented 9 years ago

In PR #47

@kostiakoval have you seen other codes to not print ? If none, this issue could be closed after PR #47 merge? (maybe we can discuss about split files elsewhere like in #43)

krzyzanowskim commented 9 years ago

Why the whole "ReusableProtocol" is out in this PR ?

krzyzanowskim commented 9 years ago

ReusableProtocol describe what is already in UIKit. It's good to have it around with extensions, no matter if Natalie generated something reusable or not.

I think this change is unnecessary.