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
15 changes: 13 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
included:
- Sources

# SwiftLint analyze 的 unused_import 对系统框架 import(Foundation/UIKit/Security 等)存在已知误报:
# swiftc 编译日志 0 条 unused import 警告,删除这些 import 会导致编译失败
# (如 STSecurityModels 依赖 Foundation 的 Date/TimeInterval,见 .github/workflows/swift.yml 的 Analyze 步骤)。
# 该规则已整体禁用(见下方 analyzer_rules),故无需在此按文件排除。
excluded:
- Sources/STMarkdown/Resources
- .build
Expand Down Expand Up @@ -67,8 +71,15 @@ opt_in_rules:
force_cast: error # as! 直接 error

analyzer_rules:
- unused_import
- unused_declaration
# 本仓库是底层公用库:大量 public/internal/fileprivate API 提供给宿主 App / Example 模块调用,
# SwiftLint analyze 的 analyzer_rules 只扫描包内 99 个文件,看不到外部调用方,
# 会系统性误报 unused_import 与 unused_declaration(且 swiftc 编译日志证明 import 必需)。
# 验证依据见下。故整体禁用这两个 analyzer 规则。
# - unused_import : 系统框架 import(Foundation/UIKit/Security 等)被误判为冗余,
# clean build 的 swiftc 编译日志 unused import 警告为 0 条,删除会导致编译失败。
# - unused_declaration: 对外暴露的库 API 在包内无引用,被误判为未使用。
# - unused_import
# - unused_declaration

# 公开 API 文档缺失检查:存量 882 个未清零,暂移出 opt_in_rules(见 disabled_rules),
# 待文档补齐专项后再恢复并重新纳入 --strict 门槛。仅检查 public 级别。
Expand Down
2 changes: 1 addition & 1 deletion Sources/STBaseView/STBaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ open class STBaseView: UIView {
guard self.layoutMode == .scroll else { return }
guard appearing || self.baseContentInset != nil else { return }
guard let userInfo = note.userInfo, self.enableScrollViewKeyboardAdjustment else {
if !appearing, let baseContent = self.baseContentInset {
if !appearing, self.baseContentInset != nil {
// 键盘调整被关闭,但仍需还原已注入的 inset。
self.restoreBaseInsets()
}
Expand Down
22 changes: 6 additions & 16 deletions Sources/STConfig/STOrientationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,13 @@ public final class STOrientationManager {
}

private func requestGeometryUpdate(_ orientations: UIInterfaceOrientationMask, in windowScene: UIWindowScene?) {
let targetWindowScene = windowScene ?? self.activeWindowScene()
if #available(iOS 16.0, *), let targetWindowScene {
targetWindowScene.requestGeometryUpdate(.iOS(interfaceOrientations: orientations)) { error in
STLog("[STOrientationManager] requestGeometryUpdate failed: \(error.localizedDescription)")
}
} else {
UIDevice.current.setValue(self.preferredOrientation(for: orientations).rawValue, forKey: "orientation")
guard let targetWindowScene = windowScene ?? self.activeWindowScene() else {
STLog("[STOrientationManager] No active UIWindowScene found; cannot request geometry update.")
return
}
targetWindowScene.requestGeometryUpdate(.iOS(interfaceOrientations: orientations)) { error in
STLog("[STOrientationManager] requestGeometryUpdate failed: \(error.localizedDescription)")
}
UIViewController.attemptRotationToDeviceOrientation()
}

private func preferredOrientation(for orientations: UIInterfaceOrientationMask) -> UIInterfaceOrientation {
if orientations.contains(.portrait) { return .portrait }
if orientations.contains(.landscapeLeft) { return .landscapeLeft }
if orientations.contains(.landscapeRight) { return .landscapeRight }
if orientations.contains(.portraitUpsideDown) { return .portraitUpsideDown }
return .portrait
}

private func activeWindowScene() -> UIWindowScene? {
Expand Down
10 changes: 5 additions & 5 deletions Sources/STHUD/STAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private enum STAlertLayoutConstant {
static let titleMessageSpacing: CGFloat = 10
}

public enum STAlertBtnClickType {
public enum STAlertBtnClickType: String {
case btnClick
case leftBtnClick
case rightBtnClick
Expand Down Expand Up @@ -300,7 +300,7 @@ open class STAlertController: UIViewController {
handler(true, sender.titleLabel?.text ?? "")
}
} else {
if let type = sender.identifier as? STAlertBtnClickType, type == .leftBtnClick {
if sender.stringIdentifier == STAlertBtnClickType.leftBtnClick.rawValue {
if let handler = self.alertInfo.buttonHandlers.first {
handler(true, sender.titleLabel?.text ?? "")
}
Expand Down Expand Up @@ -335,7 +335,7 @@ open class STAlertController: UIViewController {
}()
let btn = self.createBtn(action: singleAction)
btn.tag = 0
btn.identifier = STAlertBtnClickType.btnClick
btn.stringIdentifier = STAlertBtnClickType.btnClick.rawValue
btn.addTarget(self, action: #selector(alertButtonClick), for: .touchUpInside)
self.alertView.addSubview(btn)
self.view.addConstraints([
Expand Down Expand Up @@ -370,7 +370,7 @@ open class STAlertController: UIViewController {
}()
let leftBtn = self.createBtn(action: leftAction)
leftBtn.tag = 0
leftBtn.identifier = STAlertBtnClickType.leftBtnClick
leftBtn.stringIdentifier = STAlertBtnClickType.leftBtnClick.rawValue
leftBtn.addTarget(self, action: #selector(alertButtonClick), for: .touchUpInside)
self.alertView.addSubview(leftBtn)

Expand All @@ -390,7 +390,7 @@ open class STAlertController: UIViewController {
}()
let rightBtn = self.createBtn(action: rightAction)
rightBtn.tag = 1
rightBtn.identifier = STAlertBtnClickType.rightBtnClick
rightBtn.stringIdentifier = STAlertBtnClickType.rightBtnClick.rawValue
rightBtn.addTarget(self, action: #selector(alertButtonClick), for: .touchUpInside)
self.alertView.addSubview(rightBtn)
self.view.addConstraints([
Expand Down
Loading