Skip to content

Commit 0b0cc83

Browse files
Andrey SakAndrey Sak
Andrey Sak
authored and
Andrey Sak
committed
Reduced SDK size
1 parent f7e5445 commit 0b0cc83

8 files changed

+135
-124
lines changed

Example/Example.xcodeproj/project.pbxproj

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
70113E7129C1D01800CBA08B /* VideoEditorModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70113E7029C1D01800CBA08B /* VideoEditorModule.swift */; };
2020
8A32EED0258CB5430098F852 /* bundleEffects in Resources */ = {isa = PBXBuildFile; fileRef = 8A32EECF258CB5430098F852 /* bundleEffects */; };
2121
8A32EEDF258CB70C0098F852 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8A32EEDE258CB70C0098F852 /* Assets.xcassets */; };
22+
DBF5B72E2CC271D900F2FDF2 /* ExternalResourcesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF5B72D2CC271CC00F2FDF2 /* ExternalResourcesManager.swift */; };
23+
DBF5B7572CC28E8000F2FDF2 /* bnb-resources.zip in Resources */ = {isa = PBXBuildFile; fileRef = DBF5B7562CC28E8000F2FDF2 /* bnb-resources.zip */; };
2224
/* End PBXBuildFile section */
2325

2426
/* Begin PBXFileReference section */
@@ -41,6 +43,8 @@
4143
8AFC95CF269DC12D00B4114B /* BNBLicenseUtils.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = BNBLicenseUtils.xcframework; sourceTree = "<group>"; };
4244
8D879ADE024EEEC9574AAB2D /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
4345
A24378930003F0F910117502 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
46+
DBF5B72D2CC271CC00F2FDF2 /* ExternalResourcesManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalResourcesManager.swift; sourceTree = "<group>"; };
47+
DBF5B7562CC28E8000F2FDF2 /* bnb-resources.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "bnb-resources.zip"; sourceTree = "<group>"; };
4448
/* End PBXFileReference section */
4549

