Skip to content

Commit dd19fee

Browse files
authored
Add FXIOS-11527 EngineProvider dependency registration to avoid fatal error on SampleBrowser (#25451)
* Add back dependency to avoid fatal error on SampleBrowser * Create specific DependencyHelper for SampleBrowser * Remove unused dependency for Component library
1 parent 1982bd2 commit dd19fee

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

SampleBrowser/SampleBrowser.xcodeproj/project.pbxproj

+12-13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
1D1C32772B97EFD4006CF034 /* TelemetryHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1C32762B97EFD4006CF034 /* TelemetryHandler.swift */; };
1111
1D96A2D72BA14D9500EF7CC7 /* DefaultAdsTrackerDefinitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D96A2D62BA14D9500EF7CC7 /* DefaultAdsTrackerDefinitions.swift */; };
12+
21AE78502D8B4AE6002FDC9E /* DependencyHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21AE784E2D8B4AE6002FDC9E /* DependencyHelper.swift */; };
1213
8A0687612B6D9F990031427A /* SettingsDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A0687602B6D9F990031427A /* SettingsDelegate.swift */; };
1314
8A0F446B2B56EDC900438589 /* EngineProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A0F446A2B56EDC900438589 /* EngineProvider.swift */; };
1415
8A0F446E2B56EF1A00438589 /* WebEngine in Frameworks */ = {isa = PBXBuildFile; productRef = 8A0F446D2B56EF1A00438589 /* WebEngine */; };
@@ -46,7 +47,6 @@
4647
8ADF72CA2B73DB9700530E7A /* MainFrameAtDocumentEnd.js in Resources */ = {isa = PBXBuildFile; fileRef = 8ADF72C52B73DB9700530E7A /* MainFrameAtDocumentEnd.js */; };
4748
8AEBDD712B69A8C300FE9192 /* AppLaunchUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AEBDD702B69A8C300FE9192 /* AppLaunchUtil.swift */; };
4849
E132973C2BA9E71B0095FF61 /* ToolbarKit in Frameworks */ = {isa = PBXBuildFile; productRef = E132973B2BA9E71B0095FF61 /* ToolbarKit */; };
49-
E189C24B2BB2D1140065CEF2 /* DependencyHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = E189C2492BB2D1140065CEF2 /* DependencyHelper.swift */; };
5050
E1A58CC52BC3FF8F004009F1 /* AddressToolbarContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1A58CC42BC3FF8F004009F1 /* AddressToolbarContainer.swift */; };
5151
E1C525C62BCFF77900073A6D /* RootViewControllerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1C525C52BCFF77900073A6D /* RootViewControllerModel.swift */; };
5252
E1CF5D1C2BC82F9E00F2287F /* AddressToolbarContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1CF5D1B2BC82F9E00F2287F /* AddressToolbarContainerModel.swift */; };
@@ -57,6 +57,7 @@
5757
/* Begin PBXFileReference section */
5858
1D1C32762B97EFD4006CF034 /* TelemetryHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TelemetryHandler.swift; sourceTree = "<group>"; };
5959
1D96A2D62BA14D9500EF7CC7 /* DefaultAdsTrackerDefinitions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultAdsTrackerDefinitions.swift; sourceTree = "<group>"; };
60+
21AE784E2D8B4AE6002FDC9E /* DependencyHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DependencyHelper.swift; sourceTree = "<group>"; };
6061
8A0687602B6D9F990031427A /* SettingsDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsDelegate.swift; sourceTree = "<group>"; };
6162
8A0F44682B56ECBF00438589 /* BrowserKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserKit; path = ../BrowserKit; sourceTree = "<group>"; };
6263
8A0F446A2B56EDC900438589 /* EngineProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EngineProvider.swift; sourceTree = "<group>"; };
@@ -95,7 +96,6 @@
9596
8ADF72C42B73DB9700530E7A /* AllFramesAtDocumentEnd.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = AllFramesAtDocumentEnd.js; sourceTree = "<group>"; };
9697
8ADF72C52B73DB9700530E7A /* MainFrameAtDocumentEnd.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = MainFrameAtDocumentEnd.js; sourceTree = "<group>"; };
9798
8AEBDD702B69A8C300FE9192 /* AppLaunchUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLaunchUtil.swift; sourceTree = "<group>"; };
98-
E189C2492BB2D1140065CEF2 /* DependencyHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DependencyHelper.swift; sourceTree = "<group>"; };
9999
E1A58CC42BC3FF8F004009F1 /* AddressToolbarContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressToolbarContainer.swift; sourceTree = "<group>"; };
100100
E1C525C52BCFF77900073A6D /* RootViewControllerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewControllerModel.swift; sourceTree = "<group>"; };
101101
E1CF5D1B2BC82F9E00F2287F /* AddressToolbarContainerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressToolbarContainerModel.swift; sourceTree = "<group>"; };
@@ -116,6 +116,14 @@
116116
/* End PBXFrameworksBuildPhase section */
117117

