Skip to content

Commit d5b7a58

Browse files
committed
修改类名AttributedString为ASAttributedString, 解决与Xcode13中Foundation.AttributedString类名冲突问题.
1 parent a23728c commit d5b7a58

33 files changed

+362
-317
lines changed

AttributedString.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "AttributedString"
4-
s.version = "1.6.9"
4+
s.version = "2.0.0"
55
s.summary = "基于Swift字符串插值快速构建你想要的富文本, 支持点击按住等事件获取, 支持多种类型过滤"
66

77
s.homepage = "https://github.com/lixiang1994/AttributedString"

AttributedString.xcodeproj/project.pbxproj

+8-8
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@
838838
"@executable_path/Frameworks",
839839
"@loader_path/Frameworks",
840840
);
841-
MARKETING_VERSION = 1.6.8;
841+
MARKETING_VERSION = 2.0.0;
842842
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.watchos;
843843
PRODUCT_NAME = AttributedString;
844844
SDKROOT = watchos;
@@ -866,7 +866,7 @@
866866
"@executable_path/Frameworks",
867867
"@loader_path/Frameworks",
868868
);
869-
MARKETING_VERSION = 1.6.8;
869+
MARKETING_VERSION = 2.0.0;
870870
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.watchos;
871871
PRODUCT_NAME = AttributedString;
872872
SDKROOT = watchos;
@@ -893,7 +893,7 @@
893893
"@executable_path/Frameworks",
894894
"@loader_path/Frameworks",
895895
);
896-
MARKETING_VERSION = 1.6.8;
896+
MARKETING_VERSION = 2.0.0;
897897
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.tvos;
898898
PRODUCT_NAME = AttributedString;
899899
SDKROOT = appletvos;
@@ -920,7 +920,7 @@
920920
"@executable_path/Frameworks",
921921
"@loader_path/Frameworks",
922922
);
923-
MARKETING_VERSION = 1.6.8;
923+
MARKETING_VERSION = 2.0.0;
924924
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.tvos;
925925
PRODUCT_NAME = AttributedString;
926926
SDKROOT = appletvos;
@@ -996,7 +996,7 @@
996996
"@loader_path/Frameworks",
997997
);
998998
MACOSX_DEPLOYMENT_TARGET = 10.13;
999-
MARKETING_VERSION = 1.6.8;
999+
MARKETING_VERSION = 2.0.0;
10001000
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.macos;
10011001
PRODUCT_NAME = AttributedString;
10021002
SDKROOT = macosx;
@@ -1023,7 +1023,7 @@
10231023
"@loader_path/Frameworks",
10241024
);
10251025
MACOSX_DEPLOYMENT_TARGET = 10.13;
1026-
MARKETING_VERSION = 1.6.8;
1026+
MARKETING_VERSION = 2.0.0;
10271027
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.macos;
10281028
PRODUCT_NAME = AttributedString;
10291029
SDKROOT = macosx;
@@ -1170,7 +1170,7 @@
11701170
"@executable_path/Frameworks",
11711171
"@loader_path/Frameworks",
11721172
);
1173-
MARKETING_VERSION = 1.6.8;
1173+
MARKETING_VERSION = 2.0.0;
11741174
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.ios;
11751175
PRODUCT_NAME = AttributedString;
11761176
SKIP_INSTALL = YES;
@@ -1199,7 +1199,7 @@
11991199
"@executable_path/Frameworks",
12001200
"@loader_path/Frameworks",
12011201
);
1202-
MARKETING_VERSION = 1.6.8;
1202+
MARKETING_VERSION = 2.0.0;
12031203
PRODUCT_BUNDLE_IDENTIFIER = com.lee.attributedstring.ios;
12041204
PRODUCT_NAME = AttributedString;
12051205
SKIP_INSTALL = YES;

