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

Commit f2171df

Browse files
author
Chris Yang
committed
review
format
1 parent 7943f5c commit f2171df

File tree

11 files changed

+32
-34
lines changed

11 files changed

+32
-34
lines changed

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

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88

99
FLUTTER_ASSERT_ARC
1010

11+
static GetFlutterAssetPathFromBundle(NSBundle* bundle) {
12+
NSString* flutterAssetsPath = FLTAssetPath(bundle);
13+
// Use the raw path solution so that asset path can be returned from unloaded bundles.
14+
// See https://github.com/flutter/engine/pull/46073
15+
NSString* assetsPath = [bundle pathForResource:flutterAssetsPath ofType:nil];
16+
if (assetsPath.length == 0) {
17+
// In app extension, using full relative path (kDefaultAssetPath)
18+
// returns nil when the app bundle is not loaded. Try to use
19+
// the sub folder name, which can successfully return a valid path.
20+
assetsPath = [bundle pathForResource:@"flutter_assets" ofType:nil];
21+
}
22+
return assetsPath;
23+
}
24+
1125
const NSString* kDefaultAssetPath = @"Frameworks/App.framework/flutter_assets";
1226

1327
NSBundle* FLTFrameworkBundleInternal(NSString* flutterFrameworkBundleID, NSURL* searchURL) {
@@ -29,7 +43,7 @@
2943
}
3044

3145
NSBundle* FLTGetApplicationBundle() {
32-
NSBundle* mainBundle = [NSBundle mainBundle];
46+
NSBundle* mainBundle = NSBundle.mainBundle;
3347
// App extension bundle is in <AppName>.app/PlugIns/Extension.appex.
3448
if ([mainBundle.bundleURL.pathExtension isEqualToString:@"appex"]) {
3549
// Up two levels.
@@ -48,7 +62,7 @@
4862
flutterFrameworkBundle = [NSBundle bundleWithIdentifier:flutterFrameworkBundleID];
4963
}
5064
if (flutterFrameworkBundle == nil) {
51-
flutterFrameworkBundle = [NSBundle mainBundle];
65+
flutterFrameworkBundle = NSBundle.mainBundle;
5266
}
5367
return flutterFrameworkBundle;
5468
}
@@ -58,26 +72,9 @@
5872
}
5973

6074
NSString* FLTAssetsPathFromBundle(NSBundle* bundle) {
61-
NSString* flutterAssetsPath = FLTAssetPath(bundle);
62-
// Use the raw path solution so that asset path can be returned from unloaded bundles.
63-
// See https://github.com/flutter/engine/pull/46073
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];
75+
NSString* flutterAssetsPath = GetFlutterAssetPathFromBundle(bundle);
76+
if (flutterAssetsPath.length == 0) {
77+
flutterAssetsPath = GetFlutterAssetPathFromBundle(NSBundle.mainBundle);
7078
}
71-
72-
if (assetsPath.length == 0) {
73-
assetsPath = [[NSBundle mainBundle] pathForResource:flutterAssetsPath ofType:nil];
74-
}
75-
76-
if (assetsPath.length == 0) {
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];
81-
}
82-
return assetsPath;
79+
return flutterAssetsPath;
8380
}

testing/scenario_app/ios/FlutterAppExtensionTestHost/FlutterAppExtensionTestHost/AppDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

testing/scenario_app/ios/FlutterAppExtensionTestHost/FlutterAppExtensionTestHost/AppDelegate.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4+
45
#import "AppDelegate.h"
56

67
@interface AppDelegate ()

testing/scenario_app/ios/FlutterAppExtensionTestHost/FlutterAppExtensionTestHost/SceneDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

testing/scenario_app/ios/FlutterAppExtensionTestHost/FlutterAppExtensionTestHost/SceneDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

testing/scenario_app/ios/FlutterAppExtensionTestHost/FlutterAppExtensionTestHost/ViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

testing/scenario_app/ios/FlutterAppExtensionTestHost/FlutterAppExtensionTestHost/ViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

testing/scenario_app/ios/FlutterAppExtensionTestHost/FlutterAppExtensionTestHost/main.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

testing/scenario_app/ios/Scenarios/ScenariosShare/ShareViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

testing/scenario_app/ios/Scenarios/ScenariosShare/ShareViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Chromium Authors. All rights reserved.
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

testing/scenario_app/ios/Scenarios/ScenariosUITests/AppExtensionTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ - (void)testAppExtensionLaunching {
2727
}
2828
[button tap];
2929
BOOL launchedExtensionInFlutter = NO;
30-
// Custom share extenton button (like the one we made in this test) does not have a unique
30+
// Custom share extension button (like the one in this test) does not have a unique
3131
// identity. They are all identified as `XCElementSnapshotPrivilegedValuePlaceholder`.
32-
// We loop through all the `XCElementSnapshotPrivilegedValuePlaceholder` and find the Flutter one.
32+
// Loop through all the `XCElementSnapshotPrivilegedValuePlaceholder` and find the Flutter one.
3333
for (int i = 0; i < self.hostApplication.collectionViews.cells.count; i++) {
3434
XCUIElement* shareSheetCell =
3535
[self.hostApplication.collectionViews.cells elementBoundByIndex:i];

0 commit comments

Comments
 (0)