You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

251 lines
9.8 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. # Firebase iOS Open Source Development [![Build Status](https://travis-ci.org/firebase/firebase-ios-sdk.svg?branch=master)](https://travis-ci.org/firebase/firebase-ios-sdk)
  2. This repository contains a subset of the Firebase iOS SDK source. It currently
  3. includes FirebaseCore, FirebaseABTesting, FirebaseAuth, FirebaseDatabase,
  4. FirebaseFirestore, FirebaseFunctions, FirebaseInstanceID, FirebaseInAppMessaging,
  5. FirebaseInAppMessagingDisplay, FirebaseMessaging, FirebaseRemoteConfig, and
  6. FirebaseStorage.
  7. The repository also includes GoogleUtilities source. The
  8. [GoogleUtilities](GoogleUtilities/README.md) pod is
  9. a set of utilities used by Firebase and other Google products.
  10. Firebase is an app development platform with tools to help you build, grow and
  11. monetize your app. More information about Firebase can be found at
  12. [https://firebase.google.com](https://firebase.google.com).
  13. ## Installation
  14. See the three subsections for details about three different installation methods.
  15. 1. [Standard pod install](README.md#standard-pod-install)
  16. 1. [Installing from the GitHub repo](README.md#installing-from-github)
  17. 1. [Experimental Carthage](README.md#carthage-ios-only)
  18. ### Standard pod install
  19. Go to
  20. [https://firebase.google.com/docs/ios/setup](https://firebase.google.com/docs/ios/setup).
  21. ### Installing from GitHub
  22. For releases starting with 5.0.0, the source for each release is also deployed
  23. to CocoaPods master and available via standard
  24. [CocoaPods Podfile syntax](https://guides.cocoapods.org/syntax/podfile.html#pod).
  25. These instructions can be used to access the Firebase repo at other branches,
  26. tags, or commits.
  27. #### Background
  28. See
  29. [the Podfile Syntax Reference](https://guides.cocoapods.org/syntax/podfile.html#pod)
  30. for instructions and options about overriding pod source locations.
  31. #### Accessing Firebase Source Snapshots
  32. All of the official releases are tagged in this repo and available via CocoaPods. To access a local
  33. source snapshot or unreleased branch, use Podfile directives like the following:
  34. To access FirebaseFirestore via a branch:
  35. ```
  36. pod 'FirebaseCore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
  37. pod 'FirebaseFirestore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'master'
  38. ```
  39. To access FirebaseMessaging via a checked out version of the firebase-ios-sdk repo do:
  40. ```
  41. pod 'FirebaseCore', :path => '/path/to/firebase-ios-sdk'
  42. pod 'FirebaseMessaging', :path => '/path/to/firebase-ios-sdk'
  43. ```
  44. ### Carthage (iOS only)
  45. Instructions for the experimental Carthage distribution are at
  46. [Carthage](Carthage.md).
  47. ### Rome
  48. Instructions for installing binary frameworks via
  49. [Rome](https://github.com/CocoaPods/Rome) are at [Rome](Rome.md).
  50. ## Development
  51. To develop Firebase software in this repository, ensure that you have at least
  52. the following software:
  53. * Xcode 10.1 (or later)
  54. * CocoaPods 1.7.2 (or later)
  55. * [CocoaPods generate](https://github.com/square/cocoapods-generate)
  56. For the pod that you want to develop:
  57. `pod gen Firebase{name here}.podspec --local-sources=./ --auto-open --platforms=ios`
  58. Note: If the CocoaPods cache is out of date, you may need to run
  59. `pod repo update` before the `pod gen` command.
  60. Note: Set the `--platforms` option to `macos` or `tvos` to develop/test for
  61. those platforms. Since 10.2, Xcode does not properly handle multi-platform
  62. CocoaPods workspaces.
  63. Firestore has a self contained Xcode project. See
  64. [Firestore/README.md](Firestore/README.md).
  65. ### Development for Catalyst
  66. * `pod gen {name here}.podspec --local-sources=./ --auto-open --platforms=ios`
  67. * Check the Mac box in the App-iOS Build Settings
  68. * Sign the App in the Settings Signing & Capabilities tab
  69. * Click Pods in the Project Manager
  70. * Add Signing to the iOS host app and unit test targets
  71. * Select the Unit-unit scheme
  72. * Run it to build and test
  73. ### Adding a New Firebase Pod
  74. See [AddNewPod.md](AddNewPod.md).
  75. ### Code Formatting
  76. To ensure that the code is formatted consistently, run the script
  77. [./scripts/style.sh](https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/style.sh)
  78. before creating a PR.
  79. Travis will verify that any code changes are done in a style compliant way. Install
  80. `clang-format` and `swiftformat`.
  81. These commands will get the right versions:
  82. ```
  83. brew upgrade https://raw.githubusercontent.com/Homebrew/homebrew-core/e3496d9/Formula/clang-format.rb
  84. brew upgrade https://raw.githubusercontent.com/Homebrew/homebrew-core/7963c3d/Formula/swiftformat.rb
  85. ```
  86. Note: if you already have a newer version of these installed you may need to
  87. `brew switch` to this version.
  88. To update this section, find the versions of clang-format and swiftformat.rb to
  89. match the versions in the CI failure logs
  90. [here](https://github.com/Homebrew/homebrew-core/tree/master/Formula).
  91. ### Running Unit Tests
  92. Select a scheme and press Command-u to build a component and run its unit tests.
  93. #### Viewing Code Coverage
  94. First, make sure that [xcov](https://github.com/nakiostudio/xcov) is installed with `gem install xcov`.
  95. After running the `AllUnitTests_iOS` scheme in Xcode, execute
  96. `xcov --workspace Firebase.xcworkspace --scheme AllUnitTests_iOS --output_directory xcov_output`
  97. at Example/ in the terminal. This will aggregate the coverage, and you can run `open xcov_output/index.html` to see the results.
  98. ### Running Sample Apps
  99. In order to run the sample apps and integration tests, you'll need valid
  100. `GoogleService-Info.plist` files for those samples. The Firebase Xcode project contains dummy plist
  101. files without real values, but can be replaced with real plist files. To get your own
  102. `GoogleService-Info.plist` files:
  103. 1. Go to the [Firebase Console](https://console.firebase.google.com/)
  104. 2. Create a new Firebase project, if you don't already have one
  105. 3. For each sample app you want to test, create a new Firebase app with the sample app's bundle
  106. identifier (e.g. `com.google.Database-Example`)
  107. 4. Download the resulting `GoogleService-Info.plist` and replace the appropriate dummy plist file
  108. (e.g. in [Example/Database/App/](Example/Database/App/));
  109. Some sample apps like Firebase Messaging ([Example/Messaging/App](Example/Messaging/App)) require
  110. special Apple capabilities, and you will have to change the sample app to use a unique bundle
  111. identifier that you can control in your own Apple Developer account.
  112. ## Specific Component Instructions
  113. See the sections below for any special instructions for those components.
  114. ### Firebase Auth
  115. If you're doing specific Firebase Auth development, see
  116. [the Auth Sample README](Example/Auth/README.md) for instructions about
  117. building and running the FirebaseAuth pod along with various samples and tests.
  118. ### Firebase Database
  119. To run the Database Integration tests, make your database authentication rules
  120. [public](https://firebase.google.com/docs/database/security/quickstart).
  121. ### Firebase Storage
  122. To run the Storage Integration tests, follow the instructions in
  123. [FIRStorageIntegrationTests.m](Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m).
  124. #### Push Notifications
  125. Push notifications can only be delivered to specially provisioned App IDs in the developer portal.
  126. In order to actually test receiving push notifications, you will need to:
  127. 1. Change the bundle identifier of the sample app to something you own in your Apple Developer
  128. account, and enable that App ID for push notifications.
  129. 2. You'll also need to
  130. [upload your APNs Provider Authentication Key or certificate to the Firebase Console](https://firebase.google.com/docs/cloud-messaging/ios/certs)
  131. at **Project Settings > Cloud Messaging > [Your Firebase App]**.
  132. 3. Ensure your iOS device is added to your Apple Developer portal as a test device.
  133. #### iOS Simulator
  134. The iOS Simulator cannot register for remote notifications, and will not receive push notifications.
  135. In order to receive push notifications, you'll have to follow the steps above and run the app on a
  136. physical device.
  137. ## Community Supported Efforts
  138. We've seen an amazing amount of interest and contributions to improve the Firebase SDKs, and we are
  139. very grateful! We'd like to empower as many developers as we can to be able to use Firebase and
  140. participate in the Firebase community.
  141. ### tvOS, macOS, and Catalyst
  142. Thanks to contributions from the community, FirebaseABTesting, FirebaseAuth, FirebaseCore,
  143. FirebaseDatabase, FirebaseMessaging, FirebaseFirestore,
  144. FirebaseFunctions, FirebaseRemoteConfig, and FirebaseStorage now compile, run unit tests, and work on
  145. tvOS, macOS, and Catalyst.
  146. For tvOS, checkout the [Sample](Example/tvOSSample).
  147. Keep in mind that macOS, Catalyst and tvOS are not officially supported by Firebase, and this
  148. repository is actively developed primarily for iOS. While we can catch basic unit test issues with
  149. Travis, there may be some changes where the SDK no longer works as expected on macOS or tvOS. If you
  150. encounter this, please [file an issue](https://github.com/firebase/firebase-ios-sdk/issues).
  151. To install, add a subset of the following to the Podfile:
  152. ```
  153. pod 'Firebase/ABTesting'
  154. pod 'Firebase/Auth'
  155. pod 'Firebase/Database'
  156. pod 'Firebase/Firestore'
  157. pod 'Firebase/Functions'
  158. pod 'Firebase/Messaging'
  159. pod 'Firebase/RemoteConfig'
  160. pod 'Firebase/Storage'
  161. ```
  162. #### Additional Catalyst Notes
  163. * FirebaseAuth and FirebaseMessaging require adding `Keychain Sharing Capability`
  164. to Build Settings.
  165. * FirebaseFirestore requires signing the
  166. [gRPC Resource target](https://github.com/firebase/firebase-ios-sdk/issues/3500#issuecomment-518741681).
  167. ## Roadmap
  168. See [Roadmap](ROADMAP.md) for more about the Firebase iOS SDK Open Source
  169. plans and directions.
  170. ## Contributing
  171. See [Contributing](CONTRIBUTING.md) for more information on contributing to the Firebase
  172. iOS SDK.
  173. ## License
  174. The contents of this repository is licensed under the
  175. [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
  176. Your use of Firebase is governed by the
  177. [Terms of Service for Firebase Services](https://firebase.google.com/terms/).