Skip to content

Commit

Permalink
Remove unused code from WordPressShared (#23423)
Browse files Browse the repository at this point in the history
* Remove WPWalkthroughOverlayView

* Remove DateUtils

* Remove unused code from NSString-Helpers

* Remove UIDevice+Helpers

* Remove wp_reduce

* Remove WPNUXUtility

* Remove WPSharedLogging

* Remove unused code from WPStyleGuide

* Remove unused code from WPTableViewCell

* Remove unused WPShared-Swift header

* Remove unused code from WPDeviceIdentification

* Remove unused #if SWIFT_PACAKGE imports

* Remove unused ConsoleLogger

* Remove unused toStringForPageSections

* Remove NSMutableData extensions

* Remove unused Secret

* Remove unwanted commented-out code
  • Loading branch information
kean authored Jul 17, 2024
1 parent 803d111 commit 17a6703
Show file tree
Hide file tree
Showing 52 changed files with 44 additions and 1,633 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import Foundation

#if SWIFT_PACKAGE
import WordPressSharedObjC
#endif

/// This struct represents an analytics event.
/// Declaring this class as final is a design choice to promote a simpler usage and implement events
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import Foundation

// MARK: - Collection Type Helpers
//
extension BidirectionalCollection {
public func lastIndex(where predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.Index? {
if let idx = try reversed().firstIndex(where: predicate) {
return self.index(before: idx.base)
}
return nil
}
}

extension Collection {
/// Returns the element at the specified index if it is within bounds, otherwise nil.
///
public subscript (safe index: Index) -> Element? {
public subscript(safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
24 changes: 0 additions & 24 deletions Modules/Sources/WordPressShared/Utility/ConsoleLogger.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extension Bundle {
/// otherwise it will be the framework bundle.
///
@objc public class var wordPressSharedBundle: Bundle {
#if SWIFT_PACKAGE
#if DEBUG
// Workaround for https://forums.swift.org/t/swift-5-3-swiftpm-resources-in-tests-uses-wrong-bundle-path/37051
if let testBundlePath = ProcessInfo.processInfo.environment["XCTestBundlePath"],
Expand All @@ -18,15 +17,5 @@ extension Bundle {
}
#endif
return Bundle.module
#else
let defaultBundle = Bundle(for: BundleFinder.self)
// If installed with CocoaPods, resources will be in WordPressShared.bundle
if let bundleURL = defaultBundle.resourceURL,
let resourceBundle = Bundle(url: bundleURL.appendingPathComponent("WordPressShared.bundle")) {
return resourceBundle
}
// Otherwise, the default bundle is used for resources
return defaultBundle
#endif
}
}
}
20 changes: 0 additions & 20 deletions Modules/Sources/WordPressShared/Utility/NSDate+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,6 @@ extension Date {
return DateFormatters.shortDateTime.string(from: self)
}

@available(*, deprecated, message: "Not used, as far as I can tell – @jkmassel, Jan 2021")
fileprivate func toStringForPageSections() -> String {
let interval = timeIntervalSinceNow

if interval > 0 && interval < 86400 {
return NSLocalizedString("later today", comment: "Later today")
} else {
let formatter = RelativeDateTimeFormatter()
formatter.unitsStyle = .short
formatter.dateTimeStyle = .named

return formatter.localizedString(fromTimeInterval: interval)
}
}

/// Returns the date components object.
///
public func dateAndTimeComponents() -> DateComponents {
Expand Down Expand Up @@ -244,11 +229,6 @@ extension NSDate {
return (self as Date).shortStringWithTime()
}

@available(*, deprecated, message: "Scheduled for removal with FormatterKit – if it's still used, we'll rewrite it with modern APIs")
@objc public func toStringForPageSections() -> String {
return (self as Date).toStringForPageSections()
}

/// Returns the date components object.
///
@objc public func dateAndTimeComponents() -> NSDateComponents {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import Foundation
import UIKit

#if SWIFT_PACKAGE
import WordPressSharedObjC
#endif

/// Contains methods for formatting post or comment content for display.
///
Expand Down
49 changes: 0 additions & 49 deletions Modules/Sources/WordPressShared/Utility/Secret.swift

This file was deleted.

3 changes: 0 additions & 3 deletions Modules/Sources/WordPressShared/Utility/String+Helpers.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import Foundation

#if SWIFT_PACKAGE
import WordPressSharedObjC
#endif

extension String {
public func stringByDecodingXMLCharacters() -> String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import Foundation

#if SWIFT_PACKAGE
import WordPressSharedObjC
#endif

extension String {

Expand All @@ -15,7 +12,7 @@ extension String {
do {
regex = try NSRegularExpression(pattern: pattern, options: options)
} catch {
WPSharedLogError("Error parsing regex: \(error)")
assertionFailure("Failed to create regex: \(error)")
return self
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import Foundation
import UIKit

#if SWIFT_PACKAGE
import WordPressSharedObjC
#endif

/// Extension on WPStyleGuide to use Dynamic Type fonts.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import Foundation
import UIKit

#if SWIFT_PACKAGE
import WordPressSharedObjC
#endif

/// WPStyleGuide Extension to use serif fonts.
///
Expand Down
24 changes: 0 additions & 24 deletions Modules/Sources/WordPressShared/WordPressShared.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
#if SWIFT_PACKAGE

@_exported import WordPressSharedObjC

#endif

func WPSharedLogError(_ format: String, _ arguments: CVarArg...) {
withVaList(arguments) { WPSharedLogvError(format, $0) }
}

func WPSharedLogWarning(_ format: String, _ arguments: CVarArg...) {
withVaList(arguments) { WPSharedLogvWarning(format, $0) }
}

func WPSharedLogInfo(_ format: String, _ arguments: CVarArg...) {
withVaList(arguments) { WPSharedLogvInfo(format, $0) }
}

func WPSharedLogDebug(_ format: String, _ arguments: CVarArg...) {
withVaList(arguments) { WPSharedLogvDebug(format, $0) }
}

func WPSharedLogVerbose(_ format: String, _ arguments: CVarArg...) {
withVaList(arguments) { WPSharedLogvVerbose(format, $0) }
}
49 changes: 0 additions & 49 deletions Modules/Sources/WordPressSharedObjC/Logging/WPSharedLogging.m

This file was deleted.

13 changes: 0 additions & 13 deletions Modules/Sources/WordPressSharedObjC/Private/WPShared-Swift.h

This file was deleted.

37 changes: 0 additions & 37 deletions Modules/Sources/WordPressSharedObjC/Utility/DateUtils.m

This file was deleted.

Loading

0 comments on commit 17a6703

Please sign in to comment.