Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 083c3aa

Browse files
committed
Add Package.swift
1 parent 2117da6 commit 083c3aa

23 files changed

+354
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ vendor/
3333
fastlane/test_output
3434
fastlane/README.md
3535
fastlane/report.xml
36+
37+
.swiftpm

Package.resolved

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
// swift-tools-version:5.5
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "WordPressShared",
7+
platforms: [.iOS(.v13)],
8+
products: [
9+
.library(name: "WordPressShared", targets: ["WordPressShared"])
10+
],
11+
dependencies: [
12+
.package(url: "https://github.com/buildkite/test-collector-swift", from: "0.3.0"),
13+
.package(url: "https://github.com/CocoaLumberjack/CocoaLumberjack", from: "3.8.0"),
14+
.package(url: "https://github.com/AliSoftware/OHHTTPStubs", from: "9.1.0"),
15+
// See https://github.com/erikdoe/ocmock/issues/500#issuecomment-1002700625
16+
.package(url: "https://github.com/erikdoe/ocmock", revision: "afd2c6924e8a36cb872bc475248b978f743c6050"),
17+
.package(url: "https://github.com/Quick/Quick", from: "6.0.0"),
18+
],
19+
targets: [
20+
.target(
21+
name: "WordPressSharedAnalyticsObjC",
22+
path: "WordPressShared/Core/Analytics",
23+
sources: ["WPAnalytics.m"],
24+
publicHeadersPath: "."
25+
),
26+
.target(
27+
name: "WordPressSharedAnalytics",
28+
dependencies: [.target(name: "WordPressSharedAnalyticsObjC")],
29+
path: "WordPressShared/Core/Analytics",
30+
sources: ["AnalyticsEvent.swift"]
31+
),
32+
.target(
33+
name: "WordPressSharedLoggingObjCPrivate",
34+
dependencies: [.product(name: "CocoaLumberjack", package: "CocoaLumberjack")],
35+
path: "WordPressShared/Private",
36+
sources: ["WPSharedLoggingPrivate.m",],
37+
publicHeadersPath: "."
38+
),
39+
.target(
40+
name: "WordPressSharedLoggingObjC",
41+
dependencies: [.target(name: "WordPressSharedLoggingObjCPrivate")],
42+
path: "WordPressShared/Core/Logging",
43+
sources: ["WPSharedLogging.m"],
44+
publicHeadersPath: "."
45+
),
46+
.target(
47+
name: "WordPressSharedUtlityObjC",
48+
dependencies: [
49+
.target(name: "WordPressSharedLoggingObjCPrivate"),
50+
.target(name: "WordPressSharedResources"),
51+
],
52+
path: "WordPressShared/Core/Utility",
53+
sources: [
54+
"PhotonImageURLHelper.m",
55+
"NSString+Helpers.m",
56+
"DisplayableImageHelper.m",
57+
"NSString+XMLExtensions.m",
58+
"WPFontManager.m",
59+
"DateUtils.m",
60+
"WPDeviceIdentification.m",
61+
"NSString+Util.m",
62+
"UIDevice+Helpers.m",
63+
"NSBundle+VersionNumberHelper.m",
64+
"WPImageSource.m",
65+
"WPMapFilterReduce.m",
66+
],
67+
publicHeadersPath: "."
68+
),
69+
.target(
70+
name: "WordPressSharedResources",
71+
dependencies: [.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack")],
72+
path: "WordPressShared",
73+
sources: [
74+
"Core/Utility/NSBundle+WordPressShared.swift",
75+
],
76+
resources: [.process("Resources")]
77+
),
78+
.target(
79+
name: "WordPressSharedUtlity",
80+
dependencies: [
81+
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
82+
.target(name: "WordPressSharedUtlityObjC"),
83+
.target(name: "WordPressSharedResources"),
84+
],
85+
path: "WordPressShared/Core/Utility",
86+
sources: [
87+
"String+StripGutenbergContentForExcerpt.swift",
88+
"EmailFormatValidator.swift",
89+
"String+RemovingMatches.swift",
90+
"EmailTypoChecker.swift",
91+
"Dictionary+Helpers.swift",
92+
"Secret.swift",
93+
"WPImageURLHelper.swift",
94+
"NSDate+Helpers.swift",
95+
"CollectionType+Helpers.swift",
96+
"NSString+Summary.swift",
97+
"String+StripShortcodes.swift",
98+
"RichContentFormatter.swift",
99+
"String+URLValidation.swift",
100+
"Debouncer.swift",
101+
"Languages.swift",
102+
"NSString+Swift.swift",
103+
"NSMutableData+Helpers.swift",
104+
"String+Helpers.swift",
105+
]
106+
),
107+
.target(
108+
name: "WordPressSharedViewObjC",
109+
dependencies: [
110+
.target(name: "WordPressSharedUtlityObjC")
111+
],
112+
path: "WordPressShared/Core/Views",
113+
sources: [
114+
"WPStyleGuide.m",
115+
"WPTextFieldTableViewCell.m",
116+
"WPTableViewCell.m",
117+
"WPNUXUtility.m",
118+
],
119+
publicHeadersPath: "."
120+
),
121+
.target(
122+
name: "WordPressSharedView",
123+
dependencies: [
124+
.target(name: "WordPressSharedViewObjC"),
125+
],
126+
path: "WordPressShared/Core/Views",
127+
sources: [
128+
"WPStyleGuide+SerifFonts.swift",
129+
"WPStyleGuide+DynamicType.swift",
130+
]
131+
),
132+
.target(
133+
name: "WordPressShared",
134+
dependencies: [
135+
.target(name: "WordPressSharedAnalyticsObjC"),
136+
.target(name: "WordPressSharedAnalytics"),
137+
.target(name: "WordPressSharedLoggingObjC"),
138+
.target(name: "WordPressSharedUtlityObjC"),
139+
.target(name: "WordPressSharedResources"),
140+
.target(name: "WordPressSharedUtlity"),
141+
.target(name: "WordPressSharedViewObjC"),
142+
.target(name: "WordPressSharedView"),
143+
],
144+
path: "WordPressShared",
145+
sources: ["WordPressShared.swift"]
146+
),
147+
.testTarget(
148+
name: "WordPressSharedTests",
149+
dependencies: [
150+
.target(name: "WordPressShared"),
151+
.product(name: "OCMock", package: "ocmock"),
152+
"Quick",
153+
"OHHTTPStubs",
154+
],
155+
path: "WordPressSharedTests",
156+
sources: [
157+
"WPImageSourceTest.m",
158+
"TestAnalyticsTracker.m",
159+
"PhotonImageURLHelperTest.m",
160+
"DisplayableImageHelperTest.m",
161+
"NSStringHelpersTests.m",
162+
"WPAnalyticsTests.m",
163+
"NSStringSwiftTests.m",
164+
"WPMapFilterReduceTest.m",
165+
],
166+
resources: [
167+
.copy("anim-reader.gif"),
168+
.copy("test-image.jpg"),
169+
]
170+
)
171+
]
172+
)

