Skip to content
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

Feature Request: Support Launch Arguments and Environment Variables #96

Open
FelixLisczyk opened this issue Dec 18, 2024 · 1 comment
Open

Comments

@FelixLisczyk
Copy link

Currently, the SweetPad extension doesn't support setting launch arguments and environment variables when launching apps. While the extension supports basic app launching through the sweetpad-lldb configuration type, developers need more control over the app's launch configuration for different development scenarios.

Current Configuration

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "sweetpad-lldb",
      "request": "launch",
      "name": "Attach to running app (SweetPad)",
      "preLaunchTask": "sweetpad: launch",
    },
  ],
}

Proposed Solution

Option 1: Enhanced Launch Configuration

Extend the existing configuration to include launch arguments and environment variables:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "sweetpad-lldb",
      "request": "launch",
      "name": "Launch App (SweetPad)",
      "preLaunchTask": "sweetpad: launch",
	  "scheme": "My Scheme",
      "launchArguments": [
        "-skipOnboarding",
        "-unlockFeatureX"
      ],
      "environmentVariables": {
        "OS_ACTIVITY_MODE": "disable",
        "OTHER_VAR": "value"
      }
    },
  ],
}

Option 2: Automatic Xcode Scheme Parser

  • Parse launch arguments and environment variables directly from the Xcode project/scheme configuration
  • No additional configuration needed in launch.json if using existing Xcode/XcodeGen/Tuist settings

Technical Considerations

  • Environment variables for the simulator must be prefixed with SIMCTL_CHILD_ (Source)
  • The extension should handle this prefix automatically
  • (Option 1) Support for multiple launch configurations in the same workspace

Use Cases

  1. Control feature flags during development:

    • Skip onboarding flows
    • Toggle feature states
    • Control unlock states
  2. Configure debugging environment:

    • Set logging levels via OS_ACTIVITY_MODE
    • Control debug output verbosity
    • Set test environment variables

Benefits

  • Improved development workflow parity with Xcode
  • More efficient testing of different app states
  • Better debugging capabilities through environment control
  • (Option 2) Seamless integration with existing Xcode/XcodeGen/Tuist configurations
@hyzyla
Copy link
Collaborator

hyzyla commented Dec 22, 2024

@FelixLisczyk, thank you for submitting this issue. Option 2 is definitely a great idea, but it’s likely the next step. In the new version of the extension, I’ve added launchArgs and launchEnv to task definitions and settings configurations. For your example you need to create separate task "tasks.json" and then use it as preLaunchTask in "launch.json"

./vscode/tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "sweetpad",
      "action": "launch",
      "problemMatcher": [
        "$sweetpad-watch",
        "$sweetpad-xcodebuild-default",
        "$sweetpad-xcbeautify-errors",
        "$sweetpad-xcbeautify-warnings"
      ],
      "label": "sweetpad: my launch",   // This is the name for preLaunchTask task
      "detail": "Build and Launch the app",
      "isBackground": true,
      "launchArgs": ["-skipOnboarding", "-unlockFeatureX"],
      "launchEnv": {
        "OS_ACTIVITY_MODE": "disable",
        "OTHER_VAR": "value"
      }
    }
  ]
}

./vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "sweetpad-lldb",
      "request": "launch",
      "name": "Attach to running app (SweetPad)",
      "preLaunchTask": "sweetpad: my launch"
    }
  ]
}
  1. Customise "preLaunchTask"
  2. Set additional launch arguments and environment variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants