diff --git a/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets.dart b/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets.dart index c506c7f80a1..a29a35b9fd3 100644 --- a/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets.dart +++ b/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets.dart @@ -214,10 +214,19 @@ Map _assetTargetLocations( Uri? absolutePath, ) { final Set alreadyTakenNames = {}; - return { - for (final AssetImpl asset in nativeAssets) - asset: _targetLocationMacOS(asset, absolutePath, alreadyTakenNames), - }; + final Map idToPath = {}; + final Map result = {}; + for (final AssetImpl asset in nativeAssets) { + final KernelAssetPath path = idToPath[asset.id] ?? + _targetLocationMacOS(asset, absolutePath, alreadyTakenNames).path; + idToPath[asset.id] = path; + result[asset] = KernelAsset( + id: (asset as NativeCodeAssetImpl).id, + target: Target.fromArchitectureAndOS(asset.architecture!, asset.os), + path: path, + ); + } + return result; } KernelAsset _targetLocationMacOS( diff --git a/packages/flutter_tools/test/general.shard/isolated/macos/native_assets_test.dart b/packages/flutter_tools/test/general.shard/isolated/macos/native_assets_test.dart index 69add748a0e..d3f64668282 100644 --- a/packages/flutter_tools/test/general.shard/isolated/macos/native_assets_test.dart +++ b/packages/flutter_tools/test/general.shard/isolated/macos/native_assets_test.dart @@ -177,12 +177,25 @@ void main() { nativeAssetsYaml, projectUri.resolve('build/native_assets/macos/native_assets.yaml'), ); + final String nativeAssetsYamlContents = + await fileSystem.file(nativeAssetsYaml).readAsString(); expect( - await fileSystem.file(nativeAssetsYaml).readAsString(), + nativeAssetsYamlContents, contains('package:bar/bar.dart'), ); expect(buildRunner.buildDryRunInvocations, 1); expect(buildRunner.linkDryRunInvocations, 1); + // Check that the framework uri is identical for both archs. + final String pathSeparator = const LocalPlatform().pathSeparator; + expect( + nativeAssetsYamlContents, + stringContainsInOrder( + [ + 'bar.framework${pathSeparator}bar', + 'bar.framework${pathSeparator}bar', + ], + ), + ); }); testUsingContext('build with assets but not enabled', overrides: {