Skip to content

Commit

Permalink
Remove SwiftShell from Xcode.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Nov 14, 2023
1 parent 3227856 commit 173ced6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
51 changes: 34 additions & 17 deletions src/TrueWidget/swift/WidgetSource/Xcode.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Combine
import Foundation
import SwiftShell

extension WidgetSource {
public class Xcode: ObservableObject {
Expand Down Expand Up @@ -52,22 +51,40 @@ extension WidgetSource {
let command = "/usr/bin/xcode-select"

if FileManager.default.fileExists(atPath: command) {
let fullPath = run(command, "--print-path").stdout
if fullPath.count > 0 {
var bundlePath = ""

if let range = fullPath.range(of: ".app/") {
let startIndex = fullPath.startIndex
let endIndex = fullPath.index(before: range.upperBound)
bundlePath = String(fullPath[startIndex..<endIndex])
} else {
bundlePath = fullPath
}

if bundlePath == "/Applications/Xcode.app" {
return (bundlePath, .defaultPath)
} else {
return (bundlePath, .nonDefaultPath)
let xcodeSelectCommand = Process()
xcodeSelectCommand.launchPath = command
xcodeSelectCommand.arguments = [
"--print-path"
]

xcodeSelectCommand.environment = [
"LC_ALL": "C"
]

let pipe = Pipe()
xcodeSelectCommand.standardOutput = pipe

xcodeSelectCommand.launch()
xcodeSelectCommand.waitUntilExit()

if let data = try? pipe.fileHandleForReading.readToEnd() {
let fullPath = String(decoding: data, as: UTF8.self)
if fullPath.count > 0 {
var bundlePath = ""

if let range = fullPath.range(of: ".app/") {
let startIndex = fullPath.startIndex
let endIndex = fullPath.index(before: range.upperBound)
bundlePath = String(fullPath[startIndex..<endIndex])
} else {
bundlePath = fullPath
}

if bundlePath == "/Applications/Xcode.app" {
return (bundlePath, .defaultPath)
} else {
return (bundlePath, .nonDefaultPath)
}
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/project-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ packages:
Sparkle:
url: https://github.com/sparkle-project/Sparkle
from: 2.5.1
SwiftShell:
url: https://github.com/kareman/SwiftShell
from: 5.1.0

targets:
TrueWidget:
Expand All @@ -31,7 +28,6 @@ targets:
ASSETCATALOG_COMPILER_APPICON_NAME: ''
OTHER_SWIFT_FLAGS: '-warnings-as-errors'
dependencies:
- package: SwiftShell
- target: TrueWidget Helper

TrueWidget Helper:
Expand All @@ -56,5 +52,3 @@ targets:
- '@loader_path/../../../../Frameworks'
OTHER_SWIFT_FLAGS: '-warnings-as-errors'
SWIFT_OBJC_BRIDGING_HEADER: Helper/DeprecatedOpenAtLogin/objc/DeprecatedOpenAtLogin-Bridging-Header.h
dependencies:
- package: SwiftShell

0 comments on commit 173ced6

Please sign in to comment.