WordPressShared/Core/Analytics/AnalyticsEvent.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import Foundation
22

3+
#if SWIFT_PACKAGE
4+
import WordPressSharedAnalyticsObjC
5+
#endif
6+
37
/// This struct represents an analytics event.
48
/// Declaring this class as final is a design choice to promote a simpler usage and implement events
59
/// through parametrization of the `name` and `properties` properties.

WordPressShared/Core/Logging/WPSharedLogging.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#import "WPSharedLogging.h"
2+
3+
#if SWIFT_PACKAGE
4+
@import WordPressSharedLoggingObjCPrivate;
5+
#else
26
#import "WPSharedLoggingPrivate.h"
7+
#endif
38

49
DDLogLevel WPSharedGetLoggingLevel() {
510
return ddLogLevel;

WordPressShared/Core/Utility/Languages.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import Foundation
22

3+
#if SWIFT_PACKAGE
4+
import WordPressSharedResources
5+
#endif
6+
37
/// This helper class allows us to map WordPress.com LanguageID's into human readable language strings.
48
///
59
public class WordPressComLanguageDatabase: NSObject {
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
import Foundation
22

3+
#if !SWIFT_PACKAGE
4+
private class BundleFinder: NSObject {}
5+
#endif
6+
37
extension Bundle {
48

59
/// Returns the WordPressShared Bundle
610
/// If installed via CocoaPods, this will be WordPressShared.bundle,
711
/// otherwise it will be the framework bundle.
812
///
913
@objc public class var wordPressSharedBundle: Bundle {
10-
let defaultBundle = Bundle(for: WPFontManager.self)
14+
#if SWIFT_PACKAGE
15+
return Bundle.module
16+
#else
17+
let defaultBundle = Bundle(for: BundleFinder.self)
1118
// If installed with CocoaPods, resources will be in WordPressShared.bundle
1219
if let bundleURL = defaultBundle.resourceURL,
1320
let resourceBundle = Bundle(url: bundleURL.appendingPathComponent("WordPressShared.bundle")) {
1421
return resourceBundle
1522
}
1623
// Otherwise, the default bundle is used for resources
1724
return defaultBundle
25+
#endif
1826
}
1927
}

WordPressShared/Core/Utility/NSString+Helpers.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#import "NSString+Helpers.h"
22
#import <CommonCrypto/CommonDigest.h>
3-
#import "WPSharedLoggingPrivate.h"
43
#import "NSString+XMLExtensions.h"
54

5+
#if SWIFT_PACKAGE
6+
@import WordPressSharedLoggingObjCPrivate;
7+
#else
8+
#import "WPSharedLoggingPrivate.h"
9+
#endif
10+
611
static NSString *const Ellipsis = @"\u2026";
712

813
@implementation NSString (Helpers)

WordPressShared/Core/Utility/NSString+Util.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
#if SWIFT_PACKAGE
2+
#import "NSString+Util.h"
3+
#else
14
#import <WordPressShared/NSString+Util.h>
5+
#endif
26

37

48
@implementation NSString (Util)

WordPressShared/Core/Utility/RichContentFormatter.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import Foundation
2+
import UIKit
3+
4+
#if SWIFT_PACKAGE
5+
import WordPressSharedUtlityObjC
6+
#endif
27

38
/// Contains methods for formatting post or comment content for display.
49
///

0 commit comments

Comments
 (0)