From 65eebfd502201fdf6181f631655c2920c2a41e07 Mon Sep 17 00:00:00 2001 From: Sam Bae Date: Tue, 4 Oct 2022 20:47:12 -0400 Subject: [PATCH] Add spm support (#16) * Add spm support * Update podspec * Add missing imports --- .../contents.xcworkspacedata | 7 ++++++ Package.swift | 24 +++++++++++++++++++ .../StyledText/Classes}/.gitkeep | 0 .../Classes/DynamicTypeController.swift | 6 ++++- .../StyledText}/Classes/StyledButton.swift | 4 ++++ .../StyledText}/Classes/StyledLabel.swift | 4 ++++ .../StyledText}/Classes/StyledText.swift | 4 ++++ .../StyledText}/Classes/StyledTextView.swift | 4 ++++ .../StyledText}/Classes/TextStyle.swift | 6 ++++- .../StyledText}/Classes/WeakArray.swift | 0 StyledText.podspec | 8 +++---- StyledText/Classes/.gitkeep | 0 12 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata create mode 100644 Package.swift rename {StyledText/Assets => Sources/StyledText/Classes}/.gitkeep (100%) rename {StyledText => Sources/StyledText}/Classes/DynamicTypeController.swift (98%) rename {StyledText => Sources/StyledText}/Classes/StyledButton.swift (99%) rename {StyledText => Sources/StyledText}/Classes/StyledLabel.swift (97%) rename {StyledText => Sources/StyledText}/Classes/StyledText.swift (98%) rename {StyledText => Sources/StyledText}/Classes/StyledTextView.swift (97%) rename {StyledText => Sources/StyledText}/Classes/TextStyle.swift (99%) rename {StyledText => Sources/StyledText}/Classes/WeakArray.swift (100%) delete mode 100644 StyledText/Classes/.gitkeep diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..f454215 --- /dev/null +++ b/Package.swift @@ -0,0 +1,24 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "StyledText", + platforms: [ + .iOS(.v12) + ], + products: [ + .library( + name: "StyledText", + targets: ["StyledText"]) + ], + dependencies: [], + targets: [ + .target( + name: "StyledText", + dependencies: [], + path: "Sources") + ], + swiftLanguageVersions: [.v5] +) diff --git a/StyledText/Assets/.gitkeep b/Sources/StyledText/Classes/.gitkeep similarity index 100% rename from StyledText/Assets/.gitkeep rename to Sources/StyledText/Classes/.gitkeep diff --git a/StyledText/Classes/DynamicTypeController.swift b/Sources/StyledText/Classes/DynamicTypeController.swift similarity index 98% rename from StyledText/Classes/DynamicTypeController.swift rename to Sources/StyledText/Classes/DynamicTypeController.swift index 7424eae..5e7bc61 100644 --- a/StyledText/Classes/DynamicTypeController.swift +++ b/Sources/StyledText/Classes/DynamicTypeController.swift @@ -1,6 +1,8 @@ +#if canImport(UIKit) + import UIKit -public protocol DynamicTypeControllerDelegate: class { +public protocol DynamicTypeControllerDelegate: AnyObject { func preferredContentSizeCategoryDidUpdate(controller: DynamicTypeController, newCategory: UIContentSizeCategory) } @@ -114,3 +116,5 @@ private extension UIContentSizeCategory { } } } + +#endif diff --git a/StyledText/Classes/StyledButton.swift b/Sources/StyledText/Classes/StyledButton.swift similarity index 99% rename from StyledText/Classes/StyledButton.swift rename to Sources/StyledText/Classes/StyledButton.swift index 4c755e5..f0bf2ab 100644 --- a/StyledText/Classes/StyledButton.swift +++ b/Sources/StyledText/Classes/StyledButton.swift @@ -1,3 +1,5 @@ +#if canImport(UIKit) + import UIKit open class StyledButton: UIButton { @@ -81,3 +83,5 @@ open class StyledButton: UIButton { updateStyles() } } + +#endif diff --git a/StyledText/Classes/StyledLabel.swift b/Sources/StyledText/Classes/StyledLabel.swift similarity index 97% rename from StyledText/Classes/StyledLabel.swift rename to Sources/StyledText/Classes/StyledLabel.swift index 9a02690..ffe5210 100644 --- a/StyledText/Classes/StyledLabel.swift +++ b/Sources/StyledText/Classes/StyledLabel.swift @@ -1,3 +1,5 @@ +#if canImport(UIKit) + import UIKit public class StyledLabel: UILabel { @@ -44,3 +46,5 @@ public class StyledLabel: UILabel { super.attributedText = styledText.styledAttributedStringValue } } + +#endif diff --git a/StyledText/Classes/StyledText.swift b/Sources/StyledText/Classes/StyledText.swift similarity index 98% rename from StyledText/Classes/StyledText.swift rename to Sources/StyledText/Classes/StyledText.swift index fb70571..b428cf7 100644 --- a/StyledText/Classes/StyledText.swift +++ b/Sources/StyledText/Classes/StyledText.swift @@ -1,3 +1,5 @@ +#if canImport(UIKit) + import Foundation public protocol StyledText { @@ -48,3 +50,5 @@ public struct StyledAttributedString: StyledText { return mutableString } } + +#endif diff --git a/StyledText/Classes/StyledTextView.swift b/Sources/StyledText/Classes/StyledTextView.swift similarity index 97% rename from StyledText/Classes/StyledTextView.swift rename to Sources/StyledText/Classes/StyledTextView.swift index c1189ce..f3e2f41 100644 --- a/StyledText/Classes/StyledTextView.swift +++ b/Sources/StyledText/Classes/StyledTextView.swift @@ -1,3 +1,5 @@ +#if canImport(UIKit) + import UIKit open class StyledTextView: UITextView { @@ -44,3 +46,5 @@ open class StyledTextView: UITextView { super.attributedText = styledText.styledAttributedStringValue } } + +#endif diff --git a/StyledText/Classes/TextStyle.swift b/Sources/StyledText/Classes/TextStyle.swift similarity index 99% rename from StyledText/Classes/TextStyle.swift rename to Sources/StyledText/Classes/TextStyle.swift index 037507e..e54a6c5 100644 --- a/StyledText/Classes/TextStyle.swift +++ b/Sources/StyledText/Classes/TextStyle.swift @@ -1,4 +1,6 @@ -import Foundation +#if canImport(UIKit) + +import UIKit public protocol TextStyleDefaultsGenerator { static func defaultKern(for font: UIFont) -> CGFloat? @@ -133,3 +135,5 @@ public struct TextStyle { dynamicTypeBehavior: dynamicTypeBehavior) } } + +#endif diff --git a/StyledText/Classes/WeakArray.swift b/Sources/StyledText/Classes/WeakArray.swift similarity index 100% rename from StyledText/Classes/WeakArray.swift rename to Sources/StyledText/Classes/WeakArray.swift diff --git a/StyledText.podspec b/StyledText.podspec index 8851a04..8a4053e 100644 --- a/StyledText.podspec +++ b/StyledText.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'StyledText' - s.version = '1.3.0' + s.version = '1.4.0' s.summary = 'Declarative text styles and simple Dynamic Type support for iOS' s.description = <<-DESC StyledText is a library that simplifies styling dynamic text in iOS applications. Instead of having to use attributed strings every time you need to update text, you can declaratively set a text style on your labels. When the text of the label is updated, the label uses the preset style. @@ -9,8 +9,8 @@ Pod::Spec.new do |s| s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'huebnerob' => 'robert.huebner@blueapron.com' } s.source = { :git => 'https://github.com/blueapron/styled-text.git', :tag => 'v' + s.version.to_s } - s.ios.deployment_target = '10.0' - s.swift_version = '5.0' - s.source_files = 'StyledText/Classes/**/*' + s.ios.deployment_target = '12.0' + s.swift_version = '5.7' + s.source_files = 'Sources/StyledText/Classes/**/*' s.frameworks = 'UIKit' end diff --git a/StyledText/Classes/.gitkeep b/StyledText/Classes/.gitkeep deleted file mode 100644 index e69de29..0000000