Skip to content

Commit 96ee28c

Browse files
committed
chore: migrate ios code obj-c -> swift
1 parent 0ced09c commit 96ee28c

15 files changed

+438
-422
lines changed

packages/firebase_app_check/firebase_app_check/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11+
14C7769AAE6B32133AA5CD0C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 89D2B16D9A434347D5972425 /* Pods_Runner.framework */; };
1112
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1213
4627F94B299406540090DA25 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BBE2A093D0D5DFBA7CE858E4 /* GoogleService-Info.plist */; };
1314
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
@@ -40,6 +41,7 @@
4041
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
4142
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
4243
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
44+
89D2B16D9A434347D5972425 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4345
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
4446
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
4547
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -48,7 +50,10 @@
4850
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4951
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
5052
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
53+
A0D98577EA5F91F62EFA6154 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
54+
BBDE97449FE5A7D57A5899FC /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
5155
BBE2A093D0D5DFBA7CE858E4 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
56+
D77D1E6A1B0B238106A314B8 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
5257
/* End PBXFileReference section */
5358

5459
/* Begin PBXFrameworksBuildPhase section */
@@ -57,12 +62,21 @@
5762
buildActionMask = 2147483647;
5863
files = (
5964
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
65+
14C7769AAE6B32133AA5CD0C /* Pods_Runner.framework in Frameworks */,
6066
);
6167
runOnlyForDeploymentPostprocessing = 0;
6268
};
6369
/* End PBXFrameworksBuildPhase section */
6470

6571
/* Begin PBXGroup section */
72+
12AA3CE588BAE31BEE665D65 /* Frameworks */ = {
73+
isa = PBXGroup;
74+
children = (
75+
89D2B16D9A434347D5972425 /* Pods_Runner.framework */,
76+
);
77+
name = Frameworks;
78+
sourceTree = "<group>";
79+
};
6680
9740EEB11CF90186004384FC /* Flutter */ = {
6781
isa = PBXGroup;
6882
children = (
@@ -82,6 +96,7 @@
8296
97C146EF1CF9000F007C117D /* Products */,
8397
F919868105D7CB93D33CAD83 /* Pods */,
8498
BBE2A093D0D5DFBA7CE858E4 /* GoogleService-Info.plist */,
99+
12AA3CE588BAE31BEE665D65 /* Frameworks */,
85100
);
86101
sourceTree = "<group>";
87102
};
@@ -122,6 +137,9 @@
122137
F919868105D7CB93D33CAD83 /* Pods */ = {
123138
isa = PBXGroup;
124139
children = (
140+
A0D98577EA5F91F62EFA6154 /* Pods-Runner.debug.xcconfig */,
141+
BBDE97449FE5A7D57A5899FC /* Pods-Runner.release.xcconfig */,
142+
D77D1E6A1B0B238106A314B8 /* Pods-Runner.profile.xcconfig */,
125143
);
126144
path = Pods;
127145
sourceTree = "<group>";
@@ -133,13 +151,15 @@
133151
isa = PBXNativeTarget;
134152
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
135153
buildPhases = (
154+
C37AD95B42832F6A68E334D2 /* [CP] Check Pods Manifest.lock */,
136155
9740EEB61CF901F6004384FC /* Run Script */,
137156
97C146EA1CF9000F007C117D /* Sources */,
138157
97C146EB1CF9000F007C117D /* Frameworks */,
139158
97C146EC1CF9000F007C117D /* Resources */,
140159
9705A1C41CF9048500538489 /* Embed Frameworks */,
141160
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
142161
46A64A04299681F5003FC4F3 /* ShellScript */,
162+
AFB7A6C16FE39E97CCC45D78 /* [CP] Embed Pods Frameworks */,
143163
);
144164
buildRules = (
145165
);
@@ -252,6 +272,45 @@
252272
shellPath = /bin/sh;
253273
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
254274
};
275+
AFB7A6C16FE39E97CCC45D78 /* [CP] Embed Pods Frameworks */ = {
276+
isa = PBXShellScriptBuildPhase;
277+
buildActionMask = 2147483647;
278+
files = (
279+
);
280+
inputFileListPaths = (
281+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
282+
);
283+
name = "[CP] Embed Pods Frameworks";
284+
outputFileListPaths = (
285+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
286+
);
287+
runOnlyForDeploymentPostprocessing = 0;
288+
shellPath = /bin/sh;
289+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
290+
showEnvVarsInLog = 0;
291+
};
292+
C37AD95B42832F6A68E334D2 /* [CP] Check Pods Manifest.lock */ = {
293+
isa = PBXShellScriptBuildPhase;
294+
buildActionMask = 2147483647;
295+
files = (
296+
);
297+
inputFileListPaths = (
298+
);
299+
inputPaths = (
300+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
301+
"${PODS_ROOT}/Manifest.lock",
302+
);
303+
name = "[CP] Check Pods Manifest.lock";
304+
outputFileListPaths = (
305+
);
306+
outputPaths = (
307+
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
308+
);
309+
runOnlyForDeploymentPostprocessing = 0;
310+
shellPath = /bin/sh;
311+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
312+
showEnvVarsInLog = 0;
313+
};
255314
/* End PBXShellScriptBuildPhase section */
256315

