Kyle-Ye/ScreenShieldKit
关于
A Swift framework to hide UIView/NSView/CALayer and SwiftUI views on iOS 18 and newer from being captured when taking screenshots.
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文ScreenShieldKit
A Swift framework to hide UIView/NSView/CALayer, and SwiftUI views on iOS 18 and newer, from being captured when taking screenshots.
Overview
| Coverage | Workflow | Matrix | Status |
|---|---|---|---|
| Package public API | package.yml |
iOS 18.5 with Xcode 16.4 & iOS 26.2 with Xcode 26.3 | |
| Package public API with SPI interfaces | package_interface.yml |
iOS 18.5 with Xcode 16.4 & iOS 26.2 with Xcode 26.3 | |
| UIKit example UI tests | example_uikit.yml |
iOS 18.5 with Xcode 16.4 & iOS 26.2 with Xcode 26.3 | |
| SwiftUI example UI tests | example_swiftui.yml |
iOS 18.5 with Xcode 16.4 & iOS 26.2 with Xcode 26.3 | |
| OpenSwiftUI example UI tests | example_openswiftui.yml |
iOS 18.5 with Xcode 16.4 & iOS 26.2 with Xcode 26.3 |

Getting Started
In your Package.swift file, add the following dependency to your dependencies argument:
.package(url: "https://github.com/Kyle-Ye/ScreenShieldKit.git", from: "0.2.0"),
Then add the dependency to any targets you've declared in your manifest:
.target(
name: "MyTarget",
dependencies: [
.product(name: "ScreenShieldKit", package: "ScreenShieldKit"),
]
),
Usage
Instead of wrapping your view in a secure UITextField or ScreenShieldView,
you can just directly call the hiddenFromCapture(_:) API on your view or layer.
UIKit
import ScreenShieldKit
let view = UIView(frame: .zero)
view.hiddenFromCapture(true)
// Restore the behavior
view.hiddenFromCapture(false)
SwiftUI
For SwiftUI on iOS 18, macOS 15, tvOS 18, watchOS 11, and visionOS 2 or newer:
import ScreenShieldKit
import SwiftUI
Text("Sensitive content")
.hiddenFromCapture()
OpenSwiftUI
For OpenSwiftUI, enable the package trait. The dependency uses the OpenSwiftUI-spm binary package from version 0.18.1.
swift build --traits OpenSwiftUI
import OpenSwiftUI
import ScreenShieldKit
Text("Sensitive content")
.hiddenFromCapture()
AppKit
AppKit support is best-effort. The current implementation uses the same private
layer update mask path as UIKit, but that has been observed not to hide NSView
contents from macOS system captures reliably.
SPI Interfaces
To build against the local SPI interface shims instead of ScreenShieldKit's
fallback declarations, set SCREENSHIELDKIT_USE_SPI_INTERFACES=1 before
building.
SCREENSHIELDKIT_USE_SPI_INTERFACES=1 swift build
Examples
The example apps are managed by Tuist:
cd Example
mise trust --yes
mise install
mise exec -- tuist install
mise exec -- tuist generate --no-open
Available schemes:
UIKitExample: UIKit demo and the target app for UI tests.AppKitExample: macOS AppKit demo.SwiftUIExample: SwiftUI demo for iOS and macOS.OpenSwiftUIExample: OpenSwiftUI demo for iOS and macOS.
Detailed documentation for ScreenShieldKit can be found on GitHub Pages. Release-to-release API changes are available on the API Changes page.
License
See LICENSE file - MIT
Acknowledgements
- @NSAntoine for the CALayer capture hiding write-up: https://nsantoine.dev/posts/CALayerCaptureHiding
- @Kyle-Ye for the SwiftUI capture hiding notes: https://kyleye.top/posts/swiftui-hidden-from-capture
探索相关项目
加载中…