CoreAPITests.swift 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // Copyright 2021 Google LLC
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. // MARK: This file is used to evaluate the experience of using Firebase APIs in Swift.
  17. import Foundation
  18. import FirebaseCore
  19. final class CoreAPITests {
  20. func usage() {
  21. // MARK: - FirebaseApp
  22. // Configure Firebase app
  23. FirebaseApp.configure()
  24. if let options = FirebaseOptions(contentsOfFile: "path/to/GoogleService-Info.plist") {
  25. FirebaseApp.configure(name: "App", options: options)
  26. FirebaseApp.configure(options: options)
  27. }
  28. // Retrieve Firebase app(s)
  29. if let _ /* app */ = FirebaseApp.app() {
  30. // ...
  31. }
  32. if let _ /* app */ = FirebaseApp.app(name: "App") {
  33. // ...
  34. }
  35. if let _ /* apps */ = FirebaseApp.allApps {
  36. // ...
  37. }
  38. // Delete Firebase app
  39. if let app = FirebaseApp.app() {
  40. app.delete { _ /* succes */ in
  41. // ...
  42. }
  43. #if compiler(>=5.5) && canImport(_Concurrency)
  44. if #available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) {
  45. // async/await is a Swift 5.5+ feature available on iOS 15+
  46. Task {
  47. await app.delete()
  48. }
  49. }
  50. #endif // compiler(>=5.5) && canImport(_Concurrency)
  51. }
  52. // Properties
  53. if let app = FirebaseApp.app() {
  54. _ = app.name
  55. _ = app.options
  56. _ = app.isDataCollectionDefaultEnabled
  57. app.isDataCollectionDefaultEnabled = false
  58. }
  59. // MARK: - FirebaseConfiguration
  60. _ = FirebaseConfiguration.shared
  61. FirebaseConfiguration.shared.setLoggerLevel(.debug)
  62. // MARK: - FirebaseLoggerLevel
  63. let loggerLevel: FirebaseLoggerLevel = .debug
  64. switch loggerLevel {
  65. case FirebaseLoggerLevel.error:
  66. break
  67. case FirebaseLoggerLevel.warning:
  68. break
  69. case FirebaseLoggerLevel.notice:
  70. break
  71. case FirebaseLoggerLevel.info:
  72. break
  73. case FirebaseLoggerLevel.debug:
  74. break
  75. default:
  76. break
  77. }
  78. _ = FirebaseLoggerLevel.min
  79. _ = FirebaseLoggerLevel.max
  80. // MARK: - FirebaseOptions
  81. // FirebaseOptions default instance
  82. if let _ /* defaultOptions */ = FirebaseOptions.defaultOptions() {
  83. // ...
  84. }
  85. // FirebaseOptions initializers
  86. _ = FirebaseOptions(googleAppID: "googleAppID", gcmSenderID: "gcmSenderID")
  87. if let _ /* options */ = FirebaseOptions(contentsOfFile: "path/to/file") {
  88. // ...
  89. }
  90. // Properties
  91. if let options = FirebaseOptions.defaultOptions() {
  92. _ = options.bundleID
  93. _ = options.gcmSenderID
  94. _ = options.googleAppID
  95. if let _ /* apiKey */ = options.apiKey {
  96. // ...
  97. }
  98. if let _ /* clientID */ = options.clientID {
  99. // ...
  100. }
  101. if let _ /* trackingID */ = options.trackingID {
  102. // ...
  103. }
  104. if let _ /* projectID */ = options.projectID {
  105. // ...
  106. }
  107. if let _ /* androidClientID */ = options.androidClientID {
  108. // ...
  109. }
  110. if let _ /* databaseURL */ = options.databaseURL {
  111. // ...
  112. }
  113. if let _ /* deepLinkURLScheme */ = options.deepLinkURLScheme {
  114. // ...
  115. }
  116. if let _ /* storageBucket */ = options.storageBucket {
  117. // ...
  118. }
  119. if let _ /* appGroupID */ = options.appGroupID {
  120. // ...
  121. }
  122. }
  123. // MARK: - FirebaseVersion
  124. _ = FirebaseVersion()
  125. }
  126. }