Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/featureflags_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: FeatureFlagsExample

on:
push:
branches: [main]
paths:
- 'FeatureFlags/**'
- 'Example/FeatureFlagsExample/**'
- 'Example/Resources/**'
- 'Example/Project.swift'
- 'Example/Tuist.swift'
- 'Example/Tuist/**'
- 'Example/mise.toml'
- 'Package.swift'
- '.github/actions/build-example/**'
- '.github/workflows/featureflags_example.yml'
pull_request:
branches: [main]
paths:
- 'FeatureFlags/**'
- 'Example/FeatureFlagsExample/**'
- 'Example/Resources/**'
- 'Example/Project.swift'
- 'Example/Tuist.swift'
- 'Example/Tuist/**'
- 'Example/mise.toml'
- 'Package.swift'
- '.github/actions/build-example/**'
- '.github/workflows/featureflags_example.yml'

jobs:
build:
name: Build FeatureFlagsExample (${{ matrix.platform }})
strategy:
fail-fast: false
matrix:
include:
- platform: iOS
destination: "generic/platform=iOS"
- platform: iOS Simulator
destination: "generic/platform=iOS Simulator"
- platform: macOS
destination: "platform=macOS"
runs-on:
- macos-15
- xcode-26.6
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-example
with:
scheme: FeatureFlagsExample
destination: ${{ matrix.destination }}
xcode-version: "26.6"
50 changes: 50 additions & 0 deletions Example/FeatureFlagsExample/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// ContentView.swift
// DarwinPrivateFrameworks

import FeatureFlags
import SwiftUI

private struct GestureContainerKey: FeatureFlagsKey {
var domain: StaticString { "SwiftUI" }

var feature: StaticString { "gestureContainer" }
}

struct ContentView: View {
@State private var isEnabled = FeatureFlags.isFeatureEnabled(GestureContainerKey())

var body: some View {
NavigationStack {
Form {
Section {
LabeledContent("Domain", value: "SwiftUI")
LabeledContent("Feature", value: "gestureContainer")
LabeledContent("Status") {
Label(
isEnabled ? "Enabled" : "Disabled",
systemImage: isEnabled ? "checkmark.circle.fill" : "minus.circle"
)
.foregroundStyle(isEnabled ? .green : .secondary)
}
} footer: {
Text("The result comes from the system feature flag service.")
}
}
.formStyle(.grouped)
.navigationTitle("Feature Flags")
.toolbar {
Button("Refresh", systemImage: "arrow.clockwise") {
isEnabled = FeatureFlags.isFeatureEnabled(GestureContainerKey())
}
}
}
#if os(macOS)
.frame(minWidth: 400, minHeight: 260)
#endif
}
}

#Preview {
ContentView()
}
14 changes: 14 additions & 0 deletions Example/FeatureFlagsExample/ExampleApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// ExampleApp.swift
// DarwinPrivateFrameworks

import SwiftUI