4650
/* Begin PBXFrameworksBuildPhase section */
@@ -102,6 +106,8 @@
102106
70113E7029C1D01800CBA08B /* VideoEditorModule.swift */,
103107
636C55232B0DF24100678849 /* PhotoEditorModule.swift */,
104108
639DA00F254700290011C153 /* ViewController.swift */,
109+
DBF5B7562CC28E8000F2FDF2 /* bnb-resources.zip */,
110+
DBF5B72D2CC271CC00F2FDF2 /* ExternalResourcesManager.swift */,
105111
63F7115F29D1F21A00045A06 /* short_music_20.wav */,
106112
634FAC06255C351900FB0DBC /* Localizable.strings */,
107113
639DA011254700290011C153 /* Main.storyboard */,
@@ -176,6 +182,7 @@
176182
634FAC04255C351900FB0DBC /* Localizable.strings in Resources */,
177183
639DA0182547002C0011C153 /* LaunchScreen.storyboard in Resources */,
178184
635DB1AC2548541000B1C799 /* luts in Resources */,
185+
DBF5B7572CC28E8000F2FDF2 /* bnb-resources.zip in Resources */,
179186
639DA013254700290011C153 /* Main.storyboard in Resources */,
180187
8A32EEDF258CB70C0098F852 /* Assets.xcassets in Resources */,
181188
8A32EED0258CB5430098F852 /* bundleEffects in Resources */,
@@ -249,6 +256,7 @@
249256
buildActionMask = 2147483647;
250257
files = (
251258
639DA010254700290011C153 /* ViewController.swift in Sources */,
259+
DBF5B72E2CC271D900F2FDF2 /* ExternalResourcesManager.swift in Sources */,
252260
636C55242B0DF24100678849 /* PhotoEditorModule.swift in Sources */,
253261
70113E7129C1D01800CBA08B /* VideoEditorModule.swift in Sources */,
254262
639DA00C254700290011C153 /* AppDelegate.swift in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// ExternalResourcesManager.swift
3+
// Example
4+
//
5+
// Created by Andrey Sak on 18.10.24.
6+
//
7+
8+
import BNBSdkCore
9+
import BanubaUtilities
10+
11+
class ExternalResourcesManager {
12+
13+
static let shared = ExternalResourcesManager()
14+
15+
private init() {}
16+
17+
let fileManager = FileManager.default
18+
19+
var resourcesBundleLocalURL: URL {
20+
let applicationSupportRoot = fileManager.urls(
21+
for: .applicationSupportDirectory,
22+
in: .userDomainMask
23+
).last!
24+
return applicationSupportRoot.appendingPathComponent("bnb-resources", isDirectory: true)
25+
}
26+
27+
func prepareResources() {
28+
guard let zipURL = Bundle.main.url(forResource: "bnb-resources", withExtension: "zip") else {
29+
print("Unable to locate zip file")
30+
return
31+
}
32+
33+
if !fileManager.fileExists(atPath: resourcesBundleLocalURL.path) {
34+
35+
let isSuccess = SSZipArchive.unzipFile(
36+
atPath: zipURL.path,
37+
toDestination: resourcesBundleLocalURL.path
38+
)
39+
40+
if !isSuccess {
41+
print("Unable to unarchive zip file")
42+
return
43+
}
44+
}
45+
}
46+
}

Example/Example/PhotoEditorModule.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import BanubaPhotoEditorSDK
1+
import BanubaPhotoEditorSDKLight
2+
import BNBSdkCore
23

34
class PhotoEditorModule {
45
var photoEditorSDK: BanubaPhotoEditor?
56

67
init(token: String) {
7-
let configuration = PhotoEditorConfig()
8+
let configuration = PhotoEditorConfig(
9+
previewScreenMode: .disabled,
10+
resourcesURL: ExternalResourcesManager.shared.resourcesBundleLocalURL
11+
)
812
photoEditorSDK = BanubaPhotoEditor(
913
token: token,
1014
configuration: configuration

Example/Example/VideoEditorModule.swift

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Photos
99
import BSImagePicker
1010
import VEExportSDK
1111
import BanubaAudioBrowserSDK
12+
import BNBSdkCore
1213

1314
// Adopting CountdownView to using in BanubaVideoEditorSDK
1415
extension CountdownView: MusicEditorCountdownAnimatableView {}
@@ -27,6 +28,8 @@ class VideoEditorModule {
2728
configuration: config
2829
)
2930

31+
BNBUtilityManager.addResourcePath(ExternalResourcesManager.shared.resourcesBundleLocalURL.path)
32+
3033
self.videoEditorSDK = videoEditorSDK
3134
}
3235

Example/Example/ViewController.swift

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import UIKit
22
import BanubaVideoEditorSDK
3-
import BanubaPhotoEditorSDK
3+
import BanubaPhotoEditorSDKLight
44

55
import VideoEditor
66
import AVFoundation
@@ -25,6 +25,26 @@ class ViewController: UIViewController, BanubaVideoEditorDelegate, BanubaPhotoEd
2525
// Use “true” if you want users could restore the last video editing session.
2626
private let restoreLastVideoEditingSession: Bool = false
2727

28+
override func viewDidLoad() {
29+
super.viewDidLoad()
30+
31+
32+
let activityIndicator = UIActivityIndicatorView(style: .large)
33+
view.addSubview(activityIndicator)
34+
activityIndicator.center = view.frame.getCenter()
35+
activityIndicator.center.y = view.frame.maxY - activityIndicator.frame.height - 20
36+
activityIndicator.startAnimating()
37+
view.isUserInteractionEnabled = false
38+
39+
Task(priority: .medium) {
40+
ExternalResourcesManager.shared.prepareResources()
41+
Task { @MainActor in
42+
activityIndicator.removeFromSuperview()
43+
view.isUserInteractionEnabled = true
44+
}
45+
}
46+
}
47+
2848
// MARK: - Handle BanubaVideoEditor callbacks
2949
func videoEditorDidCancel(_ videoEditor: BanubaVideoEditor) {
3050
if restoreLastVideoEditingSession == false {
@@ -214,12 +234,12 @@ class ViewController: UIViewController, BanubaVideoEditorDelegate, BanubaPhotoEd
214234

215235
// MARK: - BanubaPhotoEditorDelegate
216236
extension ViewController {
217-
func photoEditorDidCancel(_ photoEditor: BanubaPhotoEditorSDK.BanubaPhotoEditor) {
237+
func photoEditorDidCancel(_ photoEditor: BanubaPhotoEditor) {
218238
print("User has closed the photo editor")
219239
photoEditor.dismissPhotoEditor(animated: true, completion: nil)
220240
}
221241

222-
func photoEditorDidFinishWithImage(_ photoEditor: BanubaPhotoEditorSDK.BanubaPhotoEditor, image: UIImage) {
242+
func photoEditorDidFinishWithImage(_ photoEditor: BanubaPhotoEditor, image: UIImage) {
223243
print("User has saved the edited image")
224244
photoEditor.dismissPhotoEditor(animated: true, completion: nil)
225245
}

Example/Example/bnb-resources.zip

61.9 MB
Binary file not shown.

Example/Podfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ inhibit_all_warnings!
88

99
target 'Example' do
1010

11-
banuba_sdk_version = '1.37.1'
11+
banuba_sdk_version = '1.38.0'
1212

1313
# Video Editor
1414

1515
pod 'BanubaARCloudSDK', banuba_sdk_version #optional
1616
pod 'BanubaVideoEditorSDK', banuba_sdk_version
1717
pod 'BanubaAudioBrowserSDK', banuba_sdk_version #optional
18-
pod 'BanubaSDKSimple', banuba_sdk_version
19-
pod 'BanubaSDK', banuba_sdk_version
18+
pod 'BanubaSDKLight', banuba_sdk_version
2019
pod 'BanubaSDKServicing', banuba_sdk_version
2120
pod 'VideoEditor', banuba_sdk_version
2221
pod 'BanubaUtilities', banuba_sdk_version
@@ -28,10 +27,11 @@ target 'Example' do
2827
pod 'VEExportSDK', banuba_sdk_version
2928
pod 'VEEffectsSDK', banuba_sdk_version
3029
pod 'VEPlaybackSDK', banuba_sdk_version
30+
3131

3232
pod "BSImagePicker"
3333

3434
# Photo Editor
3535

36-
pod 'BanubaPhotoEditorSDK', '1.2.3'
36+
pod 'BanubaPhotoEditorSDKLight', '1.2.4'
3737
end

0 commit comments

Comments
 (0)