118118
/* Begin PBXGroup section */
119+
21AE784F2D8B4AE6002FDC9E /* Dependency */ = {
120+
isa = PBXGroup;
121+
children = (
122+
21AE784E2D8B4AE6002FDC9E /* DependencyHelper.swift */,
123+
);
124+
path = Dependency;
125+
sourceTree = "<group>";
126+
};
119127
8A0F44692B56EDC000438589 /* Engine */ = {
120128
isa = PBXGroup;
121129
children = (
@@ -206,6 +214,7 @@
206214
8A4601E32B0FE20500FFD17F /* SampleBrowser */ = {
207215
isa = PBXGroup;
208216
children = (
217+
21AE784F2D8B4AE6002FDC9E /* Dependency */,
209218
8A4601E42B0FE20500FFD17F /* AppDelegate.swift */,
210219
8AEBDD702B69A8C300FE9192 /* AppLaunchUtil.swift */,
211220
8A4601ED2B0FE20700FFD17F /* Assets.xcassets */,
@@ -215,7 +224,6 @@
215224
8A4601EF2B0FE20700FFD17F /* LaunchScreen.storyboard */,
216225
8A0F44882B5704C100438589 /* Model */,
217226
8A0F44892B57050200438589 /* Networking */,
218-
E189C24A2BB2D1140065CEF2 /* Dependency */,
219227
8A4601E62B0FE20500FFD17F /* SceneDelegate.swift */,
220228
1D1C32762B97EFD4006CF034 /* TelemetryHandler.swift */,
221229
8A4602142B0FE40E00FFD17F /* UI */,
@@ -280,15 +288,6 @@
280288
path = Scripts;
281289
sourceTree = "<group>";
282290
};
283-
E189C24A2BB2D1140065CEF2 /* Dependency */ = {
284-
isa = PBXGroup;
285-
children = (
286-
E189C2492BB2D1140065CEF2 /* DependencyHelper.swift */,
287-
);
288-
name = Dependency;
289-
path = ../../SampleComponentLibraryApp/SampleComponentLibraryApp/Dependency;
290-
sourceTree = "<group>";
291-
};
292291
/* End PBXGroup section */
293292

294293
/* Begin PBXNativeTarget section */
@@ -408,7 +407,6 @@
408407
8A0F447D2B56FD9600438589 /* SearchModel.swift in Sources */,
409408
8A0F44852B56FFFC00438589 /* SearchTerm.swift in Sources */,
410409
1D96A2D72BA14D9500EF7CC7 /* DefaultAdsTrackerDefinitions.swift in Sources */,
411-
E189C24B2BB2D1140065CEF2 /* DependencyHelper.swift in Sources */,
412410
8A3DB32F2B5AD3D400F89705 /* SettingsCell.swift in Sources */,
413411
8A0F44792B56FD6E00438589 /* SuggestionCellViewModel.swift in Sources */,
414412
8A3DB32D2B5AD3C700F89705 /* SettingsViewController.swift in Sources */,
@@ -423,6 +421,7 @@
423421
8A0687612B6D9F990031427A /* SettingsDelegate.swift in Sources */,
424422
E1CF5D1C2BC82F9E00F2287F /* AddressToolbarContainerModel.swift in Sources */,
425423
8A0F44812B56FDEA00438589 /* SearchDataProvider.swift in Sources */,
424+
21AE78502D8B4AE6002FDC9E /* DependencyHelper.swift in Sources */,
426425
E1F816B12BCEBB940043E2E0 /* NavigationToolbarContainer.swift in Sources */,
427426
8A4602202B0FE52F00FFD17F /* UISearchbar+Extension.swift in Sources */,
428427
8A3DB3312B5AD3E000F89705 /* SettingsDataSource.swift in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/
4+
5+
import UIKit
6+
import Common
7+
8+
class DependencyHelper {
9+
func bootstrapDependencies() {
10+
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
11+
// Fatal error here so we can gather info as this would cause a crash down the line anyway
12+
fatalError("Failed to register any dependencies")
13+
}
14+
15+
let themeManager: ThemeManager = appDelegate.themeManager
16+
AppContainer.shared.register(service: themeManager)
17+
18+
let engineProvider = appDelegate.engineProvider
19+
AppContainer.shared.register(service: engineProvider)
20+
21+
// Tell the container we are done registering
22+
AppContainer.shared.bootstrap()
23+
}
24+
25+
func reset() {
26+
AppContainer.shared.reset()
27+
}
28+
29+
static var baseBundleIdentifier: String {
30+
let bundle = Bundle.main
31+
let packageType = bundle.object(forInfoDictionaryKey: "CFBundlePackageType") as? String
32+
let baseBundleIdentifier = bundle.bundleIdentifier!
33+
if packageType == "XPC!" {
34+
let components = baseBundleIdentifier.components(separatedBy: ".")
35+
return components[0 ..< components.count - 1].joined(separator: ".")
36+
}
37+
return baseBundleIdentifier
38+
}
39+
}

0 commit comments

Comments
 (0)