diff --git a/RSCore/Sources/RSCoreObjC/NSSharingService+RSCore.h b/Mac/MainWindow/Timeline/NSSharingService+Extension.h similarity index 91% rename from RSCore/Sources/RSCoreObjC/NSSharingService+RSCore.h rename to Mac/MainWindow/Timeline/NSSharingService+Extension.h index 0914febbc..389a58161 100644 --- a/RSCore/Sources/RSCoreObjC/NSSharingService+RSCore.h +++ b/Mac/MainWindow/Timeline/NSSharingService+Extension.h @@ -5,10 +5,7 @@ // Created by Brent Simmons on 11/3/24. // -#if TARGET_OS_OSX - @import AppKit; -#import @interface NSSharingService (NoDeprecationWarning) @@ -24,5 +21,3 @@ + (NSArray *)sharingServicesForItems_noDeprecationWarning:(NSArray *)items; @end - -#endif diff --git a/RSCore/Sources/RSCoreObjC/NSSharingService+RSCore.m b/Mac/MainWindow/Timeline/NSSharingService+Extension.m similarity index 75% rename from RSCore/Sources/RSCoreObjC/NSSharingService+RSCore.m rename to Mac/MainWindow/Timeline/NSSharingService+Extension.m index 663340fb7..cf2e71e26 100644 --- a/RSCore/Sources/RSCoreObjC/NSSharingService+RSCore.m +++ b/Mac/MainWindow/Timeline/NSSharingService+Extension.m @@ -1,15 +1,11 @@ // -// NSSharingService+RSCore.m +// NSSharingService+Extension.m // RSCore // // Created by Brent Simmons on 11/3/24. // -#import - -#if TARGET_OS_OSX - -#import "NSSharingService+RSCore.h" +#import "NSSharingService+Extension.h" @implementation NSSharingService (NoDeprecationWarning) @@ -24,5 +20,3 @@ } @end - -#endif diff --git a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift index 828a2a47c..8a0199f12 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift @@ -8,7 +8,6 @@ import AppKit import RSCore -import RSCoreObjC import Articles import Account diff --git a/Mac/NetNewsWire-Bridging-Header.h b/Mac/NetNewsWire-Bridging-Header.h index 3f547bcf1..01bbec4e2 100644 --- a/Mac/NetNewsWire-Bridging-Header.h +++ b/Mac/NetNewsWire-Bridging-Header.h @@ -7,3 +7,4 @@ // #import "WKPreferencesPrivate.h" +#import "NSSharingService+Extension.h" diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index edca111f7..2e433a0a7 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -59,17 +59,11 @@ 840D617F2029031C009BC708 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D617E2029031C009BC708 /* AppDelegate.swift */; }; 8413876D2CD8970B00E8490F /* RSCore in Frameworks */ = {isa = PBXBuildFile; productRef = 8413876C2CD8970B00E8490F /* RSCore */; }; 8413876E2CD8970B00E8490F /* RSCore in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 8413876C2CD8970B00E8490F /* RSCore */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 841387702CD8970B00E8490F /* RSCoreObjC in Frameworks */ = {isa = PBXBuildFile; productRef = 8413876F2CD8970B00E8490F /* RSCoreObjC */; }; - 841387712CD8970B00E8490F /* RSCoreObjC in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 8413876F2CD8970B00E8490F /* RSCoreObjC */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 841387732CD8970B00E8490F /* RSCoreResources in Frameworks */ = {isa = PBXBuildFile; productRef = 841387722CD8970B00E8490F /* RSCoreResources */; }; 841387752CD897C500E8490F /* RSCore in Frameworks */ = {isa = PBXBuildFile; productRef = 841387742CD897C500E8490F /* RSCore */; }; 841387762CD897C500E8490F /* RSCore in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 841387742CD897C500E8490F /* RSCore */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 841387782CD897C500E8490F /* RSCoreObjC in Frameworks */ = {isa = PBXBuildFile; productRef = 841387772CD897C500E8490F /* RSCoreObjC */; }; - 841387792CD897C500E8490F /* RSCoreObjC in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 841387772CD897C500E8490F /* RSCoreObjC */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 8413877B2CD897CF00E8490F /* RSCore in Frameworks */ = {isa = PBXBuildFile; productRef = 8413877A2CD897CF00E8490F /* RSCore */; }; - 8413877E2CD897CF00E8490F /* RSCoreObjC in Frameworks */ = {isa = PBXBuildFile; productRef = 8413877D2CD897CF00E8490F /* RSCoreObjC */; }; 841387812CD897EF00E8490F /* RSCore in Frameworks */ = {isa = PBXBuildFile; productRef = 841387802CD897EF00E8490F /* RSCore */; }; - 841387842CD897EF00E8490F /* RSCoreObjC in Frameworks */ = {isa = PBXBuildFile; productRef = 841387832CD897EF00E8490F /* RSCoreObjC */; }; 841387872CD89E5200E8490F /* RSCore in Frameworks */ = {isa = PBXBuildFile; productRef = 841387862CD89E5200E8490F /* RSCore */; }; 8413878E2CDC790C00E8490F /* RSWeb in Frameworks */ = {isa = PBXBuildFile; productRef = 8413878D2CDC790C00E8490F /* RSWeb */; }; 8413878F2CDC790C00E8490F /* RSWeb in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 8413878D2CDC790C00E8490F /* RSWeb */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -225,7 +219,6 @@ 513F327B2593EE6F0003048F /* SyncDatabase in Embed Frameworks */, 513F32722593EE6F0003048F /* Articles in Embed Frameworks */, 513F32812593EF180003048F /* Account in Embed Frameworks */, - 841387792CD897C500E8490F /* RSCoreObjC in Embed Frameworks */, 513F32752593EE6F0003048F /* ArticlesDatabase in Embed Frameworks */, ); name = "Embed Frameworks"; @@ -269,7 +262,6 @@ 513277662590FC780064F1E7 /* Secrets in Embed Frameworks */, 513277652590FC640064F1E7 /* SyncDatabase in Embed Frameworks */, 513277622590FC640064F1E7 /* ArticlesDatabase in Embed Frameworks */, - 841387712CD8970B00E8490F /* RSCoreObjC in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -570,7 +562,6 @@ buildActionMask = 2147483647; files = ( 841387812CD897EF00E8490F /* RSCore in Frameworks */, - 841387842CD897EF00E8490F /* RSCoreObjC in Frameworks */, 511B148924E5DBDD00C919BD /* Account in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -590,7 +581,6 @@ files = ( 51BC2F3824D3439A00E90810 /* Account in Frameworks */, 8413877B2CD897CF00E8490F /* RSCore in Frameworks */, - 8413877E2CD897CF00E8490F /* RSCoreObjC in Frameworks */, 84C1EB4A2CDFE0D200C7456A /* RSTree in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -619,7 +609,6 @@ 516B695F24D2F33B00B5702F /* Account in Frameworks */, 847C4C112CDF2310008BF5FE /* RSTree in Frameworks */, 8417FA432CDF2E56005F989B /* RSDatabase in Frameworks */, - 841387782CD897C500E8490F /* RSCoreObjC in Frameworks */, 513F32712593EE6F0003048F /* Articles in Frameworks */, 513F32772593EE6F0003048F /* Secrets in Frameworks */, 841387912CDC791B00E8490F /* RSWeb in Frameworks */, @@ -642,7 +631,6 @@ 841387732CD8970B00E8490F /* RSCoreResources in Frameworks */, 8413878E2CDC790C00E8490F /* RSWeb in Frameworks */, 179C39EA26F76B0500D4E741 /* Zip in Frameworks */, - 841387702CD8970B00E8490F /* RSCoreObjC in Frameworks */, 847C4C0E2CDF2301008BF5FE /* RSTree in Frameworks */, 8413876D2CD8970B00E8490F /* RSCore in Frameworks */, 514C16CE24D2E63F009A3AFA /* Account in Frameworks */, @@ -791,7 +779,6 @@ packageProductDependencies = ( 511B148824E5DBDD00C919BD /* Account */, 841387802CD897EF00E8490F /* RSCore */, - 841387832CD897EF00E8490F /* RSCoreObjC */, ); productName = ShareExtension; productReference = 510C415C24E5CDE3008226FD /* NetNewsWire Share Extension.appex */; @@ -839,7 +826,6 @@ packageProductDependencies = ( 51BC2F3724D3439A00E90810 /* Account */, 8413877A2CD897CF00E8490F /* RSCore */, - 8413877D2CD897CF00E8490F /* RSCoreObjC */, 84C1EB492CDFE0D200C7456A /* RSTree */, ); productName = "NetNewsWire iOS Share Extension"; @@ -921,7 +907,6 @@ 513F32792593EE6F0003048F /* SyncDatabase */, 179D280A26F6F93D003B2E0A /* Zip */, 841387742CD897C500E8490F /* RSCore */, - 841387772CD897C500E8490F /* RSCoreObjC */, 841387902CDC791B00E8490F /* RSWeb */, 847C4C102CDF2310008BF5FE /* RSTree */, 8417FA422CDF2E56005F989B /* RSDatabase */, @@ -967,7 +952,6 @@ 513277632590FC640064F1E7 /* SyncDatabase */, 179C39E926F76B0500D4E741 /* Zip */, 8413876C2CD8970B00E8490F /* RSCore */, - 8413876F2CD8970B00E8490F /* RSCoreObjC */, 841387722CD8970B00E8490F /* RSCoreResources */, 8413878D2CDC790C00E8490F /* RSWeb */, 847C4C0D2CDF2301008BF5FE /* RSTree */, @@ -1821,10 +1805,6 @@ isa = XCSwiftPackageProductDependency; productName = RSCore; }; - 8413876F2CD8970B00E8490F /* RSCoreObjC */ = { - isa = XCSwiftPackageProductDependency; - productName = RSCoreObjC; - }; 841387722CD8970B00E8490F /* RSCoreResources */ = { isa = XCSwiftPackageProductDependency; productName = RSCoreResources; @@ -1833,26 +1813,14 @@ isa = XCSwiftPackageProductDependency; productName = RSCore; }; - 841387772CD897C500E8490F /* RSCoreObjC */ = { - isa = XCSwiftPackageProductDependency; - productName = RSCoreObjC; - }; 8413877A2CD897CF00E8490F /* RSCore */ = { isa = XCSwiftPackageProductDependency; productName = RSCore; }; - 8413877D2CD897CF00E8490F /* RSCoreObjC */ = { - isa = XCSwiftPackageProductDependency; - productName = RSCoreObjC; - }; 841387802CD897EF00E8490F /* RSCore */ = { isa = XCSwiftPackageProductDependency; productName = RSCore; }; - 841387832CD897EF00E8490F /* RSCoreObjC */ = { - isa = XCSwiftPackageProductDependency; - productName = RSCoreObjC; - }; 841387862CD89E5200E8490F /* RSCore */ = { isa = XCSwiftPackageProductDependency; productName = RSCore; diff --git a/RSCore/.swiftpm/xcode/xcshareddata/xcschemes/RSCore.xcscheme b/RSCore/.swiftpm/xcode/xcshareddata/xcschemes/RSCore.xcscheme new file mode 100644 index 000000000..7dca0385c --- /dev/null +++ b/RSCore/.swiftpm/xcode/xcshareddata/xcschemes/RSCore.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RSCore/.swiftpm/xcode/xcshareddata/xcschemes/RSCoreTests.xcscheme b/RSCore/.swiftpm/xcode/xcshareddata/xcschemes/RSCoreTests.xcscheme new file mode 100644 index 000000000..fdd717019 --- /dev/null +++ b/RSCore/.swiftpm/xcode/xcshareddata/xcschemes/RSCoreTests.xcscheme @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/RSCore/Package.swift b/RSCore/Package.swift index 30a6f1ab8..5e3848bf6 100644 --- a/RSCore/Package.swift +++ b/RSCore/Package.swift @@ -7,22 +7,13 @@ let package = Package( platforms: [.macOS(.v14), .iOS(.v17)], products: [ .library(name: "RSCore", type: .dynamic, targets: ["RSCore"]), - .library(name: "RSCoreObjC", type: .dynamic, targets: ["RSCoreObjC"]), .library(name: "RSCoreResources", type: .static, targets: ["RSCoreResources"]) ], targets: [ .target( name: "RSCore", - dependencies: ["RSCoreObjC"], swiftSettings: [.unsafeFlags(["-warnings-as-errors"])] ), - .target( - name: "RSCoreObjC", - dependencies: [], - cSettings: [ - .headerSearchPath("include") - ] - ), .target( name: "RSCoreResources", resources: [ diff --git a/RSCore/Sources/RSCoreObjC/NSData+RSCore.h b/RSCore/Sources/RSCoreObjC/NSData+RSCore.h deleted file mode 100755 index d9b9e1e52..000000000 --- a/RSCore/Sources/RSCoreObjC/NSData+RSCore.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// NSData+RSCore.h -// RSCore -// -// Created by Brent Simmons on 3/25/15. -// Copyright (c) 2015 Ranchero Software, LLC. All rights reserved. -// - -@import Foundation; - - -BOOL RSEqualBytes(const void *bytes1, const void *bytes2, size_t length); - -NSString *RSHexadecimalStringWithBytes(const unsigned char *bytes, NSUInteger numberOfBytes); - - -@interface NSData (RSCore) - -- (NSData *)rs_md5Hash; -- (NSString *)rs_md5HashString; - -- (BOOL)rs_dataIsPNG; -- (BOOL)rs_dataIsGIF; -- (BOOL)rs_dataIsJPEG; -- (BOOL)rs_dataIsImage; - -- (BOOL)rs_dataIsProbablyHTML; - -- (BOOL)rs_dataBeginsWithBytes:(const void *)bytes length:(size_t)numberOfBytes; - -- (NSString *)rs_noCopyString; //This data object must out-live returned string. May return nil. - -/*If bytes are deadbeef, then string is @"deadbeef". Returns nil for empty data.*/ - -- (NSString *)rs_hexadecimalString; - -@end diff --git a/RSCore/Sources/RSCoreObjC/NSData+RSCore.m b/RSCore/Sources/RSCoreObjC/NSData+RSCore.m deleted file mode 100755 index d49f7e602..000000000 --- a/RSCore/Sources/RSCoreObjC/NSData+RSCore.m +++ /dev/null @@ -1,156 +0,0 @@ -// -// NSData+RSCore.m -// RSCore -// -// Created by Brent Simmons on 3/25/15. -// Copyright (c) 2015 Ranchero Software, LLC. All rights reserved. -// - -#import -#import "NSData+RSCore.h" - - -@implementation NSData (RSCore) - - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -- (NSData *)rs_md5Hash { - - unsigned char hash[CC_MD5_DIGEST_LENGTH]; - CC_MD5([self bytes], (CC_LONG)[self length], hash); - - return [NSData dataWithBytes:(const void *)hash length:CC_MD5_DIGEST_LENGTH]; -} -#pragma GCC diagnostic pop - -- (NSString *)rs_md5HashString { - - NSData *d = [self rs_md5Hash]; - return [d rs_hexadecimalString]; -} - -BOOL RSEqualBytes(const void *bytes1, const void *bytes2, size_t length) { - - return memcmp(bytes1, bytes2, length) == 0; -} - - -- (BOOL)rs_dataBeginsWithBytes:(const void *)bytes length:(size_t)numberOfBytes { - - if ([self length] < numberOfBytes) { - return NO; - } - - return RSEqualBytes([self bytes], bytes, numberOfBytes); -} - - -- (BOOL)rs_dataIsPNG { - - /* http://www.w3.org/TR/PNG/#5PNG-file-signature : "The first eight bytes of a PNG datastream always contain the following (decimal) values: 137 80 78 71 13 10 26 10" */ - - static const Byte pngHeader[] = {137, 'P', 'N', 'G', 13, 10, 26, 10}; - return [self rs_dataBeginsWithBytes:pngHeader length:sizeof(pngHeader)]; -} - - -- (BOOL)rs_dataIsGIF { - - /* http://www.onicos.com/staff/iz/formats/gif.html */ - - static const Byte gifHeader1[] = {'G', 'I', 'F', '8', '7', 'a'}; - if ([self rs_dataBeginsWithBytes:gifHeader1 length:sizeof(gifHeader1)]) { - return YES; - } - - static const Byte gifHeader2[] = {'G', 'I', 'F', '8', '9', 'a'}; - return [self rs_dataBeginsWithBytes:gifHeader2 length:sizeof(gifHeader2)]; -} - - -- (BOOL)rs_dataIsJPEG { - - const void *bytes = [self bytes]; - - static const Byte jpegHeader1[] = {'J', 'F', 'I', 'F'}; - - if (RSEqualBytes(bytes + 6, jpegHeader1, sizeof(jpegHeader1))) { - return YES; - } - - static const Byte jpegHeader2[] = {'E', 'x', 'i', 'f'}; - return RSEqualBytes(bytes + 6, jpegHeader2, sizeof(jpegHeader2)); -} - - -- (BOOL)rs_dataIsImage { - - return [self rs_dataIsPNG] || [self rs_dataIsJPEG] || [self rs_dataIsGIF]; -} - - -- (BOOL)rs_dataIsProbablyHTML { - - NSString *s = [self rs_noCopyString]; - if (!s) { - return NO; - } - - if (![s containsString:@">"] || ![s containsString:@">"]) { - return NO; - } - - for (NSString *oneString in @[@"html", @"body"]) { - NSRange range = [s rangeOfString:oneString options:NSCaseInsensitiveSearch]; - if (range.location == NSNotFound) { - return NO; - } - } - - return YES; -} - - -- (NSString *)rs_noCopyString { - - NSDictionary *options = @{NSStringEncodingDetectionSuggestedEncodingsKey : @[@(NSUTF8StringEncoding)]}; - BOOL usedLossyConversion = NO; - NSStringEncoding encoding = [NSString stringEncodingForData:self encodingOptions:options convertedString:nil usedLossyConversion:&usedLossyConversion]; - if (encoding == 0) { - return nil; - } - - return [[NSString alloc] initWithBytesNoCopy:(void *)self.bytes length:self.length encoding:encoding freeWhenDone:NO]; -} - - -NSString *RSHexadecimalStringWithBytes(const Byte *bytes, NSUInteger numberOfBytes) { - - if (numberOfBytes < 1) { - return nil; - } - - if (numberOfBytes == 16) { - // Common case — MD5 hash, for example. - return [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]]; - } - - NSMutableString *s = [[NSMutableString alloc] initWithString:@""]; - NSUInteger i = 0; - - for (i = 0; i < numberOfBytes; i++) { - [s appendString:[NSString stringWithFormat:@"%02x", bytes[i]]]; - } - - return [s copy]; -} - - -- (NSString *)rs_hexadecimalString { - - return RSHexadecimalStringWithBytes([self bytes], [self length]); -} - - -@end diff --git a/RSCore/Sources/RSCoreObjC/include/RSCore.h b/RSCore/Sources/RSCoreObjC/include/RSCore.h deleted file mode 100644 index 894196969..000000000 --- a/RSCore/Sources/RSCoreObjC/include/RSCore.h +++ /dev/null @@ -1,11 +0,0 @@ -// -// RSCore.h -// -// -// Created by Maurice Parker on 11/20/20. -// - -@import Foundation; - -#import "../NSData+RSCore.h" -#import "../NSSharingService+RSCore.h" diff --git a/RSParser/.swiftpm/xcode/xcshareddata/xcschemes/RSParser.xcscheme b/RSParser/.swiftpm/xcode/xcshareddata/xcschemes/RSParser.xcscheme new file mode 100644 index 000000000..e6ad3f0f0 --- /dev/null +++ b/RSParser/.swiftpm/xcode/xcshareddata/xcschemes/RSParser.xcscheme @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RSParser/.swiftpm/xcode/xcshareddata/xcschemes/RSParserTests.xcscheme b/RSParser/.swiftpm/xcode/xcshareddata/xcschemes/RSParserTests.xcscheme new file mode 100644 index 000000000..d49f2c2c1 --- /dev/null +++ b/RSParser/.swiftpm/xcode/xcshareddata/xcschemes/RSParserTests.xcscheme @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + +