Skip to content

Commit eaee18d

Browse files
committed
添加SPM支持
1 parent 19e3fe9 commit eaee18d

20 files changed

+134
-68
lines changed

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

AttributedString.xcodeproj/project.pbxproj

+13-17
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
9B267B8B24406B2F002F571E /* WKInterfaceButtonExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B267B8924406B2F002F571E /* WKInterfaceButtonExtension.swift */; };
2727
9B267B8C24406B2F002F571E /* WKInterfaceLabelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B267B8A24406B2F002F571E /* WKInterfaceLabelExtension.swift */; };
2828
9B267B8E24406D71002F571E /* WKInterfaceTextFieldExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B267B8D24406D71002F571E /* WKInterfaceTextFieldExtension.swift */; };
29-
9B267B95244072BE002F571E /* NSShadowExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B267B94244072BE002F571E /* NSShadowExtension.swift */; };
3029
9B267BA424408072002F571E /* AttributedString.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B267B9B24408072002F571E /* AttributedString.framework */; };
3130
9B267BB2244080FC002F571E /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6E894F23823C40009EBEBE /* AttributedString.h */; settings = {ATTRIBUTES = (Public, ); }; };
3231
9B267BB32440811F002F571E /* CGSizeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B6E89AE238275D2009EBEBE /* CGSizeExtension.swift */; };
@@ -54,8 +53,9 @@
5453
9B34BD46243DBEA900932E6C /* Attribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B6E89E02382C301009EBEBE /* Attribute.swift */; };
5554
9B34BD47243DBEA900932E6C /* ParagraphStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B6E89E22382C392009EBEBE /* ParagraphStyle.swift */; };
5655
9B34BD48243DBEA900932E6C /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B6E89E42382C488009EBEBE /* Attachment.swift */; };
57-
9B34BD65243DFACE00932E6C /* NSShadowExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B34BD63243DFAA600932E6C /* NSShadowExtension.swift */; };
5856
9B34BD68243DFCBB00932E6C /* NSTextFieldExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B34BD66243DFC9E00932E6C /* NSTextFieldExtension.swift */; };
57+
9B6854C524971B8B005F301C /* NSShadowExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B6E89DE23828F7C009EBEBE /* NSShadowExtension.swift */; };
58+
9B6854C624971B8C005F301C /* NSShadowExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B6E89DE23828F7C009EBEBE /* NSShadowExtension.swift */; };
5959
9B6E895123823C40009EBEBE /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6E894F23823C40009EBEBE /* AttributedString.h */; settings = {ATTRIBUTES = (Public, ); }; };
6060
9B6E899E23823FFD009EBEBE /* AttributedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B6E899D23823FFD009EBEBE /* AttributedString.swift */; };
6161
9B6E89A223826D8E009EBEBE /* Interpolation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B6E89A123826D8E009EBEBE /* Interpolation.swift */; };
@@ -115,12 +115,10 @@
115115
9B267B8924406B2F002F571E /* WKInterfaceButtonExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKInterfaceButtonExtension.swift; sourceTree = "<group>"; };
116116
9B267B8A24406B2F002F571E /* WKInterfaceLabelExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKInterfaceLabelExtension.swift; sourceTree = "<group>"; };
117117
9B267B8D24406D71002F571E /* WKInterfaceTextFieldExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKInterfaceTextFieldExtension.swift; sourceTree = "<group>"; };
118-
9B267B94244072BE002F571E /* NSShadowExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSShadowExtension.swift; sourceTree = "<group>"; };
119118
9B267B9B24408072002F571E /* AttributedString.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AttributedString.framework; sourceTree = BUILT_PRODUCTS_DIR; };
120119
9B267BA324408072002F571E /* AttributedString-tvOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "AttributedString-tvOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
121120
9B267BBF244081BB002F571E /* AttributedString_tvOS_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedString_tvOS_Tests.swift; sourceTree = "<group>"; };
122121
9B34BD37243DBC8100932E6C /* AttributedString.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AttributedString.framework; sourceTree = BUILT_PRODUCTS_DIR; };
123-
9B34BD63243DFAA600932E6C /* NSShadowExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSShadowExtension.swift; sourceTree = "<group>"; };
124122
9B34BD66243DFC9E00932E6C /* NSTextFieldExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSTextFieldExtension.swift; sourceTree = "<group>"; };
125123
9B6E894C23823C40009EBEBE /* AttributedString.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AttributedString.framework; sourceTree = BUILT_PRODUCTS_DIR; };
126124
9B6E894F23823C40009EBEBE /* AttributedString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; };
@@ -214,7 +212,6 @@
214212
9B267B8924406B2F002F571E /* WKInterfaceButtonExtension.swift */,
215213
9B267B8A24406B2F002F571E /* WKInterfaceLabelExtension.swift */,
216214
9B267B8D24406D71002F571E /* WKInterfaceTextFieldExtension.swift */,
217-
9B267B94244072BE002F571E /* NSShadowExtension.swift */,
218215
);
219216
path = WatchKit;
220217
sourceTree = "<group>";
@@ -267,6 +264,7 @@
267264
9B6E89A42382739C009EBEBE /* UIKit */,
268265
9B0A2A3723851EB6003D8A55 /* Extension.swift */,
269266
9B87659F24850742009C51C2 /* ObjectExtension.swift */,
267+
9B6E89DE23828F7C009EBEBE /* NSShadowExtension.swift */,
270268
);
271269
path = Extension;
272270
sourceTree = "<group>";
@@ -277,7 +275,6 @@
277275
9B6E89A7238273E4009EBEBE /* UITextViewExtension.swift */,
278276
9B6E89A92382742F009EBEBE /* UITextFieldExtension.swift */,
279277
9B6E89AB238274CB009EBEBE /* UILabelExtension.swift */,
280-
9B6E89DE23828F7C009EBEBE /* NSShadowExtension.swift */,
281278
9B0A2A39238524E1003D8A55 /* UIButtonExtension.swift */,
282279
);
283280
path = UIKit;
@@ -286,7 +283,6 @@
286283
9B6E89A5238273B2009EBEBE /* AppKit */ = {
287284
isa = PBXGroup;
288285
children = (
289-
9B34BD63243DFAA600932E6C /* NSShadowExtension.swift */,
290286
9B34BD66243DFC9E00932E6C /* NSTextFieldExtension.swift */,
291287
);
292288
path = AppKit;
@@ -604,13 +600,13 @@
604600
9B267B79244066C1002F571E /* CGPointExtension.swift in Sources */,
605601
9BE7D4C82488E0FC00DE1176 /* Action.swift in Sources */,
606602
9B267B7A244066C1002F571E /* Extension.swift in Sources */,
607-
9B267B95244072BE002F571E /* NSShadowExtension.swift in Sources */,
608603
9B267B8B24406B2F002F571E /* WKInterfaceButtonExtension.swift in Sources */,
609604
9B267B7B244066C1002F571E /* AttributedString.swift in Sources */,
610605
9B267B7C244066C1002F571E /* Interpolation.swift in Sources */,
611606
9B267B7D244066C1002F571E /* Attribute.swift in Sources */,
612607
9B8765A224850742009C51C2 /* ObjectExtension.swift in Sources */,
613608
9B267B7E244066C1002F571E /* ParagraphStyle.swift in Sources */,
609+
9B6854C624971B8C005F301C /* NSShadowExtension.swift in Sources */,
614610
9B267B7F244066C1002F571E /* Attachment.swift in Sources */,
615611
9B267B8E24406D71002F571E /* WKInterfaceTextFieldExtension.swift in Sources */,
616612
);
@@ -652,11 +648,11 @@
652648
buildActionMask = 2147483647;
653649
files = (
654650
9B34BD68243DFCBB00932E6C /* NSTextFieldExtension.swift in Sources */,
655-
9B34BD65243DFACE00932E6C /* NSShadowExtension.swift in Sources */,
656651
9B34BD40243DBEA900932E6C /* CGSizeExtension.swift in Sources */,
657652
9B34BD41243DBEA900932E6C /* CGRectExtension.swift in Sources */,
658653
9B34BD42243DBEA900932E6C /* CGPointExtension.swift in Sources */,
659654
9B34BD43243DBEA900932E6C /* Extension.swift in Sources */,
655+
9B6854C524971B8B005F301C /* NSShadowExtension.swift in Sources */,
660656
9B34BD44243DBEA900932E6C /* AttributedString.swift in Sources */,
661657
9B34BD45243DBEA900932E6C /* Interpolation.swift in Sources */,
662658
9B8765A124850742009C51C2 /* ObjectExtension.swift in Sources */,
@@ -808,7 +804,7 @@
808804
"@executable_path/Frameworks",
809805
"@loader_path/Frameworks",
810806
);
811-
MARKETING_VERSION = 1.3.2;
807+
MARKETING_VERSION = 1.3.3;
812808
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.watchos;
813809
PRODUCT_NAME = AttributedString;
814810
SDKROOT = watchos;
@@ -836,7 +832,7 @@
836832
"@executable_path/Frameworks",
837833
"@loader_path/Frameworks",
838834
);
839-
MARKETING_VERSION = 1.3.2;
835+
MARKETING_VERSION = 1.3.3;
840836
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.watchos;
841837
PRODUCT_NAME = AttributedString;
842838
SDKROOT = watchos;
@@ -863,7 +859,7 @@
863859
"@executable_path/Frameworks",
864860
"@loader_path/Frameworks",
865861
);
866-
MARKETING_VERSION = 1.3.2;
862+
MARKETING_VERSION = 1.3.3;
867863
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.tvos;
868864
PRODUCT_NAME = AttributedString;
869865
SDKROOT = appletvos;
@@ -890,7 +886,7 @@
890886
"@executable_path/Frameworks",
891887
"@loader_path/Frameworks",
892888
);
893-
MARKETING_VERSION = 1.3.2;
889+
MARKETING_VERSION = 1.3.3;
894890
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.tvos;
895891
PRODUCT_NAME = AttributedString;
896892
SDKROOT = appletvos;
@@ -966,7 +962,7 @@
966962
"@loader_path/Frameworks",
967963
);
968964
MACOSX_DEPLOYMENT_TARGET = 10.13;
969-
MARKETING_VERSION = 1.3.2;
965+
MARKETING_VERSION = 1.3.3;
970966
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.macos;
971967
PRODUCT_NAME = AttributedString;
972968
SDKROOT = macosx;
@@ -993,7 +989,7 @@
993989
"@loader_path/Frameworks",
994990
);
995991
MACOSX_DEPLOYMENT_TARGET = 10.13;
996-
MARKETING_VERSION = 1.3.2;
992+
MARKETING_VERSION = 1.3.3;
997993
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.macos;
998994
PRODUCT_NAME = AttributedString;
999995
SDKROOT = macosx;
@@ -1140,7 +1136,7 @@
11401136
"@executable_path/Frameworks",
11411137
"@loader_path/Frameworks",
11421138
);
1143-
MARKETING_VERSION = 1.3.2;
1139+
MARKETING_VERSION = 1.3.3;
11441140
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.ios;
11451141
PRODUCT_NAME = AttributedString;
11461142
SKIP_INSTALL = YES;
@@ -1168,7 +1164,7 @@
11681164
"@executable_path/Frameworks",
11691165
"@loader_path/Frameworks",
11701166
);
1171-
MARKETING_VERSION = 1.3.2;
1167+
MARKETING_VERSION = 1.3.3;
11721168
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.ios;
11731169
PRODUCT_NAME = AttributedString;
11741170
SKIP_INSTALL = YES;

