Skip to content

Commit a389ae8

Browse files
authored
Move +classNameWithoutNamespaces to WordPressSharedObjC (#24164)
* Move `NSObject +classNameWithoutNamespaces` to WordPressSharedObjC So we can use it next in WordPressData. * Make WordPressData depend on WordPressSharedObjC
1 parent 0b1a843 commit a389ae8

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

Modules/Package.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ let package = Package(
6565
.product(name: "XCUITestHelpers", package: "ScreenObject"),
6666
], swiftSettings: [.swiftLanguageMode(.v5)]),
6767
.target(name: "WordPressDataObjC"),
68-
.target(name: "WordPressData", dependencies: [.target(name: "WordPressDataObjC")]),
68+
.target(
69+
name: "WordPressData",
70+
dependencies: [
71+
.target(name: "WordPressDataObjC"),
72+
.target(name: "WordPressSharedObjC")
73+
]
74+
),
6975
.target(name: "WordPressFlux", swiftSettings: [.swiftLanguageMode(.v5)]),
7076
.target(name: "WordPressCore", dependencies: [.target(name: "WordPressShared"), .product(name: "WordPressAPI", package: "wordpress-rs")]),
7177
.target(name: "WordPressSharedObjC", resources: [.process("Resources")], swiftSettings: [.swiftLanguageMode(.v5)]),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#import "NSObject+ClassName.h"
2+
3+
@implementation NSObject (ClassName)
4+
5+
+ (NSString *)classNameWithoutNamespaces
6+
{
7+
// Note that Swift prepends the module name to the class name itself
8+
return [[NSStringFromClass(self) componentsSeparatedByString:@"."] lastObject];
9+
}
10+
11+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#import <Foundation/Foundation.h>
2+
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
@interface NSObject (ClassName)
6+
7+
+ (NSString *)classNameWithoutNamespaces;
8+
9+
@end
10+
11+
NS_ASSUME_NONNULL_END

WordPress/Classes/Categories/NSObject+Helpers.h

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ NS_ASSUME_NONNULL_BEGIN
44

55
@interface NSObject (Helpers)
66

7+
// FIXME: Currently duplicated in WordPressSharedObjC because it'll be used in WordPressData (which depends on WordPressSharedObjc)
8+
// It's not convenient to replace all usages in the main targets at this time.
9+
// They should progressively diminish as we move all the Core Data related code into WordPressData.
10+
// At that point, we should be able to remove this method from the main target.
711
+ (NSString *)classNameWithoutNamespaces;
812

913
- (void)debounce:(SEL)selector afterDelay:(NSTimeInterval)timeInterval;

0 commit comments

Comments
 (0)