[sub-spm-optional-products] Add LCECryptoKit and LCFeatureControl as optional sub-SPM products

LCEssentials installs standalone; each sub target-depends on it so linking a
sub's product always pulls LCEssentials in too, without the consumer having to
declare it separately.

- LCECryptoKit: internalized from the remote LCECryptoKitBinary git dependency
  (embedded token URL removed) into a local binaryTarget vendoring
  Frameworks/LCECryptoKit.xcframework. LCECryptoKitManager moved out of
  LCEssentials core into its own LCECryptoKitManager target/product; the
  no-op fallback for when the binary wasn't linked is gone (breaking change
  for existing consumers, see decisions/2026-09-15-sub-spm-optional-products.md).
- LCFeatureControl: new product wrapping Atomenta's Feature Control API
  (flag evaluation with TTL cache + safe-degrade fallback to defaults,
  notifications inbox, batched exposure telemetry). 45 new tests.
This commit is contained in:
Daniel Arantes Loverde
2026-09-16 09:23:57 -03:00
parent d067791930
commit 2ba487a6e8
47 changed files with 4264 additions and 113 deletions

View File

@@ -1,25 +1,13 @@
// swift-tools-version: 6.0
import PackageDescription
import Foundation
let isLocalDevelopment = false //FileManager.default.fileExists(atPath: "../LCECryptoKit/PrivateLib/LCECryptoKitBinary")
let enableCryptoBinary = ProcessInfo.processInfo.environment["LCE_ENABLE_CRYPTO_BINARY"] != "0"
let cryptoPackageURL = isLocalDevelopment
? "../LCECryptoKit/PrivateLib/LCECryptoKitBinary"
: "https://7876d8abdb7260a455259d01de49c4022f5da13c@git.loverde.com.br/Loverde-Company-LTDA/LCECryptoKitBinary.git"
let packageDependencies: [Package.Dependency] = enableCryptoBinary
? [
.package(url: cryptoPackageURL, exact: "1.0.4")
]
: []
let targetDependencies: [Target.Dependency] = enableCryptoBinary
? [
.product(name: "LCECryptoKit", package: "lcecryptokitbinary")
]
: []
// LCECryptoKit ships as a prebuilt .xcframework (`Frameworks/LCECryptoKit.xcframework`)
// vendored locally in this repo, no remote package dependency. iOS device + simulator slices
// only; consumers who need macOS/tvOS/watchOS simply don't link the `LCECryptoKit` product.
//
// Sub-SPM rule: `LCEssentials` installs standalone (no sub required). Every sub
// (`LCECryptoKit` here) target-depends on `LCEssentials`, so linking the sub's product always
// pulls `LCEssentials` in too a consumer never has to declare it separately.
let package = Package(
name: "LCEssentials",
@@ -33,14 +21,33 @@ let package = Package(
.library(
name: "LCEssentials",
targets: ["LCEssentials"]),
.library(
name: "LCECryptoKit",
targets: ["LCECryptoKitManager"]),
.library(
name: "LCFeatureControl",
targets: ["LCFeatureControl"]),
],
dependencies: packageDependencies,
targets: [
.target(
name: "LCEssentials",
dependencies: targetDependencies),
name: "LCEssentials"),
.binaryTarget(
name: "LCECryptoKit",
path: "Frameworks/LCECryptoKit.xcframework"),
.target(
name: "LCECryptoKitManager",
dependencies: [
"LCEssentials",
"LCECryptoKit"
]),
.target(
name: "LCFeatureControl",
dependencies: ["LCEssentials"]),
.testTarget(
name: "LCEssentialsTests",
dependencies: ["LCEssentials"]),
.testTarget(
name: "LCFeatureControlTests",
dependencies: ["LCFeatureControl", "LCEssentials"]),
]
)