Package.swift

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:5.2
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "AttributedString",
8+
platforms: [.iOS(.v9), .macOS(.v10_13), .tvOS(.v11), .watchOS(.v5)],
9+
products: [
10+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
11+
.library(
12+
name: "AttributedString",
13+
targets: ["AttributedString"]),
14+
],
15+
dependencies: [
16+
// Dependencies declare other packages that this package depends on.
17+
// .package(url: /* package url */, from: "1.0.0"),
18+
],
19+
targets: [
20+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
21+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
22+
.target(
23+
name: "AttributedString",
24+
dependencies: [],
25+
path: "Sources"
26+
)
27+
]
28+
)

README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,31 @@
3737

3838
## Installation
3939

40-
**CocoaPods - Podfile**
40+
#### CocoaPods - Podfile
4141

4242
```ruby
4343
pod 'AttributedString'
4444
```
4545

46-
**Carthage - Cartfile**
46+
#### Carthage - Cartfile
4747

4848
```ruby
4949
github "lixiang1994/AttributedString"
5050
```
5151

52+
#### [Swift Package Manager for Apple platforms](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)
53+
54+
Select Xcode menu `File > Swift Packages > Add Package Dependency` and enter repository URL with GUI.
55+
```
56+
Repository: https://github.com/lixiang1994/AttributedString
57+
```
58+
59+
#### [Swift Package Manager](https://swift.org/package-manager/)
60+
61+
Add the following to the dependencies of your `Package.swift`:
62+
```swift
63+
.package(url: "https://github.com/lixiang1994/AttributedString.git", from: "version")
64+
```
5265

