Skip to content

Proposal:[SwiftPM] Support projects without Runner.xcworkspace #185924

Open

Description

@chika3742

Use case

After migrating to Swift Package Manager completely and removing Cocoapods, there is only one project in a typical Flutter app. In that case, the existence of the Runner.xcworkspace becomes meaningless. While Xcode alone can build even if the xcworkspace is deleted, the current Flutter CLI throws an error:

Launching lib/main.dart on iPhone 17 Pro in debug mode...
An error occurred when adding Swift Package Manager integration:
  Exception: Xcode workspace not found.

Swift Package Manager is currently an experimental feature, please file a bug at
  https://github.com/flutter/flutter/issues/new?template=01_activation.yml 
Consider including a copy of the following files in your bug report:
  ios/Runner.xcodeproj/project.pbxproj
  ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (or the scheme for the flavor used)

To add Swift Package Manager integration manually, please use the following instructions:
https://docs.flutter.dev/to/add-swift-package-manager-manually

Alternatively, to avoid this failure, disable Flutter Swift Package Manager integration for the project
by adding the following in the project's pubspec.yaml under the "flutter" section:
  config:
    enable-swift-package-manager: false
Or disable Flutter Swift Package Manager integration globally with the
following command:
  "flutter config --no-enable-swift-package-manager"

Error launching application on iPhone 17 Pro.
flutter doctor summary
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.41.6, on macOS 26.4.1 25E253 darwin-arm64, locale ja-JP)
[!] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 26.4.1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for iPhone 13. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 2 categories.

Proposal

Please support projects xcworkspace is missing. If we need to maintain compatibility with CocoaPods, we might also need a process that automatically generates the xcworkspace in cases where a newly added package in pubspec only supports Cocoapods.

Activity

  1. chika3742 commented on May 2, 2026

    @chika3742
    ContributorAuthor

    Sorry, I closed this by mistake.

  2. changed the title [-][SwiftPM] Fall back to xcodeproj when xcworkspace is missing[/-] [+][SwiftPM] Support projects without `Runner.xcworkspace`[/+] on May 2, 2026
  3. chika3742 commented on May 2, 2026

    @chika3742
    ContributorAuthor

    I checked the code, and after making the following three changes, it worked properly in my project.

    1. Remove the following lines:
      if (_xcodeProject.xcodeWorkspace == null) {
      throw Exception('Xcode workspace not found.');
      }
    2. Remove the following lines:
      if (_xcodeProject.xcodeWorkspace == null) {
      logger.printTrace('Xcode workspace not found.');
      throw _exceptionMessage();
      }
    3. Modify the following code like below:
      if (workspacePath != null) {
      buildCommands.addAll(<String>[
      '-workspace',
      workspacePath.basename,
      '-scheme',
      scheme,
      if (buildAction !=
      XcodeBuildAction.archive) // dSYM files aren't copied to the archive if BUILD_DIR is set.
      'BUILD_DIR=${globals.fs.path.absolute(buildDirectoryPath)}',
      ]);
      }
      if (workspacePath != null) {
        buildCommands.addAll(<String>[
          '-workspace',
          workspacePath.basename,
        ]);
      }
      buildCommands.addAll(<String>[
        '-scheme',
        scheme,
        if (buildAction !=
            XcodeBuildAction.archive) // dSYM files aren't copied to the archive if BUILD_DIR is set.
          'BUILD_DIR=${globals.fs.path.absolute(buildDirectoryPath)}',
      ]);

    Regarding the migration code, I am wondering why the existence of the workspace is being checked. It seems the files in .xcworkspace is not used during the migration process.

  4. changed the title [-][SwiftPM] Support projects without `Runner.xcworkspace`[/-] [+]Proposal:[SwiftPM] Support projects without `Runner.xcworkspace`[/+] on May 4, 2026
  5. added
    c: proposalA detailed proposal for a change to Flutter
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-iosOwned by iOS platform team
    t: xcode"xcodebuild" on iOS and general Xcode project management
    platform-iosiOS applications specifically
    and removed
    in triagePresently being triaged by the triage team
    on May 4, 2026
  6. hellohuanlin commented on May 4, 2026

    @hellohuanlin
    Contributor

    @chika3742 PRs welcome. Note that there can still be Cocoapods plugins in use, so make sure to check that use case too.

  7. chika3742 commented on May 6, 2026

    @chika3742
    ContributorAuthor

    I have reconsidered, and I feel that the benefits are outweighed by the significant amount of work required, such as maintaining consistency and updating related documentation. Therefore, I will close this issue myself.

  8. hellohuanlin commented on May 6, 2026

    @hellohuanlin
    Contributor

    I have reconsidered, and I feel that the benefits are outweighed by the significant amount of work required, such as maintaining consistency and updating related documentation. Therefore, I will close this issue myself.

    Well there could be contributors in the community who can help out. Re-opening since it's still a valid issue.

  9. added
    P3Issues that are less important to the Flutter project
    triaged-iosTriaged by iOS platform team
    on May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterplatform-iosiOS applications specificallyt: xcode"xcodebuild" on iOS and general Xcode project managementteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions