Skip to content

[rive_native] Issue on a dart 3.7 workspace project + workaround #467

@tpucci

Description

@tpucci

Hey there :)

I suggest a modification on the setup.dart file to handle dart workspaces.

String _findPackageLocation() {
    // Assumed package root
    var root = Directory.current.uri;

    // Resolved package location running from build scripts
    if (root.path.endsWith('/macos/Pods/') ||
        root.path.endsWith('/ios/Pods/')) {
      root = root.resolve('../..');
    }

+   final pubspecFile = File.fromUri(root.resolve('pubspec.yaml'));
+   if (pubspecFile.existsSync()) {
+     final pubspecContent = pubspecFile.readAsStringSync();
+     if (pubspecContent.contains('resolution: workspace')) {
+       final workspacePackagesOutput = Process.runSync(
+         'dart',
+         ['pub', 'workspace', 'list'],
+         workingDirectory: root.toFilePath(),
+       ).stdout.toString();
+       final lines = workspacePackagesOutput.split('\n');
+       if (lines.length > 1) {
+         final firstPackagePath = lines[1].split(RegExp(r'\s+'))[1];
+         root = root.resolveUri(Uri.directory(firstPackagePath));
+       }
+       Print.verbose('Workspace project root detected. Adjusted root to:');
+     } else {
+       Print.verbose('Building $packageName with assumed project root in:');
+     }
+   }
    Print.verbose('${root.toFilePath()}\n');

    final packageConfigFile =
        File.fromUri(root.resolve('.dart_tool/package_config.json'));

    if (!packageConfigFile.existsSync()) {
      throw Exception('Package config file not found.');
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions