Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 33c287b

Browse files
author
Chris Yang
committed
fix
remove teams fix tests fix test
1 parent 7b989a2 commit 33c287b

File tree

32 files changed

+1163
-13
lines changed

32 files changed

+1163
-13
lines changed

shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,23 @@
6161
NSString* flutterAssetsPath = FLTAssetPath(bundle);
6262
// Use the raw path solution so that asset path can be returned from unloaded bundles.
6363
// See https://github.com/flutter/engine/pull/46073
64-
NSString* assetsPath = [bundle pathForResource:flutterAssetsPath ofType:@""];
64+
NSString* assetsPath = [bundle pathForResource:flutterAssetsPath ofType:nil];
65+
if (assetsPath.length == 0) {
66+
// In app extension, using full relative path(kDefaultAssetPath)
67+
// returns nil when the app bundle is not loaded. We try to use
68+
// the sub folder name, which can successfully return a valid path.
69+
assetsPath = [bundle pathForResource:@"flutter_assets" ofType:nil];
70+
}
71+
72+
if (assetsPath.length == 0) {
73+
assetsPath = [[NSBundle mainBundle] pathForResource:flutterAssetsPath ofType:nil];
74+
}
6575

6676
if (assetsPath.length == 0) {
67-
assetsPath = [[NSBundle mainBundle] pathForResource:flutterAssetsPath ofType:@""];
77+
// In app extension, using full relative path(kDefaultAssetPath)
78+
// returns nil when the app bundle is not loaded. We try to use
79+
// the sub folder name, which can successfully return a valid path.
80+
assetsPath = [[NSBundle mainBundle] pathForResource:@"flutter_assets" ofType:nil];
6881
}
6982
return assetsPath;
7083
}

shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ - (void)testFLTAssetsURLFromBundle {
9393
id mockBundle = OCMClassMock([NSBundle class]);
9494
OCMStub([mockBundle objectForInfoDictionaryKey:@"FLTAssetsPath"]).andReturn(@"foo/assets");
9595
NSString* resultAssetsPath = @"path/to/foo/assets";
96-
OCMStub([mockBundle pathForResource:@"foo/assets" ofType:@""]).andReturn(resultAssetsPath);
96+
OCMStub([mockBundle pathForResource:@"foo/assets" ofType:nil]).andReturn(resultAssetsPath);
9797
NSString* path = FLTAssetsPathFromBundle(mockBundle);
9898
XCTAssertEqualObjects(path, @"path/to/foo/assets");
9999
}
@@ -102,9 +102,9 @@ - (void)testFLTAssetsURLFromBundle {
102102
id mockBundle = OCMClassMock([NSBundle class]);
103103
id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
104104
NSString* resultAssetsPath = @"path/to/foo/assets";
105-
OCMStub([mockBundle pathForResource:@"Frameworks/App.framework/flutter_assets" ofType:@""])
105+
OCMStub([mockBundle pathForResource:@"Frameworks/App.framework/flutter_assets" ofType:nil])
106106
.andReturn(nil);
107-
OCMStub([mockMainBundle pathForResource:@"Frameworks/App.framework/flutter_assets" ofType:@""])
107+
OCMStub([mockMainBundle pathForResource:@"Frameworks/App.framework/flutter_assets" ofType:nil])
108108
.andReturn(resultAssetsPath);
109109
NSString* path = FLTAssetsPathFromBundle(mockBundle);
110110
XCTAssertEqualObjects(path, @"path/to/foo/assets");

0 commit comments

Comments
 (0)