Skip to content

Commit

Permalink
Merge pull request #36 from cybozu/end-of-support-ios14
Browse files Browse the repository at this point in the history
End to support iOS 14
  • Loading branch information
Kyome22 authored Jul 5, 2024
2 parents 8749050 + 5b44dd0 commit 90778d3
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 130 deletions.
8 changes: 5 additions & 3 deletions LicenseDemo/LicenseDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1330;
LastUpgradeCheck = 1330;
LastUpgradeCheck = 1540;
TargetAttributes = {
18E61A6E2872A66800C5A710 = {
CreatedOnToolsVersion = 13.3.1;
Expand Down Expand Up @@ -326,6 +326,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -340,7 +341,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -386,6 +387,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -394,7 +396,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "LicenseList",
platforms: [
.iOS(.v14)
.iOS(.v15)
],
products: [
.library(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Generate a list of licenses for the Swift Package libraries that your app depend

- Development with Xcode 15.2+
- Written in Swift 5.9
- Compatible with iOS 14.0+
- Compatible with iOS 15.0+

## Privacy Manifest

Expand Down
11 changes: 0 additions & 11 deletions Sources/LicenseList/LegacyLicenseSentence.swift

This file was deleted.

69 changes: 0 additions & 69 deletions Sources/LicenseList/LegacyLicenseView.swift

This file was deleted.

26 changes: 6 additions & 20 deletions Sources/LicenseList/LicenseListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,15 @@ public struct LicenseListView: View {
.foregroundColor(Color(.systemGray3))
}
} else {
libraryNavigationLink(library)
NavigationLink {
LicenseView(library: library)
.licenseListViewStyle(licenseListViewStyle)
} label: {
Text(library.name)
}
}
}
}
.listStyle(.insetGrouped)
}

@ViewBuilder
func libraryNavigationLink(_ library: Library) -> some View {
if #available(iOS 15, *) {
NavigationLink {
LicenseView(library: library)
.licenseListViewStyle(licenseListViewStyle)
} label: {
Text(library.name)
}
} else {
NavigationLink {
LegacyLicenseView(library: library)
.licenseListViewStyle(licenseListViewStyle)
} label: {
Text(library.name)
}
}
}
}
12 changes: 3 additions & 9 deletions Sources/LicenseList/LicenseListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ public class LicenseListViewController: UIViewController {
}

private func navigateTo(library: Library) {
let hostingController = UIHostingController(rootView: Group {
if #available(iOS 15, *) {
LicenseView(library: library)
.licenseListViewStyle(licenseListViewStyle)
} else {
LegacyLicenseView(library: library)
.licenseListViewStyle(licenseListViewStyle)
}
})
let hostingController = UIHostingController(
rootView: LicenseView(library: library).licenseListViewStyle(licenseListViewStyle)
)
hostingController.title = library.name
self.navigationController?.pushViewController(hostingController, animated: true)
}
Expand Down
1 change: 0 additions & 1 deletion Sources/LicenseList/LicenseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI

@available(iOS 15, *)
public struct LicenseView: View {
@State private var attributedLicenseBody = AttributedString(stringLiteral: "")

Expand Down
15 changes: 0 additions & 15 deletions Sources/LicenseList/String+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,15 @@
import Foundation

extension StringProtocol {
// For LicenseView
func match(_ pattern: String) -> [Range<Index>] {
if let range = self.range(of: pattern, options: .regularExpression) {
return [range] + self[range.upperBound...].match(pattern)
}
return []
}

// For LegacyLicenseView
func split(_ pattern: String) -> [LegacyLicenseSentence] {
if let range = self.range(of: pattern, options: .regularExpression) {
let res: [LegacyLicenseSentence] = [
LegacyLicenseSentence(isHyperLink: false, body: String(self[..<range.lowerBound])),
LegacyLicenseSentence(isHyperLink: true, body: String(self[range])),
] + self[range.upperBound...].split(pattern)
return res.compactMap { $0.body.isEmpty ? nil : $0 }
}
return [LegacyLicenseSentence(isHyperLink: false, body: String(self))]
}
}

@available(iOS 15, *)
extension AttributedStringProtocol {
// For LicenseView
func match(_ pattern: String) -> [Range<AttributedString.Index>] {
if let range = self.range(of: pattern, options: .regularExpression) {
return [range] + self[range.upperBound...].match(pattern)
Expand Down

0 comments on commit 90778d3

Please sign in to comment.