From 3ec9f9b7616f92f43dc8750ebe2f4ff024a71a8c Mon Sep 17 00:00:00 2001 From: gsl-anthonymerle Date: Fri, 3 May 2024 10:27:53 +0200 Subject: [PATCH 1/4] update project to be compatible with XCode 14.3 --- LinesSorter.xcodeproj/project.pbxproj | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/LinesSorter.xcodeproj/project.pbxproj b/LinesSorter.xcodeproj/project.pbxproj index c155322..ffe523e 100644 --- a/LinesSorter.xcodeproj/project.pbxproj +++ b/LinesSorter.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 676A624E2BE3EE6500DCE1D9 /* XcodeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 679977972BE3E9E500722F13 /* XcodeKit.framework */; }; + 676A624F2BE3EE6500DCE1D9 /* XcodeKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 679977972BE3E9E500722F13 /* XcodeKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 886FC12D212B5A260067A24F /* Array+DuplicatedElementsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 886FC12C212B5A260067A24F /* Array+DuplicatedElementsTests.swift */; }; 886FC12F212B5A930067A24F /* Array+DuplicatesElements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 886FC12E212B5A930067A24F /* Array+DuplicatesElements.swift */; }; 886FC130212B5B690067A24F /* Array+DuplicatesElements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 886FC12E212B5A930067A24F /* Array+DuplicatesElements.swift */; }; @@ -56,6 +58,17 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + 676A62502BE3EE6500DCE1D9 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 676A624F2BE3EE6500DCE1D9 /* XcodeKit.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; D72EFE962122FBD7009E4A17 /* Embed App Extensions */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -70,6 +83,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 679977972BE3E9E500722F13 /* XcodeKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XcodeKit.framework; path = Library/Frameworks/XcodeKit.framework; sourceTree = DEVELOPER_DIR; }; 886FC12C212B5A260067A24F /* Array+DuplicatedElementsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+DuplicatedElementsTests.swift"; sourceTree = ""; }; 886FC12E212B5A930067A24F /* Array+DuplicatesElements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+DuplicatesElements.swift"; sourceTree = ""; }; 886FC131212B5C410067A24F /* SortSelectedLinesCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SortSelectedLinesCommand.swift; sourceTree = ""; }; @@ -122,6 +136,7 @@ buildActionMask = 2147483647; files = ( D72EFE882122FBD7009E4A17 /* Cocoa.framework in Frameworks */, + 676A624E2BE3EE6500DCE1D9 /* XcodeKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -181,6 +196,7 @@ isa = PBXGroup; children = ( D72EFE872122FBD7009E4A17 /* Cocoa.framework */, + 679977972BE3E9E500722F13 /* XcodeKit.framework */, ); name = Frameworks; sourceTree = ""; @@ -267,6 +283,7 @@ D72EFE812122FBD7009E4A17 /* Sources */, D72EFE822122FBD7009E4A17 /* Frameworks */, D72EFE832122FBD7009E4A17 /* Resources */, + 676A62502BE3EE6500DCE1D9 /* Embed Frameworks */, ); buildRules = ( ); @@ -283,7 +300,7 @@ D72EFE582122FBC6009E4A17 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0940; + LastSwiftUpdateCheck = 1530; LastUpgradeCheck = 0940; ORGANIZATIONNAME = "Vadim Bulavin"; TargetAttributes = { @@ -544,6 +561,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = BG5NSSX25D; + ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = LinesSorter/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -567,6 +585,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = BG5NSSX25D; + ENABLE_HARDENED_RUNTIME = YES; ENABLE_TESTABILITY = YES; INFOPLIST_FILE = LinesSorter/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( From 10e147df1c64c80aab54c487927af0233fd973be Mon Sep 17 00:00:00 2001 From: gsl-anthonymerle Date: Fri, 3 May 2024 10:47:35 +0200 Subject: [PATCH 2/4] Add capability to extension --- LinesSorter.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LinesSorter.xcodeproj/project.pbxproj b/LinesSorter.xcodeproj/project.pbxproj index ffe523e..6f79f9d 100644 --- a/LinesSorter.xcodeproj/project.pbxproj +++ b/LinesSorter.xcodeproj/project.pbxproj @@ -658,6 +658,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = BG5NSSX25D; + ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = SourceEditorExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -684,6 +685,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = BG5NSSX25D; + ENABLE_HARDENED_RUNTIME = YES; ENABLE_TESTABILITY = YES; INFOPLIST_FILE = SourceEditorExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( From 398784bda9e3d334cfdd52952d77f64a53542c3a Mon Sep 17 00:00:00 2001 From: gsl-anthonymerle Date: Thu, 24 Oct 2024 09:11:37 +0200 Subject: [PATCH 3/4] Sort lines without taking into account keywords and case sensitivity --- SourceEditorExtension/Core/Prettifier.swift | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/SourceEditorExtension/Core/Prettifier.swift b/SourceEditorExtension/Core/Prettifier.swift index eecd89d..77fbb98 100644 --- a/SourceEditorExtension/Core/Prettifier.swift +++ b/SourceEditorExtension/Core/Prettifier.swift @@ -24,8 +24,17 @@ struct Prettifier { let linesRemoved = removeBlankLines(lines: lines, in: range) range = range.lowerBound...(range.upperBound - linesRemoved) - LinesSorter().sort(lines, in: range, by: <) - + LinesSorter().sort(lines, in: range) { lhs, rhs in + let lhs = lhs + .removingImportKeywords() + .lowercased() + let rhs = rhs + .removingImportKeywords() + .lowercased() + + return lhs < rhs + } + removeDuplicates(from: lines, in: range) } @@ -56,3 +65,11 @@ struct Prettifier { .forEach(lines.removeObject(at:)) } } + +extension StringProtocol { + func removingImportKeywords() -> String { + replacingOccurrences(of: "@preconcurrency", with: "") + .replacingOccurrences(of: "@testable", with: "") + .replacingOccurrences(of: "import", with: "") + } +} From bf5554f80500f5b6647cbc2981eaaa629cb22904 Mon Sep 17 00:00:00 2001 From: gsl-anthonymerle Date: Thu, 24 Oct 2024 09:38:23 +0200 Subject: [PATCH 4/4] Revert "Sort lines without taking into account keywords and case sensitivity" This reverts commit 398784bda9e3d334cfdd52952d77f64a53542c3a. --- SourceEditorExtension/Core/Prettifier.swift | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/SourceEditorExtension/Core/Prettifier.swift b/SourceEditorExtension/Core/Prettifier.swift index 77fbb98..eecd89d 100644 --- a/SourceEditorExtension/Core/Prettifier.swift +++ b/SourceEditorExtension/Core/Prettifier.swift @@ -24,17 +24,8 @@ struct Prettifier { let linesRemoved = removeBlankLines(lines: lines, in: range) range = range.lowerBound...(range.upperBound - linesRemoved) - LinesSorter().sort(lines, in: range) { lhs, rhs in - let lhs = lhs - .removingImportKeywords() - .lowercased() - let rhs = rhs - .removingImportKeywords() - .lowercased() - - return lhs < rhs - } - + LinesSorter().sort(lines, in: range, by: <) + removeDuplicates(from: lines, in: range) } @@ -65,11 +56,3 @@ struct Prettifier { .forEach(lines.removeObject(at:)) } } - -extension StringProtocol { - func removingImportKeywords() -> String { - replacingOccurrences(of: "@preconcurrency", with: "") - .replacingOccurrences(of: "@testable", with: "") - .replacingOccurrences(of: "import", with: "") - } -}