5366

5467
## Usage

README_CN.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,31 @@ AttributedString - 基于Swift插值方式优雅的构建富文本
3737

3838
## 安装
3939

40-
**CocoaPods - Podfile**
40+
#### CocoaPods - Podfile
4141

4242
```ruby
4343
pod 'AttributedString'
4444
```
4545

46-
**Carthage - Cartfile**
46+
#### Carthage - Cartfile
4747

4848
```ruby
4949
github "lixiang1994/AttributedString"
5050
```
5151

52+
#### [Swift Package Manager for Apple platforms](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)
53+
54+
选择 Xcode 菜单 `File > Swift Packages > Add Package Dependency` 输入仓库地址.
55+
```
56+
Repository: https://github.com/lixiang1994/AttributedString
57+
```
58+
59+
#### [Swift Package Manager](https://swift.org/package-manager/)
60+
61+
将以下内容添加到你的 `Package.swift`:
62+
```swift
63+
.package(url: "https://github.com/lixiang1994/AttributedString.git", from: "version")
64+
```
5265

5366

5467
## 使用

Sources/Extension/AppKit/NSShadowExtension.swift

-19
This file was deleted.

Sources/Extension/AppKit/NSTextFieldExtension.swift

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2020 LEE. All rights reserved.
77
//
88

