So I was trying to Set Up an Edit-Build-Test-Debug Loop and I reached this step.
As I followed the steps, I reached the place where we add the swift.xcodeproj to our xcode workspace and create an empty xcode project to be added in the same workspace.
And now I got some doubts :
Is the swift compiler present in the swift.xcodeproj where we basically have to make changes?
Why did we add a new xcodeproj to our workspace, what would it be used for?
How to add a scheme for my target? The drop-down list already has a long list of schemes, and I don't know which one to add. Also, I could not find the "Run action settings" of the scheme to modify.
How do I see the changes I make to the compiler codebase? Is there a playground or something which will run on the new compiler, so that I could test right away by giving input code?
I'm a student who has just finished up his "compilers theory" class and wants to become an active contributor at swift, So I would be extremely happy if there are any other suggestions you might want to give on how I go about next.
Those are good questions, I'll try to do my best and answer with what I know about this workflow. Note that this is still an in progress work and we are working towards a better developer experience.
This is the project generated by build script (cmake actually) and yes, it contains all targets of swift project and reference to all the source files across all compiler components e.g. libParse, libSema,... etc and as well as other components such as runtime and standard library.
So the goal of having this Swift.xcodeproj dropped into the workspace is that so it is used by Xcode to reference all source files and provide an editor experience so you can search for a file in the workspace and start making changes.
This workflow is based on taking Xcode IDE and use that on top of ninja build system. To give a bit more context before we use to build fully on top of Xcode, but that was not stable as ninja build so that is why this is the recommended workflow now. You can read more about this in here Remove/Deprecate —xcode option from build script.
But to answer the question this new project will serve as a link from Xcode to an "External Build System" in this case ninja and where we are going to create our target so we can via Xcode, link an Xcode target to a ninja executable, trigger a ninja build, attach to the debugger and start working. So in short terms, this new project is the bridge from Xcode to ninja.
It depends on what you want to work on. For the compiler you want swift-frontend. But you don't want to add the one from Swift.xcodeproj (perhaps you will to help Xcode with indexing). But at this point you should create a new target that points to the ninja executable. And that is the step right after Create an empty Xcode project in the workspace.
Once we have everything setup, we are able to invoke swift-frontend executable from Xcode and actually pass arguments to it, so you can create a simple swift file and pass as an argument through Xcode to the frontend executable with custom flags maybe. I normally get the arguments from lit execution of a test file run with -a. But there is more info about how to debug things down in this GettingStarted file.
@LucianoPAlmeida First of all, thank you very much for your help. But I'm not sure I understand the last part. How do I invoke a swift-frontend executable? How do I make a swift file which compiles on the newly edited compiler?
I had tried things like making a new swift file in the empty xcode project (which was the linker between xcode and ninja), It ended with an error:
< unknown >:0: error: no frontend action was selected
Program ended with exit code: 1
I made a swift file and tried to pass it as an argument in the scheme settings of my target of the empty xcodeproj...didn't work out.
All I want is to have a swift file that compiles on the newly edited compiler (if that's possible)