-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include
support for Project Definitions (reuse code across Project.swift files)
#170
Comments
❤️ this idea. This is a clear advantage compared to other manifest formats like json or yaml. In modular apps where most of the targets have a similar structure, this will be very useful. |
+1 on this. Would be a big win for my setup as well. |
@pepibumur I've actually thought about this more and not sure it's the best idea. Having the project files as declarative as possible should be our goal, introducing this might take us away from that. I can see how sharing build settings might be useful, but we should look at doing that through another mechanism |
There are ups-and-downs, sure. Currently I have a 50 line chunk that I need to keep in sync in 12 separate Some of it (like extended Carthage handling) is thankfully redundant now with recent updates to Tuist, but I haven't had the time to update yet. |
@enhorn Do you have an example of what the repeated lines are? |
Yeah, I'm also curious to see what are the most repeated pieces of code. With the information we could think of other potential solutions to tackle the reusability problem. |
Perhaps I've made this more complex than necessary. Updating my Carthage handling will definitely ease some of this. 😅 |
Thanks for taking the time to get that example written down with some diagrams. e.g. .framework(path: "//Carthage/iOS/Build/FancyButton.framework") similarly for everywhere else which defines a path. with just the above you should be able to reduce the amount of work you are required to do inside of each Project.swift file, and In addition to that the work I am doing to provide different configuration options will only aid you more. I would really advise against doing any code inside of the Project.swift file, you should prefer declarative syntax as it allows to make easier assumptions about the Project file and could even help with migrations in the future. Take a watch of the SwiftPM video from the WWDC 2018 session "Getting to know SwiftPM" https://developer.apple.com/videos/play/wwdc2018/411/ - at about 13:40 he talks in more detail about why you should prefer declarative. Do you think with the above changes it will help tuist fit your requirements? |
Yeah. Relative paths would look cleaner. :-) The issue I've solved right now is that we have about ~30 targets (defined in 11 As it is now, targets inherit their Carthage dependencies through their "Carthage-dependencies" file, and they only need to add any additional they them self use in their own dependencies file. It's generally a workaround for: #253 |
@enhorn |
Indeed. And with the recent fix for transitive dependencies, my need for this has been met. :-) No more |
Glad to hear the issue you were facing has been resolved @enhorn. I was curious about the technical feasibility of this feature so I pushed a proof of concept. My findings so far:
include("relative/path/to/Helpers.swift")
let project = myCustomProjectHelper(name: "MyProject")
e.g. // Helpers.swift
let sharedSettings = Settings(base: ["base": "base"],
debug: Configuration(settings: ["debug": "debug"],
xcconfig: "path/debug.xcconfig"),
release: Configuration(settings: ["release": "release"],
xcconfig: "path/release.xcconfig")) // Project.swift
include("relative/path/to/Helpers.swift")
let project = Project(name: "MyProject",
settings: sharedSettings) Ideally one would expect the path specified in
If the only use case we currently have is configurations, perhaps the Environments concept may be a better fit (even though less flexible than full fledged includes). |
Resolved via #668 |
Is your feature request related to a problem? Please describe.
I want to be able to write some code which can be used in all of the project definitions.
Describe the solution you'd like
A mechanism for including shared code in the Project.swift file, an example @pepibumur mentioned was including
//include includes/shared.swift
at the top of the file.We would have to map a graph for all of the includes and pass them to the compiler in the right order, from the most dependent to the least.
The text was updated successfully, but these errors were encountered: