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

Allow additional imports with natalie-imports.json #55

Open ldiqual opened 9 years ago

ldiqual commented 9 years ago

@krzyzanowskim

Here's a proposed fix for https://github.com/krzyzanowskim/Natalie/issues/37, as per phimage's suggestion.

This commit modifies natalie.swift so it can take a second argument imports_file_json. This JSON file must contain an array of all the framework names to import and that natalie might not be able to autodetect (see original issue).

For example, in natalie-imports.json:

["FlatUIKit"]

and then:

$ natalie.swift <path_to_project> natalie-imports.json

which will add import FlatUIKit right before custom module imports.

A couple notes:

Let me know what you think about this solution and how to possibly improve it.

phimage commented 9 years ago

To be automatically detected in our perfect world you can put the file near the storyboard with specific extension, as I do with my PR https://github.com/krzyzanowskim/Natalie/pull/48/files Without that XNatalie or a generic launcher will not add the additional command parameter

krzyzanowskim commented 9 years ago

what is wrong with specyfying module in storyboard? this is the easiest way to handle it. Configuration file introduce complication how to deal with the file, where to store etc. I'd like to realy avoid that as long as possible.

phimage commented 9 years ago

you can't specify module for objective-c framework, this is what I understand in the corresponding issue

krzyzanowskim commented 9 years ago

@phimage --additional-imports or any option would be good to have for this.

phimage commented 9 years ago

Yes option is far better than adding an extra argument behind the file path But option

I prefer configuration files by storyboard because

that's why I make "plist" into PR #48

then plist VS json, the two are easy to read, but in Xcode I prefer create and edit plist file

hartbit commented 9 years ago

As a side note, if a solution is found to the issue #64 I just opened where I ask for a feature to have Natalie parse an xcodeproj file to generate target specific files, Natalie could automatically find out which frameworks each target is linked with.

ldiqual commented 9 years ago

@phimage I like the solution of a configuration file next to the storyboard. Not really a big fan of the plist format but at least it's consistent with what apple uses. @hartbit Agreed that your solution would be best, maybe we could iterate by merging https://github.com/krzyzanowskim/Natalie/pull/48 and https://github.com/krzyzanowskim/Natalie/issues/64 when it's code-ready?

krzyzanowskim commented 8 years ago

hello, I want merge this change, can you please rebase to current codebase ? :+1: This feature need documentation in README too.