Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

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

Closed
kostiakoval opened this issue Jun 15, 2015 · 5 comments
Closed

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

kostiakoval opened this issue Jun 15, 2015 · 5 comments
Labels

Comments

@kostiakoval
Copy link
Contributor

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 :

  • Remove all from the storyboard
  • Save and build, generate it.

The files contains 145 lines of code.

I see 2 improvements:

  • Don't generated code that not used
  • Move some base functionality to separate file, if it's possible.
@kostiakoval
Copy link
Contributor Author

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
Copy link
Collaborator

phimage commented Jun 15, 2015

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
Copy link
Collaborator

phimage commented Jun 19, 2015

In PR #47

  • I print only code about Reusable/reuseidentifier (UICollectionViewController and UITableViewController ) only if needed
  • remove comment "MARK : controller name" is no segue or reuse identifier
    For the generated example : https://github.com/krzyzanowskim/Natalie/pull/47/files

@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
Copy link
Owner

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

@krzyzanowskim
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants