Issue #169 — Reorganize project as an app bundle#204
Conversation
|
Good! Only thing I can note is your changelog entries' format: With |
AliSoftware
left a comment
There was a problem hiding this comment.
I haven't reviewed this in detail, but I'm gonna mark it as rejected: don't take it the wrong way, it's probably good, but it's gonna be super-hard to review the diff given how heavy it is from containing both the changes from #201 and the changes just to make it an app bundle, so it's just to keep in mind that we'll have to wait for 201 to be ready an merged, then rebase that on top of it so that this PR only contains the relevant changes to make it an app bundle, which would make it way easier to review and cleaner to merge 😉
|
Time to rework this PR now that #201 has been modified then merged! 🎉 Could you please rebase this on top of Thanks! |
1e9adde to
4079605
Compare
|
Okay! so this should be ready for a look.
Let me know what you think. |
Rakefile
Outdated
| bindir = args.bindir.nil? || args.bindir.empty? ? Pathname.new('./build/swiftgen/bin') : Pathname.new(args.bindir) | ||
| fmkdir = args.fmkdir.nil? || args.fmkdir.empty? ? bindir + '../lib' : Pathname.new(args.fmkdir) | ||
| tpldir = args.tpldir.nil? || args.tpldir.empty? ? bindir + '../templates' : Pathname.new(args.tpldir) | ||
| tpldir = args.tpldir.nil? || args.tpldir.empty? ? bindir + '../Resources/templates' : Pathname.new(args.tpldir) |
There was a problem hiding this comment.
I'm not sure I get why you changed this?
The point of the Rakefile is to distribute SwiftGen as a command line tool in the format expected by homebrew and structured like other executables you typically have in /use/local/bin or similar non-app-bundled tools, which don't have a Resources folder
There was a problem hiding this comment.
@AliSoftware Great question, my thinking was it'd be best to keep as much parity as makes sense between the debug and the packaged version. Based on the rake install step I assumed that adding the default value would be the lowest touch way to keep things harmonious (if the debug version requires default path Resources/templates running install will overwrite the main.swift file and require reset). However I certainly understand that the .app is a secondary feature. Some other options I considered were:
- A build script to package the .app more like the cli tool (discussed here)
- Using a different relative path value depending on the target.
- Resetting the path value in
main.swiftafter the install step finishes in the rake file.
Let me know if any of these options appeal to you and I'd be happy to implement it (or if I'm off in the wrong direction all together 😬)
There was a problem hiding this comment.
Ah, I see.
But I think even without this PR, the main.swift was modified by the Rakefile anyway, as it can always be installed in any place you like depending on the rake task arguments…
And I'd still prefer keeping the structure of the final binary untouched, first because it's more standard, second because changing it would mean adapting the Homebrew's formula too, and because the final product is more important and the .app is just a convenience structure for development, not for distribution.
So I think the best option is to:
- Keep the templates in Resources for the development mode (.app bundle) — We could even point the
templatesRelativePathtoNSBundle.main.resourcesDirectoryto make it more dynamic? — because that's what .app bundles expect and the place where Xcode will put them - Keep the
Rakefilechanging that value to$tpldir, which by default if not specified when callingrake, would be../templatesto match what Homebrew and CLI binaries expect - Don't
git reset main.swiftat the end ofrake. TheRakefilealready did change themain.swiftwithout reverting it before that PR, and I think that's OK:- now that the project will be organized as an app bundle, we should only have to use the
Rakefileto do a release, so not that often anyway - I prefer to have a dirty git working copy after the
rake installand handle the reset manually than havingrakedo agit checkout main.swiftto reset it… and potentially accidentally also revert other changes that we might have forgotten to commit before callingrake install(another option would be to ensure that everything has been committed to git before authorizing to continue torake installbut ¯_(ツ)_/¯ )
- now that the project will be organized as an app bundle, we should only have to use the
So, in summary, commit the value of the relativePath that matches the relative path when the .app bundle stores the templates once compiled, so that a Cmd-R (and Cmd-U) works out of the box without changes from Xcode, and keep the Rakefile behavior as before, still letting it change the templateRelativePath during the rake install to match where the templates are asked to be installed according to the rake install[…] parameters, which would still default to ../templates.
4079605 to
62b0cee
Compare
|
@AliSoftware incorporated your feedback and rebased again 👍 |
swiftgen-cli/main.swift
Outdated
|
|
||
| let templatesRelativePath = "../Resources/templates" | ||
|
|
||
| let templatesRelativePath = (Bundle.main.resourcePath ?? "") + "/templates" |
There was a problem hiding this comment.
I'd use ?? "." instead. Because in case Bundle.main.resourcePath returns nil, we would end up pointing to the root of the filesystem, which seems dangerous 😉
|
Just a small change requested and I think (at least from what I read from GitHub) that we're good to go. Maybe if I have more time later I'll pull it and test and run on my Mac in Xcode (or if anyone can do it too to validate that in practice) before we (finally!) merge. |
|
Wait… I think at some point I disabled the I'm surprised not to see that Build Setting being changed in this PR's diff? Shouldn't this (well, more likely the new 🤔 I definitely will have to pull this on my Mac and inspect/test this. Diff'ing a pbxproj directly on GitHub isn't easy ^^ |
|
I can confirm that It runs from within Xcode, and also runs when moving the produced app (and deleting the other produced content such as frameworks), so there are definitely no dependencies left. |
- Copying templates to /Resources/templates - Modified rake to package accordingly
- added bundle resources to path - clean up swiftlint whitespace errs
62b0cee to
4f6e181
Compare
|
@AliSoftware Good catch on the root, I've rebased and pushed the fix. Re: the |
|
Indeed, I think we should be sure to get rid of the |
|
@AliSoftware agree! pushed the fix. |
AliSoftware
left a comment
There was a problem hiding this comment.
Still haven't have time to git pull that branch to test it in practice in Xcode, but if you assure me that it now doesn't warn upon pod install / pod update anymore now that ALWAYS_EMBED_SWIFT_LIBRARIES isn't overridden, then we should be good to go!
|
This is the output I'm getting with the latest code:
So it's good to go! |
|
I've finally got some time to pull and test in Xcode. Great work! |
…e toggled ON/OFF easily
|
I've remove the [EDIT] It seems that I managed to push my commit anyway somehow, even with the error I had on my git push… not sure how it worked 😹 |
|
🎉 |
This pull request covers the remainder of issue #169 involving the conversion to Swift 3 and project restructuring. The last 3 commits are regarding the app bundle / project restructure.
NOTE: This is built on top of PR #201 and should be merged after or instead of that request.