257316
/* Begin PBXSourcesBuildPhase section */

packages/firebase_app_check/firebase_app_check/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
buildConfiguration = "Debug"
4545
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4646
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
47+
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
4748
shouldUseLaunchSchemeArgsEnv = "YES">
4849
<MacroExpansion>
4950
<BuildableReference
@@ -61,11 +62,13 @@
6162
buildConfiguration = "Debug"
6263
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
6364
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
65+
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
6466
launchStyle = "0"
6567
useCustomWorkingDirectory = "NO"
6668
ignoresPersistentStateOnLaunch = "NO"
6769
debugDocumentVersioning = "YES"
6870
debugServiceExtension = "internal"
71+
enableGPUValidationMode = "1"
6972
allowLocationSimulation = "YES">
7073
<BuildableProductRunnable
7174
runnableDebuggingMode = "0">

packages/firebase_app_check/firebase_app_check/ios/firebase_app_check.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Pod::Spec.new do |s|
2424
s.license = { :file => '../LICENSE' }
2525
s.authors = 'The Chromium Authors'
2626
s.source = { :path => '.' }
27-
s.source_files = 'firebase_app_check/Sources/firebase_app_check/**/*.{h,m}'
28-
s.public_header_files = 'firebase_app_check/Sources/firebase_app_check/include/*.h'
27+
s.source_files = 'firebase_app_check/Sources/firebase_app_check/**/*.{swift}'
28+
s.swift_version = '5.0'
2929
s.ios.deployment_target = '15.0'
3030

3131
# Flutter dependencies

packages/firebase_app_check/firebase_app_check/ios/firebase_app_check/Sources/firebase_app_check/FLTAppCheckProvider.m

Lines changed: 0 additions & 52 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2021 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import Foundation
6+
import FirebaseAppCheck
7+
import FirebaseCore
8+
9+
class FLTAppCheckProvider: NSObject, AppCheckProvider {
10+
var app: FirebaseApp?
11+
var delegateProvider: AppCheckProvider?
12+
13+
init(app: FirebaseApp) {
14+
super.init()
15+
self.app = app
16+
}
17+
18+
func configure(app: FirebaseApp, providerName: String) {
19+
switch providerName {
20+
case "debug":
21+
let provider: AppCheckDebugProvider? = AppCheckDebugProvider(app: app)
22+
if let debugToken = provider?.localDebugToken() {
23+
print("Firebase App Check Debug Token: \(debugToken)")
24+
}
25+
self.delegateProvider = provider
26+
27+
case "deviceCheck":
28+
self.delegateProvider = DeviceCheckProvider(app: app)
29+
30+
case "appAttest":
31+
if #available(iOS 14.0, macCatalyst 14.0, tvOS 15.0, watchOS 9.0, *) {
32+
self.delegateProvider = AppAttestProvider(app: app)
33+
} else {
34+
// This is not a valid environment, setup debug provider.
35+
self.delegateProvider = AppCheckDebugProvider(app: app)
36+
}
37+
38+
case "appAttestWithDeviceCheckFallback":
39+
if #available(iOS 14.0, *) {
40+
self.delegateProvider = AppAttestProvider(app: app)
41+
} else {
42+
self.delegateProvider = DeviceCheckProvider(app: app)
43+
}
44+
45+
default:
46+
break
47+
}
48+
}
49+
50+
func getToken(completion: @escaping (AppCheckToken?, Error?) -> Void) {
51+
// Proxying to delegateProvider
52+
delegateProvider?.getToken(completion: completion)
53+
}
54+
}

packages/firebase_app_check/firebase_app_check/ios/firebase_app_check/Sources/firebase_app_check/FLTAppCheckProviderFactory.m

Lines changed: 0 additions & 47 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2021 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import Foundation
6+
import FirebaseAppCheck
7+
import FirebaseCore
8+
9+
class FLTAppCheckProviderFactory: NSObject, AppCheckProviderFactory {
10+
var providers: [String: FLTAppCheckProvider]?
11+
12+
func createProvider(with app: FirebaseApp) -> AppCheckProvider? {
13+
// The SDK may try to call this before we have been configured,
14+
// so we will configure ourselves and set the provider up as a default to start
15+
// pre-configure
16+
if providers == nil {
17+
providers = [:]
18+
}
19+
20+
if providers?[app.name] == nil {
21+
providers?[app.name] = FLTAppCheckProvider(app: app)
22+
if let provider = providers?[app.name] {
23+
// We set "deviceCheck" as this is currently what is default. Backward compatible.
24+
provider.configure(app: app, providerName: "deviceCheck")
25+
}
26+
}
27+
28+
return providers?[app.name]
29+
}
30+
31+
func configure(app: FirebaseApp, providerName: String) {
32+
if providers == nil {
33+
providers = [:]
34+
}
35+
36+
if providers?[app.name] == nil {
37+
providers?[app.name] = FLTAppCheckProvider(app: app)
38+
}
39+
40+
if let provider = providers?[app.name] {
41+
provider.configure(app: app, providerName: providerName)
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)