Demo-Mac/Demo-Mac/AllViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extension AllViewController {
5454

5555
struct Item {
5656
let title: (String, String)
57-
let content: AttributedString
57+
let content: ASAttributedString
5858
let code: String
5959
}
6060

@@ -899,7 +899,7 @@ extension AllViewController {
899899
tableView.selectRowIndexes(.init(integer: 0), byExtendingSelection: true)
900900
}
901901

902-
func clicked(_ result: AttributedString.Action.Result) {
902+
func clicked(_ result: ASAttributedString.Action.Result) {
903903
switch result.content {
904904
case .string(let value):
905905
print("点击了文本: \n\(value) \nrange: \(result.range)")
@@ -909,7 +909,7 @@ extension AllViewController {
909909
}
910910
}
911911

912-
func pressed(_ result: AttributedString.Action.Result) {
912+
func pressed(_ result: ASAttributedString.Action.Result) {
913913
switch result.content {
914914
case .string(let value):
915915
print("按住了文本: \n\(value) \nrange: \(result.range)")

Demo-Mac/Demo-Mac/ViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ViewController: NSViewController {
4747
/// , .paragraph(.alignment(.center)))
4848
/// """
4949

50-
let array: [AttributedString] = [
50+
let array: [ASAttributedString] = [
5151
.init(
5252
"""
5353
\(.image(#imageLiteral(resourceName: "swift-icon"), .custom(size: .init(width: 64, height: 64))))
@@ -129,7 +129,7 @@ class ViewController: NSViewController {
129129
"""
130130
]
131131

132-
let string = array.reduce(into: AttributedString(stringLiteral: "")) {
132+
let string = array.reduce(into: ASAttributedString(stringLiteral: "")) {
133133
$0 += $1 + "\n"
134134
}
135135
label.attributed.string = string

Demo-TV/Demo-TV/AllDetailViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AllDetailViewController: UIViewController {
2424

2525
func set(item: Item) {
2626
list = [
27-
AttributedString(item.content, .font(.systemFont(ofSize: 38))).value,
27+
ASAttributedString(item.content, .font(.systemFont(ofSize: 38))).value,
2828
.init(string: item.code)
2929
]
3030

Demo-TV/Demo-TV/AllTableViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extension AllTableViewController {
5757

5858
struct Item {
5959
let title: (String, String)
60-
let content: AttributedString
60+
let content: ASAttributedString
6161
let code: String
6262
}
6363

Demo-TV/Demo-TV/ViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ViewController: UIViewController {
4949
/// """
5050

5151

52-
let array: [AttributedString] = [
52+
let array: [ASAttributedString] = [
5353
.init(
5454
"""
5555
\(.image(#imageLiteral(resourceName: "swift-icon"), .custom(size: .init(width: 64, height: 64))))
@@ -183,10 +183,10 @@ extension ViewController: UITableViewDataSource {
183183
extension ViewController {
184184

185185
struct Model {
186-
let content: AttributedString
186+
let content: ASAttributedString
187187
let height: CGFloat
188188

189-
init(_ content: AttributedString) {
189+
init(_ content: ASAttributedString) {
190190
self.content = content
191191
self.height = content.value.boundingRect(
192192
with: .init(

Demo-Watch/Demo-Watch WatchKit Extension/InterfaceController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class InterfaceController: WKInterfaceController {
1616
override func awake(withContext context: Any?) {
1717
super.awake(withContext: context)
1818

19-
let array: [AttributedString] = [
19+
let array: [ASAttributedString] = [
2020
.init(
2121
"""
2222
\("Swift", .font(.systemFont(ofSize: 48, weight: .semibold)))
@@ -96,7 +96,7 @@ class InterfaceController: WKInterfaceController {
9696
"""
9797
]
9898

99-
let string = array.reduce(into: AttributedString(stringLiteral: "")) {
99+
let string = array.reduce(into: ASAttributedString(stringLiteral: "")) {
100100
$0 += $1 + "\n"
101101
}
102102

Demo-Watch/Demo-Watch.xcodeproj/project.pbxproj

+41
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
9B267B6324405CFD002F571E /* InterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B267B6224405CFD002F571E /* InterfaceController.swift */; };
1515
9B267B6524405CFD002F571E /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B267B6424405CFD002F571E /* ExtensionDelegate.swift */; };
1616
9B267B6724405CFD002F571E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9B267B6624405CFD002F571E /* Assets.xcassets */; };
17+
9B2E319D26A0312000BA33A8 /* AttributedString.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B2E319C26A0312000BA33A8 /* AttributedString.framework */; };
18+
9B2E319E26A0312000BA33A8 /* AttributedString.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9B2E319C26A0312000BA33A8 /* AttributedString.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1719
/* End PBXBuildFile section */
1820

1921
/* Begin PBXContainerItemProxy section */
@@ -56,6 +58,17 @@
5658
name = "Embed Watch Content";
5759
runOnlyForDeploymentPostprocessing = 0;
5860
};
61+
9B2E319F26A0312000BA33A8 /* Embed Frameworks */ = {
62+
isa = PBXCopyFilesBuildPhase;
63+
buildActionMask = 2147483647;
64+
dstPath = "";
65+
dstSubfolderSpec = 10;
66+
files = (
67+
9B2E319E26A0312000BA33A8 /* AttributedString.framework in Embed Frameworks */,
68+
);
69+
name = "Embed Frameworks";
70+
runOnlyForDeploymentPostprocessing = 0;
71+
};
5972
/* End PBXCopyFilesBuildPhase section */
6073

6174
/* Begin PBXFileReference section */
@@ -69,6 +82,7 @@
6982
9B267B6424405CFD002F571E /* ExtensionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionDelegate.swift; sourceTree = "<group>"; };
7083
9B267B6624405CFD002F571E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7184
9B267B6824405CFD002F571E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
85+
9B2E319C26A0312000BA33A8 /* AttributedString.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AttributedString.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7286
/* End PBXFileReference section */
7387

7488
/* Begin PBXFrameworksBuildPhase section */
@@ -79,6 +93,14 @@
7993
);
8094
runOnlyForDeploymentPostprocessing = 0;
8195
};
96+
9B2E318B26A02FC900BA33A8 /* Frameworks */ = {
97+
isa = PBXFrameworksBuildPhase;
98+
buildActionMask = 2147483647;
99+
files = (
100+
9B2E319D26A0312000BA33A8 /* AttributedString.framework in Frameworks */,
101+
);
102+
runOnlyForDeploymentPostprocessing = 0;
103+
};
82104
/* End PBXFrameworksBuildPhase section */
83105

84106
/* Begin PBXGroup section */
@@ -88,6 +110,7 @@
88110
9B267B5224405CFA002F571E /* Demo-Watch WatchKit App */,
89111
9B267B6124405CFD002F571E /* Demo-Watch WatchKit Extension */,
90112
9B267B4B24405CFA002F571E /* Products */,
113+
9B2E318726A02FC900BA33A8 /* Frameworks */,
91114
);
92115
sourceTree = "<group>";
93116
};
@@ -122,6 +145,14 @@
122145
path = "Demo-Watch WatchKit Extension";
123146
sourceTree = "<group>";
124147
};
148+
9B2E318726A02FC900BA33A8 /* Frameworks */ = {
149+
isa = PBXGroup;
150+
children = (
151+
9B2E319C26A0312000BA33A8 /* AttributedString.framework */,
152+
);
153+
name = Frameworks;
154+
sourceTree = "<group>";
155+
};
125156
/* End PBXGroup section */
126157

127158
/* Begin PBXNativeTarget section */
@@ -148,6 +179,8 @@
148179
buildPhases = (
149180
9B267B4C24405CFA002F571E /* Resources */,
150181
9B267B6E24405CFD002F571E /* Embed App Extensions */,
182+
9B2E318B26A02FC900BA33A8 /* Frameworks */,
183+
9B2E319F26A0312000BA33A8 /* Embed Frameworks */,
151184
);
152185
buildRules = (
153186
);
@@ -446,6 +479,10 @@
446479
DEVELOPMENT_TEAM = "";
447480
IBSC_MODULE = Demo_Watch_WatchKit_Extension;
448481
INFOPLIST_FILE = "Demo-Watch WatchKit App/Info.plist";
482+
LD_RUNPATH_SEARCH_PATHS = (
483+
"$(inherited)",
484+
"@executable_path/Frameworks",
485+
);
449486
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.watchos;
450487
PRODUCT_NAME = "$(TARGET_NAME)";
451488
SDKROOT = watchos;
@@ -465,6 +502,10 @@
465502
DEVELOPMENT_TEAM = "";
466503
IBSC_MODULE = Demo_Watch_WatchKit_Extension;
467504
INFOPLIST_FILE = "Demo-Watch WatchKit App/Info.plist";
505+
LD_RUNPATH_SEARCH_PATHS = (
506+
"$(inherited)",
507+
"@executable_path/Frameworks",
508+
);
468509
PRODUCT_BUNDLE_IDENTIFIER = com.attributedstring.watchos;
469510
PRODUCT_NAME = "$(TARGET_NAME)";
470511
SDKROOT = watchos;

Demo/Demo/Cell/TableViewCell.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TableViewCell: UITableViewCell {
2121
textView.textContainerInset = .zero
2222
}
2323

24-
func set(_ string: AttributedString) {
24+
func set(_ string: ASAttributedString) {
2525
textView.attributed.text = string
2626
}
2727

Demo/Demo/Debug/DebugLabelView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ extension DebugLabelView {
305305

306306
/// 设置富文本
307307
/// - Parameter text: 富文本
308-
func set(text: AttributedString) {
308+
func set(text: ASAttributedString) {
309309
// 富文本中如果包含段落样式 则无法进行多行字号缩放
310310
label.attributed.text = text
311311
// 刷新布局

Demo/Demo/Debug/DebugLabelViewController.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class DebugLabelViewController: ViewController<DebugLabelView> {
1717
didSet { set(info: info) }
1818
}
1919

20-
private var attributes: [AttributedString.Attribute] = []
21-
private var paragraphs: [AttributedString.Attribute.ParagraphStyle] = []
22-
private var attributedString: AttributedString = """
20+
private var attributes: [ASAttributedString.Attribute] = []
21+
private var paragraphs: [ASAttributedString.Attribute.ParagraphStyle] = []
22+
private var attributedString: ASAttributedString = """
2323
我的名字叫李响,我的手机号码是18611401994,我的电子邮件地址是[email protected],现在是2020/06/28 20:30。我的GitHub主页是https://github.com/lixiang1994。欢迎来Star! \("点击联系我", .action({ }))
2424
"""
2525

@@ -41,12 +41,12 @@ class DebugLabelViewController: ViewController<DebugLabelView> {
4141

4242
private func set(info: Debug.Label) {
4343

44-
func update(_ style: AttributedString.Attribute.ParagraphStyle) {
44+
func update(_ style: ASAttributedString.Attribute.ParagraphStyle) {
4545
paragraphs.removeAll(where: { $0 ~= style })
4646
paragraphs.append(style)
4747
}
4848

49-
func remove(_ style: AttributedString.Attribute.ParagraphStyle) {
49+
func remove(_ style: ASAttributedString.Attribute.ParagraphStyle) {
5050
paragraphs.removeAll(where: { $0 ~= style })
5151
}
5252

Demo/Demo/Details/ActionViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ActionViewController: UIViewController {
2121
// 如果需要修改全局默认高亮样式 可以通过以下方式
2222
// Array<AttributedString.Action.Highlight>.defalut = [.foreground(<#T##value: Color##Color#>)]
2323

24-
func clicked(_ result: AttributedString.Action.Result) {
24+
func clicked(_ result: ASAttributedString.Action.Result) {
2525
switch result.content {
2626
case .string(let value):
2727
print("点击了文本: \n\(value) \nrange: \(result.range)")
@@ -31,7 +31,7 @@ class ActionViewController: UIViewController {
3131
}
3232
}
3333

34-
func pressed(_ result: AttributedString.Action.Result) {
34+
func pressed(_ result: ASAttributedString.Action.Result) {
3535
switch result.content {
3636
case .string(let value):
3737
print("按住了文本: \n\(value) \nrange: \(result.range)")
@@ -41,7 +41,7 @@ class ActionViewController: UIViewController {
4141
}
4242
}
4343

44-
let custom = AttributedString.Action(.press, highlights: [.background(#colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)), .foreground(#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0))]) { (result) in
44+
let custom = ASAttributedString.Action(.press, highlights: [.background(#colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)), .foreground(#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0))]) { (result) in
4545
switch result.content {
4646
case .string(let value):
4747
print("按住了文本: \n\(value) \nrange: \(result.range)")

Demo/Demo/Details/CheckingViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CheckingViewController: ViewController<CheckingView> {
2525
// 移除监听
2626
//container.textView.attributed.remove(checking: .link)
2727

28-
func clicked(_ result: AttributedString.Action.Result) {
28+
func clicked(_ result: ASAttributedString.Action.Result) {
2929
switch result.content {
3030
case .string(let value):
3131
print("点击了文本: \n\(value) \nrange: \(result.range)")
@@ -36,7 +36,7 @@ class CheckingViewController: ViewController<CheckingView> {
3636
}
3737

3838
do {
39-
var string: AttributedString = """
39+
var string: ASAttributedString = """
4040
我的名字叫李响,我的手机号码是18611401994,我的电子邮件地址是[email protected],现在是2020/06/28 20:30。我的GitHub主页是https://github.com/lixiang1994。欢迎来Star! \("点击联系我", .action(clicked))
4141
"""
4242
string.add(attributes: [.foreground(#colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1)), .font(.systemFont(ofSize: 20, weight: .medium))], checkings: [.phoneNumber])
@@ -47,7 +47,7 @@ class CheckingViewController: ViewController<CheckingView> {
4747
}
4848

4949
do {
50-
var string: AttributedString = """
50+
var string: ASAttributedString = """
5151
My name is Li Xiang, my mobile phone number is 18611401994, my email address is [email protected], I live in No.10 Xitucheng Road, Haidian District, Beijing, China, and it is now 20:30 on June 28, 2020. My GitHub homepage is https://github.com/lixiang1994. Welcome to star me! \("Contact me", .action(clicked))
5252
"""
5353
string.add(attributes: [.foreground(#colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1))], checkings: [.address])

0 commit comments

Comments
 (0)