Skip to content

Commit 8534975

Browse files
committed
Migrate to SwiftVBKit
1 parent 797c01b commit 8534975

3 files changed

Lines changed: 25 additions & 73 deletions

File tree

Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ let package = Package(
1818
name: "SwiftNEW",
1919
targets: ["SwiftNEW"]),
2020
],
21-
dependencies: [],
21+
dependencies: [
22+
.package(url: "https://github.com/1998code/SwiftVBKit.git", .upToNextMinor(from: "1.1.2")),
23+
],
2224
targets: [
2325
.target(
2426
name: "SwiftNEW",

Sources/SwiftNEW/SwiftNEW.swift

Lines changed: 6 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44

55
import SwiftUI
6+
import SwiftVBKit
67

78
@available(iOS 14, watchOS 7.0, macOS 11.0, *)
89
public struct SwiftNEW: View {
@@ -48,21 +49,15 @@ public struct SwiftNEW: View {
4849
VStack(alignment: align) {
4950
Spacer()
5051
Text("What's New?").bold().font(.largeTitle)
51-
#if os(iOS)
52-
Text("Version \(UIApplication.versionBuild)")
52+
Text("Version \(Bundle.versionBuild)")
5353
.bold().font(.title).foregroundColor(.secondary)
54-
#elseif os(macOS)
55-
Text("Version \(NSApplication.versionBuild)")
56-
.bold().font(.title).foregroundColor(.secondary)
57-
#endif
5854
Spacer()
5955
if loading {
6056
ProgressView()
6157
} else {
6258
ScrollView {
6359
ForEach(items, id: \.self) { item in
64-
#if os(iOS)
65-
if item.version == UIApplication.version {
60+
if item.version == Bundle.version {
6661
ForEach(item.new, id: \.self) { new in
6762
HStack {
6863
ZStack {
@@ -82,28 +77,6 @@ public struct SwiftNEW: View {
8277
}.padding(.bottom)
8378
}
8479
}
85-
#elseif os(macOS)
86-
if item.version == NSApplication.version {
87-
ForEach(item.new, id: \.self) { new in
88-
HStack {
89-
ZStack {
90-
color
91-
Image(systemName: new.icon)
92-
.foregroundColor(.white)
93-
}
94-
.frame(width: 50, height:50)
95-
.cornerRadius(15)
96-
.padding(.trailing)
97-
VStack(alignment: .leading) {
98-
Text(new.title).font(.headline).lineLimit(1)
99-
Text(new.subtitle).font(.subheadline).foregroundColor(.secondary).lineLimit(1)
100-
Text(new.body).font(.caption).foregroundColor(.secondary).lineLimit(2)
101-
}
102-
Spacer()
103-
}.padding(.bottom)
104-
}
105-
}
106-
#endif
10780
}
10881
}.frame(width: 300, height: 450)
10982
}
@@ -130,27 +103,15 @@ public struct SwiftNEW: View {
130103
}
131104

132105
public func compareVersion() {
133-
#if os(iOS)
134-
if Double(UIApplication.version)! > version || Double(UIApplication.build)! > build {
106+
if Double(Bundle.version)! > version || Double(Bundle.build)! > build {
135107
withAnimation {
136108
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
137109
show = true
138110
}
139-
version = Double(UIApplication.version)!
140-
build = Double(UIApplication.build)!
111+
version = Double(Bundle.version)!
112+
build = Double(Bundle.build)!
141113
}
142114
}
143-
#elseif os(macOS)
144-
if Double(NSApplication.version)! > version || Double(NSApplication.build)! > build {
145-
withAnimation {
146-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
147-
show = true
148-
}
149-
version = Double(NSApplication.version)!
150-
build = Double(NSApplication.build)!
151-
}
152-
}
153-
#endif
154115
}
155116
public func loadData() {
156117
// MARK :- Local Data
@@ -167,33 +128,6 @@ public struct SwiftNEW: View {
167128
}
168129
}
169130

170-
// MARK: - Find Version
171-
#if os(iOS)
172-
public extension UIApplication {
173-
static var version: String {
174-
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String? ?? "1.0"
175-
}
176-
static var build: String {
177-
return Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String? ?? "1"
178-
}
179-
static var versionBuild: String {
180-
return "\(version) (\(build))"
181-
}
182-
}
183-
#elseif os(macOS)
184-
public extension NSApplication {
185-
static var version: String {
186-
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String? ?? "1.0"
187-
}
188-
static var build: String {
189-
return Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String? ?? "1"
190-
}
191-
static var versionBuild: String {
192-
return "\(version) (\(build))"
193-
}
194-
}
195-
#endif
196-
197131
// MARK: - Model
198132
public struct Vmodel: Codable, Hashable {
199133
var version: String

0 commit comments

Comments
 (0)