Skip to content

Commit

Permalink
Refactor and add option pbxproj
Browse files Browse the repository at this point in the history
  • Loading branch information
ldakhoa committed Sep 1, 2023
1 parent 9c9979e commit 4897373
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions App/Resources/FengNiao.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
4 changes: 4 additions & 0 deletions App/fengniao.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"macOS/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
Expand Down Expand Up @@ -336,6 +338,8 @@
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"macOS/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
Expand Down
3 changes: 2 additions & 1 deletion App/macOS/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ struct AppView: View {
ToggleState(fileExtension: "swift", isOn: true),
ToggleState(fileExtension: "xib", isOn: true),
ToggleState(fileExtension: "storyboard", isOn: true),
ToggleState(fileExtension: "plist", isOn: true)
ToggleState(fileExtension: "plist", isOn: true),
ToggleState(fileExtension: "pbxproj", isOn: true)
]

// MARK: - View
Expand Down
2 changes: 1 addition & 1 deletion App/macOS/AppViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class AppViewModel: ObservableObject {
contentState == .loading
}

private let queue = DispatchQueue(label: "com.ldakhoa.ResourcePurgeX", attributes: .concurrent)
private let queue = DispatchQueue(label: "com.onevcat.fengniao", attributes: .concurrent)

func fetchUnusedFiles(
from path: String,
Expand Down
5 changes: 3 additions & 2 deletions App/macOS/DeleteViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ final class DeleteStatusViewModel: ObservableObject {
queue.async {
let (deleted, failed) = FengNiao.delete(self.unusedFilesToDelete)

// FengNiaoKit doesn't public functions to calculate the exact download percentage,
// so using this hack to make progress continually running
self.cancellable = self.timer.sink { [weak self] _ in
DispatchQueue.main.async {
guard let self else { return }
Expand Down Expand Up @@ -56,8 +58,7 @@ final class DeleteStatusViewModel: ObservableObject {
self.consoleStatus += content
}

let projectPath = Path(self.projectPath)
if let children = try? projectPath.absolute().children() {
if let children = try? Path(self.projectPath).absolute().children() {
DispatchQueue.main.async {
self.consoleStatus += "\nNow deleting unused reference in project.pbxproj..."
}
Expand Down
7 changes: 2 additions & 5 deletions Sources/FengNiaoKit/FengNiao.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public struct FengNiao {
}

// Return a failed list of deleting
static public func delete(_ unusedFiles: [FileInfo]) -> (deleted: [FileInfo], failed :[(FileInfo, Error)]) {
static public func delete(_ unusedFiles: [FileInfo]) -> (deleted: [FileInfo], failed: [(FileInfo, Error)]) {
var deleted = [FileInfo]()
var failed = [(FileInfo, Error)]()
for file in unusedFiles {
Expand Down Expand Up @@ -192,7 +192,7 @@ public struct FengNiao {
// Skip the folders which suffix with a non-folder extension.
// eg: We need to skip a folder with such name: /myfolder.png/ (although we should blame the one who named it)
let filePath = Path(file)
if let ext = filePath.extension, filePath.isDirectory && nonDirExtensions.contains(ext) {
if let ext = filePath.extension, filePath.isDirectory && nonDirExtensions.contains(ext) {
continue
}

Expand Down Expand Up @@ -301,6 +301,3 @@ extension String {
}
}
}



1 change: 0 additions & 1 deletion Sources/FengNiaoKit/FileSearchRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@ struct PbxprojImageSearchRule: RegPatternSearchRule {
let extensions: [String]
let patterns = ["ASSETCATALOG_COMPILER_APPICON_NAME = \"?(.*?)\"?;", "ASSETCATALOG_COMPILER_COMPLICATION_NAME = \"?(.*?)\"?;"]
}

0 comments on commit 4897373

Please sign in to comment.