sweetpad-dev / sweetpad

Develop Swift/iOS projects using VSCode
https://marketplace.visualstudio.com/items?itemName=sweetpad.sweetpad
MIT License
117 stars 3 forks source link

Workspace support #10

Closed rafaelpedretti-toast closed 1 hour ago

rafaelpedretti-toast commented 1 month ago

In one project I work on we have two apps on the same repo and the extension cannot find the schemes because the response from xcodebuild -list -json has a different structure:

{
  "workspace" : {
    "name" : string,
    "schemes" : string[]
}

where inside a project it is

{
  "project" : {
    "configurations" : string[],
    "name" : string,
    "schemes" : string[],
    "targets" : string[]
  }
}

It would be nice to support this configuration

hyzyla commented 1 month ago

Hello! Could you please describe your case in detail? Are they completely separate programs? When you launch an application, do you launch only one app at a time, or do you launch multiple applications in parallel?

hyzyla commented 1 month ago

@rafaelpedretti-toast Hello! I've added basic support for workspaces in the recently released version.

My first attempt to implement this feature was to parse Xcode configuration files manually, but I failed. I couldn't properly determine the schema list for the projects. Finally, I've decided to utilize the xcodebuild -list output, similar to single project workspaces. It's not ideal, but should work for some workspaces

milanhorvatovic commented 4 weeks ago

@hyzyla would be possible to add workspace configuration to specify a workspace name or a project name? Apparently, I have a similar problem where the directory contains multiple projects at the same time and in that case, xcodebuild can't provide correct output for listing schemes.

For instance, if you're using workspaces with multiple projects or SPM modules, you want to be able to specify a workspace instead of using just the first project from xcodebuild command.

hyzyla commented 4 weeks ago

@milanhorvatovic, Yeah, I think it's not a problem to add some configuration to specify a workspace or a project. I just need more information about how your project looks like to reproduce it locally. Could you provide the structure of your project and workspace? It can be the output of a comman find . \( -name "*.xcworkspace" -o -name "*.xcodeproj" \):

➜  find . \( -name "*.xcworkspace" -o -name "*.xcodeproj" \)

./sweetpad-demo-app1/sweetpad-demo-app1.xcodeproj
./sweetpad-demo-app2/sweetpad-demo-app2.xcodeproj
./sweetpad-demo-workspace.xcworkspace
./sweetpad-demo-app4/sweetpad-demo-app4.xcodeproj
./sweetpad-demo-app3/sweetpad-demo-app3.xcodeproj
milanhorvatovic commented 4 weeks ago

Maybe the better would be to add an option for developers to specific path to the workspace or project. In that case, you don't need to worry about the structure itself because it would suit almost every needs. What do you think?

Many developers have mono repositories or different directory organization for project structure and so on.

It's not ideal, but you can get the idea from this:

./TestCombineExt/TestCombineExt.xcodeproj
./TestCombineExt/TestCombineExt.xcodeproj/project.xcworkspace
./Test.xcodeproj
./Test.xcodeproj/project.xcworkspace
./TestFoundation/TestFoundation.xcodeproj
./TestFoundation/TestFoundation.xcodeproj/project.xcworkspace
./TestSDK.xcodeproj
./TestSDK.xcodeproj/project.xcworkspace
./Test.xcworkspace
./Pods/Pods.xcodeproj
./TestUI.xcodeproj
./Playground.playground/playground.xcworkspace
./SampleApp.xcodeproj
./SampleApp.xcodeproj/project.xcworkspace
hyzyla commented 3 weeks ago

@milanhorvatovic I've added a new configuration for setting the Xcode workspace path in VSCode's settings.json Set Xcode workspace path. Let me know if it works for you 🙏 (remember to update extension before)

milanhorvatovic commented 1 week ago

@hyzyla sorry about my timing, but it works nicely, thanks again.