Skip to content

Commit

Permalink
Provide more flexible Account Service interactions (#39)
Browse files Browse the repository at this point in the history
# Provide more flexible Account Service interactions

## ♻️ Current situation & Problem
StanfordSpezi/SpeziAccount#62 simplified the
overall SpeziAccount design and made a lot of interactions easier. This
PR updates SpeziFirebaseAccount to this latest SpeziAccount release and
improves the overall design of SpeziFirebaseAccount.

A list of changes can be found in the next section.

## ⚙️ Release Notes 
* SpeziFirebaseAccount exposes now a single account service:
`FirebaseAccountService` that includes both the password and Sign in
with Apple provider.
* The old FirebaseAccountConfiguration was removed. Configuration is now
passed directly to the `FirebaseAccountService` instance which in turn
is passed to the `AccountConfiguration` of SpeziAccount.
* The `FirestoreAccountStorage` was updated to the new
`AccountStorageProvider` protocol and is now passed as an initializer
argument to the `AccountConfiguration`. You do no longer need to make it
a dependency of your `Standard` to forward all calls (the old constraint
as removed).

### 🚨 Breaking Schema Changes

SpeziAccount 2.0 changes the identifiers of account keys. Instead of
relying on the type names the `identifier` mirrors the lower-camel-case
name of the swift properties. For example `"GenderIdentityKey"` is now
named `"genderIdentity"`. Similar the `"DateOfBirthKey"` got renamed to
`"dateOfBirth"`. If you have an existing application using the
`FirestoreAccountStorage`, you might want to use the new `mapping`
initializer argument to provide a backwards compatibility identifier
mapping.

## 📚 Documentation
All documentation was updated to reflect the new behavior. Some
additional adjustments have been made to improve the general structure
of the SpeziFirebase documentation catalogs.

## ✅ Testing
Existing test cases were used to protect against regressions. Slightly
reduced test execution time.


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
Supereg authored Aug 20, 2024
1 parent e381b7d commit 7855a91
Show file tree
Hide file tree
Showing 50 changed files with 2,010 additions and 2,064 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
setupfirebaseemulator: true
path: Tests/UITests
customcommand: |
firebase emulators:exec 'set -o pipefail && xcodebuild test -project UITests.xcodeproj -scheme TestApp -destination "platform=iOS Simulator,name=iPhone 15 Pro" -resultBundlePath UITests.xcresult -derivedDataPath ".derivedData" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify'
firebase emulators:exec 'set -o pipefail && xcodebuild test -project UITests.xcodeproj -scheme TestApp -destination "platform=iOS Simulator,name=iPhone 15 Pro" -resultBundlePath UITests.xcresult -derivedDataPath ".derivedData" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -skipPackagePluginValidation -skipMacroValidation | xcbeautify'
uploadcoveragereport:
name: Upload Coverage Report
needs: [buildandtest, buildandtestuitests]
Expand Down
81 changes: 66 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
// SPDX-License-Identifier: MIT
//

import class Foundation.ProcessInfo
import PackageDescription


#if swift(<6)
let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("StrictConcurrency")
#else
let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("StrictConcurrency")
#endif


let package = Package(
name: "SpeziFirebase",
defaultLocalization: "en",
Expand All @@ -25,48 +33,64 @@ let package = Package(
.library(name: "SpeziFirebaseAccountStorage", targets: ["SpeziFirebaseAccountStorage"])
],
dependencies: [
.package(url: "https://github.com/StanfordSpezi/Spezi", from: "1.0.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziViews.git", from: "1.0.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziStorage", from: "1.0.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziAccount", from: "1.2.2"),
.package(url: "https://github.com/firebase/firebase-ios-sdk", from: "10.13.0")
],
.package(url: "https://github.com/StanfordSpezi/SpeziFoundation", from: "2.0.0-beta.1"),
.package(url: "https://github.com/StanfordSpezi/Spezi", from: "1.7.1"),
.package(url: "https://github.com/StanfordSpezi/SpeziViews", from: "1.6.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziAccount", exact: "2.0.0-beta.4"),
.package(url: "https://github.com/firebase/firebase-ios-sdk", from: "11.0.0"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0")
] + swiftLintPackage(),
targets: [
.target(
name: "SpeziFirebaseAccount",
dependencies: [
.target(name: "SpeziFirebaseConfiguration"),
.product(name: "SpeziFoundation", package: "SpeziFoundation"),
.product(name: "Spezi", package: "Spezi"),
.product(name: "SpeziValidation", package: "SpeziViews"),
.product(name: "SpeziAccount", package: "SpeziAccount"),
.product(name: "SpeziLocalStorage", package: "SpeziStorage"),
.product(name: "SpeziSecureStorage", package: "SpeziStorage"),
.product(name: "FirebaseAuth", package: "firebase-ios-sdk")
]
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "SpeziFirebaseConfiguration",
dependencies: [
.product(name: "Spezi", package: "Spezi"),
.product(name: "FirebaseFirestore", package: "firebase-ios-sdk")
]
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "SpeziFirestore",
dependencies: [
.target(name: "SpeziFirebaseConfiguration"),
.product(name: "Spezi", package: "Spezi"),
.product(name: "FirebaseFirestore", package: "firebase-ios-sdk"),
.product(name: "FirebaseFirestoreSwift", package: "firebase-ios-sdk")
]
.product(name: "Atomics", package: "swift-atomics")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "SpeziFirebaseStorage",
dependencies: [
.target(name: "SpeziFirebaseConfiguration"),
.product(name: "Spezi", package: "Spezi"),
.product(name: "FirebaseStorage", package: "firebase-ios-sdk")
]
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "SpeziFirebaseAccountStorage",
Expand All @@ -75,15 +99,42 @@ let package = Package(
.product(name: "Spezi", package: "Spezi"),
.product(name: "SpeziAccount", package: "SpeziAccount"),
.target(name: "SpeziFirestore")
]
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.testTarget(
name: "SpeziFirebaseTests",
dependencies: [
.target(name: "SpeziFirebaseAccount"),
.target(name: "SpeziFirebaseConfiguration"),
.target(name: "SpeziFirestore")
]
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
)
]
)


func swiftLintPlugin() -> [Target.PluginUsage] {
// Fully quit Xcode and open again with `open --env SPEZI_DEVELOPMENT_SWIFTLINT /Applications/Xcode.app`
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint")]
} else {
[]
}
}


func swiftLintPackage() -> [PackageDescription.Package.Dependency] {
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.package(url: "https://github.com/realm/SwiftLint.git", from: "0.55.1")]
} else {
[]
}
}

This file was deleted.

Loading

0 comments on commit 7855a91

Please sign in to comment.