Skip to content

Commit

Permalink
chore(merge): merge #192 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed May 9, 2021
2 parents 97e6482 + e35a65c commit dec9e8a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 71 deletions.
51 changes: 5 additions & 46 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import PackageDescription
let package = Package(
name: "Swiftagram",
// Supported versions.
platforms: [.iOS(.v9),
.macOS(.v10_12),
.tvOS(.v11),
.watchOS(.v3)],
platforms: [.iOS("13.0"),
.macOS("10.15"),
.tvOS("13.0"),
.watchOS("6.0")],
// Exposed libraries.
products: [.library(name: "Swiftagram",
targets: ["Swiftagram"]),
.library(name: "SwiftagramCrypto",
targets: ["SwiftagramCrypto"])],
// Package dependencies.
dependencies: [.package(url: "https://github.com/sbertix/ComposableRequest", .upToNextMinor(from: "5.0.7")),
dependencies: [.package(url: "https://github.com/sbertix/ComposableRequest", .upToNextMinor(from: "5.0.9")),
.package(url: "https://github.com/sbertix/SwCrypt.git", .upToNextMinor(from: "5.1.0"))],
// All targets.
targets: [.target(name: "Swiftagram",
Expand All @@ -32,48 +32,7 @@ let package = Package(
dependencies: ["Swiftagram", "SwiftagramCrypto"])]
)

enum CombineImplementation {
/// Apple **Combine**.
case combine
/// **cx-org/CombineX**.
case combineX

/// Default implementation.
/// If available, Apple **Combine** is always preferred.
static var `default`: CombineImplementation {
#if canImport(Combine)
return .combine
#else
return .combineX
#endif
}

/// Optional init.
///
/// - parameter description: A valid `String`.
init?(_ description: String) {
let desc = description.lowercased().filter { $0.isLetter }
switch desc {
case "combine": self = .combine
case "combinex": self = .combineX
default: return nil
}
}
}

extension ProcessInfo {
/// The selected combine implementation. Defaults to `.default`.
var combineImplementation: CombineImplementation {
return environment["CX_COMBINE_IMPLEMENTATION"].flatMap(CombineImplementation.init) ?? .default
}
}

// MARK: Adjustments

if ProcessInfo.processInfo.environment["TARGETING_WATCHOS"] == "true" {
// #workaround(xcodebuild -version 11.6, Test targets don’t work on watchOS.) @exempt(from: unicode)
package.targets.removeAll(where: { $0.isTest })
}
if ProcessInfo.processInfo.combineImplementation == .combine {
package.platforms = [.macOS("10.15"), .iOS("13.0"), .tvOS("13.0"), .watchOS("6.0")]
}
12 changes: 8 additions & 4 deletions Sources/Swiftagram/Authentication/Authenticator+Keys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ public extension Authenticator.Keys {
/// - throws: Some `Error`.
/// - returns: An array of `Secret`s.
func get() throws -> [Secret] {
try AnyStorage.items(in: authenticator.storage)
switch labels {
case let labels?:
return try AnyStorage.items(in: authenticator.storage)
.filter { labels.contains($0.label) }
default:
return try AnyStorage.items(in: authenticator.storage)
}
}

/// Delete selected `Secret`s.
Expand All @@ -70,9 +76,7 @@ public extension Authenticator.Keys {
case let labels?:
return try labels.compactMap { try authenticator.secret($0).delete() }
default:
let secrets = try? authenticator.secrets.get()
try AnyStorage.empty(authenticator.storage)
return secrets ?? []
return try authenticator.secrets.get().compactMap { try authenticator.secret($0).delete() }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public extension Authenticator.Group {
}
}
}
.setFailureType(to: Swift.Error.self)
.flatMap {
Future<AuthenticatorWebView, Swift.Error> { resolve in
// Prepare the actual `WebView`.
Expand Down
27 changes: 6 additions & 21 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
[![codecov](https://codecov.io/gh/sbertix/Swiftagram/branch/main/graph/badge.svg)](https://codecov.io/gh/sbertix/Swiftagram)
[![Telegram](https://img.shields.io/badge/Telegram-Swiftagram-blue?style=flat&logo=telegram)](https://t.me/swiftagram)
<br />
![iOS](https://img.shields.io/badge/iOS-9.0-DD5D43)
![macOS](https://img.shields.io/badge/macOS-10.12-DD5D43)
![tvOS](https://img.shields.io/badge/tvOS-11.0-DD5D43)
![watchOS](https://img.shields.io/badge/watchOS-3.0-DD5D43)
![iOS](https://img.shields.io/badge/iOS-13.0-DD5D43)
![macOS](https://img.shields.io/badge/macOS-10.15-DD5D43)
![tvOS](https://img.shields.io/badge/tvOS-13.0-DD5D43)
![watchOS](https://img.shields.io/badge/watchOS-6.0-DD5D43)

<br />

Expand All @@ -33,22 +33,6 @@ Please check out the _docs_ to find out more.

<p />

## Supporting older platform versions

**Swiftagram** relies on [**CombineX**](https://github.com/cx-org/CombineX/)'s [**CXShim**](https://github.com/cx-org/CombineX/wiki/Combine-Compatible-Package) to provide a **Combine** runtime on all platforms and versions.

However, Apple's **Combine** is used by default, meaning, without any configuration, your minimum deployment target will be limited to **iOS 13**, **macOS 10.15**, **tvOS 13** and **watchOS 6**.
If you're developing apps with **SwiftUI** or supporting recent versions alone, we suggest sticking with this default runtime, as it's supported out-of-the-box and no external libraries will be packaged inside your release archive.

If you need to support older versions, though, all you have to do, is make sure you're running your **Xcode** process specifying the custom **Combine** implementation through an environmental variable.
Something as simple as the code below is enough.

```bash
export CX_COMBINE_IMPLEMENTATION="combinex"
killall Xcode
open *.xcodeproj
```

## Status
![push](https://github.com/sbertix/Swiftagram/workflows/push/badge.svg)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/sbertix/Swiftagram)
Expand Down Expand Up @@ -257,7 +241,8 @@ var bin: Set<AnyCancellable> = []

// We're using a random endpoint to demonstrate
// how `PagerProvider` is exposed in code.
Endpoint.media(secret.identifier)
Endpoint.user(secret.identifier)
.posts
.unlock(with: secret)
.session(.instagram)
.pages(.max) // Exhaust all with `.max`
Expand Down

0 comments on commit dec9e8a

Please sign in to comment.