9+
#if os(macOS)
10+
911
import AppKit
1012

1113
private var NSClickGestureRecognizerKey: Void?
@@ -21,14 +23,12 @@ extension AttributedStringWrapper where Base: NSTextField {
2123
set {
2224
base.attributedStringValue = newValue.value
2325

24-
#if os(macOS)
2526
if newValue.value.contains(.action) {
2627
addGestureRecognizers()
2728

2829
} else {
2930
removeGestureRecognizers()
3031
}
31-
#endif
3232
}
3333
}
3434

@@ -37,8 +37,6 @@ extension AttributedStringWrapper where Base: NSTextField {
3737
set { base.placeholderAttributedString = newValue?.value }
3838
}
3939

40-
#if os(macOS)
41-
4240
private func addGestureRecognizers() {
4341
guard click == nil else { return }
4442
let gesture = NSClickGestureRecognizer(target: base, action: #selector(Base.attributedClickAction))
@@ -56,12 +54,8 @@ extension AttributedStringWrapper where Base: NSTextField {
5654
get { base.associated.get(&NSClickGestureRecognizerKey) }
5755
set { base.associated.set(retain: &NSClickGestureRecognizerKey, newValue) }
5856
}
59-
60-
#endif
6157
}
6258

63-
#if os(macOS)
64-
6559
fileprivate extension NSTextField {
6660

6761
typealias Action = AttributedString.Action

Sources/Extension/UIKit/NSShadowExtension.swift renamed to Sources/Extension/NSShadowExtension.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
// Created by Lee on 2019/11/18.
1111
// Copyright © 2019 LEE. All rights reserved.
1212
//
13-
13+
#if os(iOS) || os(tvOS)
1414
import UIKit
15+
#elseif os(macOS)
16+
import AppKit
17+
#elseif os(watchOS)
18+
import WatchKit
19+
#endif
1520

1621
public extension NSShadow {
1722

Sources/Extension/UIKit/UIButtonExtension.swift

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// Copyright © 2019 LEE. All rights reserved.
1212
//
1313

14+
#if os(iOS) || os(tvOS)
15+
1416
import UIKit
1517

1618
extension UIButton: AttributedStringCompatible {
@@ -27,3 +29,5 @@ extension AttributedStringWrapper where Base: UIButton {
2729
AttributedString(base.attributedTitle(for: state))
2830
}
2931
}
32+
33+
#endif

Sources/Extension/UIKit/UILabelExtension.swift

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// Copyright © 2019 LEE. All rights reserved.
1212
//
1313

14+
#if os(iOS) || os(tvOS)
15+
1416
import UIKit
1517

1618
private var UITapGestureRecognizerKey: Void?
@@ -123,3 +125,5 @@ fileprivate extension UILabel {
123125
}
124126

125127
#endif
128+
129+
#endif

0 commit comments

Comments
 (0)