Skip to content

Commit

Permalink
Merge pull request #302 from Darock-Studio/lib/zip
Browse files Browse the repository at this point in the history
feat: zipped dylib for networking
  • Loading branch information
WindowsMEMZ authored Mar 3, 2024
2 parents 7890bbf + 4d1eafd commit 59a266c
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 96 deletions.
64 changes: 12 additions & 52 deletions DarockBili.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,6 @@
8CA68EF62B93224B00870AAA /* Sources */,
8CA68EF72B93224B00870AAA /* Frameworks */,
8CA68EF82B93224B00870AAA /* CopyFiles */,
8CA638D62B93946A0041BF92 /* Code Signing */,
);
buildRules = (
);
Expand Down Expand Up @@ -1221,7 +1220,6 @@
8CE523B82B935D6100C89318 /* Sources */,
8CE523B92B935D6100C89318 /* Frameworks */,
8CE523BA2B935D6100C89318 /* CopyFiles */,
8CA638D72B9396510041BF92 /* Code Signing */,
);
buildRules = (
);
Expand Down Expand Up @@ -1415,44 +1413,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
8CA638D62B93946A0041BF92 /* Code Signing */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Code Signing";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "codesign -fs \"${EXPANDED_CODE_SIGN_IDENTITY_NAME}\" \"${BUILT_PRODUCTS_DIR}/DarockBili.dynamic.dylib\"\n";
};
8CA638D72B9396510041BF92 /* Code Signing */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Code Signing";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "codesign -fs \"${EXPANDED_CODE_SIGN_IDENTITY_NAME}\" \"${BUILT_PRODUCTS_DIR}/DarockBili.dynamic.watch.dylib\"\n";
};
8CA97C2D2B945F670008A99B /* Export Dylibs */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -1762,7 +1722,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand Down Expand Up @@ -1793,7 +1753,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand Down Expand Up @@ -1829,7 +1789,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1864,7 +1824,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1945,7 +1905,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1992,7 +1952,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2036,7 +1996,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2072,7 +2032,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2133,7 +2093,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -2166,7 +2126,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -2195,7 +2155,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand All @@ -2218,7 +2178,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 932;
CURRENT_PROJECT_VERSION = 942;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PostActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "codesign -fs &quot;${CODE_SIGN_IDENTITY}&quot; &quot;${BUILT_PRODUCTS_DIR}/DarockBili.dynamic.watch.dylib&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8CE523BB2B935D6100C89318"
BuildableName = "DarockBili.dynamic.watch.dylib"
BlueprintName = "DarockBili.dynamic.watch"
ReferencedContainer = "container:DarockBili.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PostActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PostActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "codesign -fs &quot;${CODE_SIGN_IDENTITY}&quot; &quot;${BUILT_PRODUCTS_DIR}/DarockBili.dynamic.dylib&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8CA68EF92B93224B00870AAA"
BuildableName = "DarockBili.dynamic.dylib"
BlueprintName = "DarockBili.dynamic"
ReferencedContainer = "container:DarockBili.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PostActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
3 changes: 3 additions & 0 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9164,6 +9164,9 @@
}
}
}
},
"正在安装..." : {

},
"清除所有已观看视频" : {
"extractionState" : "stale",
Expand Down
70 changes: 46 additions & 24 deletions MeowBili/DylibDownloadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,46 @@

import SwiftUI
import Alamofire
import ZipArchive

struct DylibDownloadView: View {
@Binding var statusSymbol: Bool
@State var downloadProgress = 0.0
@State var downloadedSize: Int64 = 0
@State var totalSize: Int64 = 0
@State var isUnziping = false
var body: some View {
NavigationStack {
List {
Section {
Text("正在下载资源...")
.bold()
}
Section {
VStack {
ProgressView(value: downloadProgress)
HStack {
Spacer()
Text("\(String(format: "%.2f", downloadProgress * 100) + " %")")
Spacer()
if !isUnziping {
Section {
Text("正在下载资源...")
.bold()
}
Section {
VStack {
ProgressView(value: downloadProgress)
HStack {
Spacer()
Text("\(String(format: "%.2f", downloadProgress * 100) + " %")")
Spacer()
}
HStack {
Spacer()
Text("\(String(format: "%.2f", Double(downloadedSize) / 1024 / 1024))MB / \(String(format: "%.2f", Double(totalSize) / 1024 / 1024))MB")
.font(.system(size: 16, weight: .bold))
.lineLimit(1)
.minimumScaleFactor(0.1)
Spacer()
}
}
HStack {
Spacer()
Text("\(String(format: "%.2f", Double(downloadedSize) / 1024 / 1024))MB / \(String(format: "%.2f", Double(totalSize) / 1024 / 1024))MB")
.font(.system(size: 16, weight: .bold))
.lineLimit(1)
.minimumScaleFactor(0.1)
Spacer()
}
} else {
Section {
VStack {
Text("正在安装...")
.bold()
ProgressView()
}
}
}
Expand Down Expand Up @@ -75,20 +87,20 @@ struct DylibDownloadView: View {
.onAppear {
let destination: DownloadRequest.Destination = { _, _ in
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let fileURL = documentsURL.appendingPathComponent("main.dylib")
let fileURL = documentsURL.appendingPathComponent("maind.zip")
return (fileURL, [.removePreviousFile])
}
#if targetEnvironment(simulator)
#if os(watchOS)
let link = "https://cd.darock.top:32767/meowbili/res/dylib/watchsimulator.dylib"
let link = "https://cd.darock.top:32767/meowbili/res/dylib/watchsimulator.zip"
#elseif os(iOS)
let link = "https://cd.darock.top:32767/meowbili/res/dylib/iphonesimulator.dylib"
let link = "https://cd.darock.top:32767/meowbili/res/dylib/iphonesimulator.zip"
#endif
#else
#if os(watchOS)
let link = "https://cd.darock.top:32767/meowbili/res/dylib/watchos.dylib"
let link = "https://cd.darock.top:32767/meowbili/res/dylib/watchos.zip"
#elseif os(iOS)
let link = "https://cd.darock.top:32767/meowbili/res/dylib/iphoneos.dylib"
let link = "https://cd.darock.top:32767/meowbili/res/dylib/iphoneos.zip"
#endif
#endif
DispatchQueue(label: "com.darock.DarockBili.resDownload").async {
Expand All @@ -101,7 +113,17 @@ struct DylibDownloadView: View {
.response { r in
if r.error == nil, let filePath = r.fileURL?.path {
debugPrint(filePath)
statusSymbol.toggle()
isUnziping = true
DispatchQueue(label: "com.darock.DarockBili.resUnzip", qos: .background).async {
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let fileURL = documentsURL.appendingPathComponent("main.dylib")
if FileManager.default.fileExists(atPath: fileURL.path()) {
try! FileManager.default.removeItem(atPath: fileURL.path())
}
try! SSZipArchive.unzipFile(atPath: filePath, toDestination: fileURL.path().split(separator: "/").dropLast().joined(separator: "/"), overwrite: true, password: nil)
try! FileManager.default.removeItem(atPath: filePath)
statusSymbol.toggle()
}
} else {
debugPrint(r.error as Any)
}
Expand Down
6 changes: 1 addition & 5 deletions MeowBili/InMain/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ struct MainView: View {
}
if latestLibVer != "" && latestLibVer != DKDynamic().GetDylibVersion() {
NavigationLink(destination: { SoftwareUpdateView() }, label: {
HStack {
Text("有资源包更新可用")
Spacer()
Text(">")
}
Text("有资源包更新可用")
})
}
}
Expand Down
Loading

0 comments on commit 59a266c

Please sign in to comment.