@main
struct ExampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
18 changes: 18 additions & 0 deletions Example/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ let project = Project(
],
settings: .settings(base: baseSettings)
),
// MARK: FeatureFlagsExample
.target(
name: "FeatureFlagsExample",
destinations: [.iPhone, .iPad, .mac],
product: .app,
bundleId: "\(bundleIdPrefix).FeatureFlagsExample",
deploymentTargets: .multiplatform(
iOS: "18.5",
macOS: "15.0"
),
infoPlist: .extendingDefault(with: defaultInfoPlist),
sources: ["FeatureFlagsExample/**"],
resources: sharedResources,
dependencies: [
.external(name: "FeatureFlags"),
],
settings: .settings(base: baseSettings)
),
// MARK: SFSymbolsExample
.target(
name: "SFSymbolsExample",
Expand Down
4 changes: 4 additions & 0 deletions Example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ This generates `Example.xcworkspace` — open it in Xcode to build and run the e
| BLSExample_2024 | BacklightServices | iOS, visionOS |
| SFSymbolsExample_2024 | SFSymbols | iOS, macOS |
| GFExample_2025 | Gestures | iOS, macOS |
| FeatureFlagsExample | FeatureFlags | iOS, macOS |

`FeatureFlagsExample` queries the system `SwiftUI.gestureContainer` flag and
displays its enabled state. Use Refresh to query the flag again.

## Regenerating

Expand Down
2 changes: 1 addition & 1 deletion Example/Tuist/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions FeatureFlags/2024/FeatureFlags.xcframework/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>LibraryIdentifier</key>
<string>macos-arm64e-arm64-x86_64</string>
<key>LibraryPath</key>
<string>FeatureFlags.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64e</string>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64-arm64e</string>
<key>LibraryPath</key>
<string>FeatureFlags.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>arm64e</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64-x86_64-simulator</string>
<key>LibraryPath</key>
<string>FeatureFlags.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"main_library": {
"current_versions": [
{
"version": "97"
}
],
"exported_symbols": [
{
"data": {
"global": [
"_$s12FeatureFlags02isA7EnabledySbAA0aB3Key_pF",
"_$s12FeatureFlags0aB3KeyMp",
"_$s12FeatureFlags0aB3KeyP6domains12StaticStringVvgTj",
"_$s12FeatureFlags0aB3KeyP6domains12StaticStringVvgTq",
"_$s12FeatureFlags0aB3KeyP7features12StaticStringVvgTj",
"_$s12FeatureFlags0aB3KeyP7features12StaticStringVvgTq",
"_$s12FeatureFlags0aB3KeyTL"
]
}
}
],
"install_names": [
{
"name": "/System/Library/PrivateFrameworks/FeatureFlags.framework/FeatureFlags"
}
],
"swift_abi": [
{
"abi": 7
}
],
"target_info": [
{
"min_deployment": "18.0",
"target": "arm64-ios"
},
{
"min_deployment": "18.0",
"target": "arm64e-ios"
}
]
},
"tapi_tbd_version": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>FeatureFlags</string>
<key>CFBundleIdentifier</key>
<string>com.apple.FeatureFlags</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.1
// swift-module-flags: -target arm64-apple-ios18.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -module-name FeatureFlags
public import Swift

public protocol FeatureFlagsKey {
var domain: Swift.StaticString { get }
var feature: Swift.StaticString { get }
}

public func isFeatureEnabled(_ key: any FeatureFlags.FeatureFlagsKey) -> Swift.Bool
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.1
// swift-module-flags: -target arm64e-apple-ios18.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -module-name FeatureFlags
public import Swift

public protocol FeatureFlagsKey {
var domain: Swift.StaticString { get }
var feature: Swift.StaticString { get }
}

public func isFeatureEnabled(_ key: any FeatureFlags.FeatureFlagsKey) -> Swift.Bool
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"main_library": {
"current_versions": [
{
"version": "97"
}
],
"exported_symbols": [
{
"data": {
"global": [
"_$s12FeatureFlags02isA7EnabledySbAA0aB3Key_pF",
"_$s12FeatureFlags0aB3KeyMp",
"_$s12FeatureFlags0aB3KeyP6domains12StaticStringVvgTj",
"_$s12FeatureFlags0aB3KeyP6domains12StaticStringVvgTq",
"_$s12FeatureFlags0aB3KeyP7features12StaticStringVvgTj",
"_$s12FeatureFlags0aB3KeyP7features12StaticStringVvgTq",
"_$s12FeatureFlags0aB3KeyTL"
]
}
}
],
"install_names": [
{
"name": "/System/Library/PrivateFrameworks/FeatureFlags.framework/FeatureFlags"
}
],
"swift_abi": [
{
"abi": 7
}
],
"target_info": [
{
"min_deployment": "18.5",
"target": "x86_64-ios-simulator"
},
{
"min_deployment": "18.5",
"target": "arm64-ios-simulator"
}
]
},
"tapi_tbd_version": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>FeatureFlags</string>
<key>CFBundleIdentifier</key>
<string>com.apple.FeatureFlags</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.1
// swift-module-flags: -target arm64-apple-ios18.5-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -module-name FeatureFlags
public import Swift

public protocol FeatureFlagsKey {
var domain: Swift.StaticString { get }
var feature: Swift.StaticString { get }
}

public func isFeatureEnabled(_ key: any FeatureFlags.FeatureFlagsKey) -> Swift.Bool
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.1
// swift-module-flags: -target x86_64-apple-ios18.5-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -module-name FeatureFlags
public import Swift

public protocol FeatureFlagsKey {
var domain: Swift.StaticString { get }
var feature: Swift.StaticString { get }
}

public func isFeatureEnabled(_ key: any FeatureFlags.FeatureFlagsKey) -> Swift.Bool
Loading
Loading