Skip to content

Commit e38ba1c

Browse files
committed
Removing dependency on Obj-C code.
1 parent e109870 commit e38ba1c

16 files changed

+161
-280
lines changed

FilestackSDK.xcodeproj/project.pbxproj

-30
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@
156156
45825CA02524E38C002F3310 /* Startable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45825C132524E389002F3310 /* Startable.swift */; };
157157
45825CA12524E38C002F3310 /* Cancellable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45825C142524E389002F3310 /* Cancellable.swift */; };
158158
45825CA22524E38C002F3310 /* DeferredAdd.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45825C152524E389002F3310 /* DeferredAdd.swift */; };
159-
4586F1802524EFF5008F282E /* FSPolicyCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 45825C1C2524E389002F3310 /* FSPolicyCall.h */; settings = {ATTRIBUTES = (Public, ); }; };
160-
4586F1842524EFF8008F282E /* FSMetadataOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 45825C1D2524E389002F3310 /* FSMetadataOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
161-
4586F1882524EFFC008F282E /* FSTransformPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 45825C1E2524E389002F3310 /* FSTransformPosition.h */; settings = {ATTRIBUTES = (Public, ); }; };
162159
4586F19E2524F1CF008F282E /* FilestackSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 4586F1652524EEB8008F282E /* FilestackSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
163160
4586F1C42524FD7E008F282E /* Fixtures in Resources */ = {isa = PBXBuildFile; fileRef = 4586F1C32524FD7E008F282E /* Fixtures */; };
164161
4591004A25C1A3DF008187F5 /* URLSession+filestackDefault.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4591004925C1A3DF008187F5 /* URLSession+filestackDefault.swift */; };
@@ -310,10 +307,6 @@
310307
45825C142524E389002F3310 /* Cancellable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cancellable.swift; sourceTree = "<group>"; };
311308
45825C152524E389002F3310 /* DeferredAdd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeferredAdd.swift; sourceTree = "<group>"; };
312309
45825C172524E389002F3310 /* VERSION */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VERSION; sourceTree = "<group>"; };
313-
45825C1C2524E389002F3310 /* FSPolicyCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSPolicyCall.h; sourceTree = "<group>"; };
314-
45825C1D2524E389002F3310 /* FSMetadataOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSMetadataOptions.h; sourceTree = "<group>"; };
315-
45825C1E2524E389002F3310 /* FSTransformPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSTransformPosition.h; sourceTree = "<group>"; };
316-
45825C202524E389002F3310 /* ObjcDefs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjcDefs.m; sourceTree = "<group>"; };
317310
4586F1652524EEB8008F282E /* FilestackSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FilestackSDK.h; sourceTree = "<group>"; };
318311
4586F1C32524FD7E008F282E /* Fixtures */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Fixtures; sourceTree = "<group>"; };
319312
4591004925C1A3DF008187F5 /* URLSession+filestackDefault.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URLSession+filestackDefault.swift"; sourceTree = "<group>"; };
@@ -367,7 +360,6 @@
367360
isa = PBXGroup;
368361
children = (
369362
45825B852524E389002F3310 /* FilestackSDK */,
370-
45825C1A2524E389002F3310 /* ObjcDefs */,
371363
);
372364
path = Sources;
373365
sourceTree = "<group>";
@@ -625,25 +617,6 @@
625617
path = Protocols;
626618
sourceTree = "<group>";
627619
};
628-
45825C1A2524E389002F3310 /* ObjcDefs */ = {
629-
isa = PBXGroup;
630-
children = (
631-
45825C1B2524E389002F3310 /* include */,
632-
45825C202524E389002F3310 /* ObjcDefs.m */,
633-
);
634-
path = ObjcDefs;
635-
sourceTree = "<group>";
636-
};
637-
45825C1B2524E389002F3310 /* include */ = {
638-
isa = PBXGroup;
639-
children = (
640-
45825C1D2524E389002F3310 /* FSMetadataOptions.h */,
641-
45825C1C2524E389002F3310 /* FSPolicyCall.h */,
642-
45825C1E2524E389002F3310 /* FSTransformPosition.h */,
643-
);
644-
path = include;
645-
sourceTree = "<group>";
646-
};
647620
OBJ_162 /* Tests */ = {
648621
isa = PBXGroup;
649622
children = (
@@ -705,9 +678,6 @@
705678
buildActionMask = 2147483647;
706679
files = (
707680
4586F19E2524F1CF008F282E /* FilestackSDK.h in Headers */,
708-
4586F1802524EFF5008F282E /* FSPolicyCall.h in Headers */,
709-
4586F1882524EFFC008F282E /* FSTransformPosition.h in Headers */,
710-
4586F1842524EFF8008F282E /* FSMetadataOptions.h in Headers */,
711681
);
712682
runOnlyForDeploymentPostprocessing = 0;
713683
};

Package.resolved

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"repositoryURL": "https://github.com/AliSoftware/OHHTTPStubs.git",
77
"state": {
88
"branch": null,
9-
"revision": "e92b5a5746ef16add2a1424f1fc19529d9a75cde",
10-
"version": "9.0.0"
9+
"revision": "12f19662426d0434d6c330c6974d53e2eb10ecd9",
10+
"version": "9.1.0"
1111
}
1212
}
1313
]

Package.swift

+1-10
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,18 @@ let package = Package(
1212
type: .dynamic,
1313
targets: ["FilestackSDK"]
1414
),
15-
.library(
16-
name: "ObjcDefs",
17-
type: .dynamic,
18-
targets: ["ObjcDefs"]
19-
),
2015
],
2116
dependencies: [
2217
.package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", .upToNextMajor(from: Version(9, 0, 0)))
2318
],
2419
targets: [
2520
.target(
2621
name: "FilestackSDK",
27-
dependencies: ["ObjcDefs"],
22+
dependencies: [],
2823
resources: [
2924
.copy("VERSION")
3025
]
3126
),
32-
.target(
33-
name: "ObjcDefs",
34-
dependencies: []
35-
),
3627
.testTarget(
3728
name: "FilestackSDKTests",
3829
dependencies: [

Sources/FilestackSDK/FilestackSDK.h

-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ FOUNDATION_EXPORT double FilestackSDKVersionNumber;
1515
FOUNDATION_EXPORT const unsigned char FilestackSDKVersionString[];
1616

1717
// In this header, you should import all the public headers of your framework using statements like #import <FilestackSDK/PublicHeader.h>
18-
#import <FilestackSDK/FSPolicyCall.h>
19-
#import <FilestackSDK/FSMetadataOptions.h>
20-
#import <FilestackSDK/FSTransformPosition.h>

Sources/FilestackSDK/Public/Enums/MetadataOptions.swift

+81-21
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,75 @@
99
import Foundation
1010

1111
/// Represents a metadata option.
12-
public typealias MetadataOptions = FSMetadataOptions
12+
public struct MetadataOptions: OptionSet {
13+
/// Size
14+
static let size = MetadataOptions(rawValue: 1 << 0)
15+
16+
/// MIME Type
17+
static let mimeType = MetadataOptions(rawValue: 1 << 1)
18+
19+
/// Filename
20+
static let fileName = MetadataOptions(rawValue: 1 << 2)
21+
22+
/// Width
23+
static let width = MetadataOptions(rawValue: 1 << 3)
24+
25+
/// Height
26+
static let height = MetadataOptions(rawValue: 1 << 4)
27+
28+
/// Uploaded
29+
static let uploaded = MetadataOptions(rawValue: 1 << 5)
30+
31+
/// Writeable
32+
static let writeable = MetadataOptions(rawValue: 1 << 6)
33+
34+
/// Cloud
35+
static let cloud = MetadataOptions(rawValue: 1 << 7)
36+
37+
/// Source URL
38+
static let sourceURL = MetadataOptions(rawValue: 1 << 8)
39+
40+
/// MD5
41+
static let MD5 = MetadataOptions(rawValue: 1 << 9)
42+
43+
/// SHA224
44+
static let SHA224 = MetadataOptions(rawValue: 1 << 10)
45+
46+
/// SHA256
47+
static let SHA256 = MetadataOptions(rawValue: 1 << 11)
48+
49+
/// SHA384
50+
static let SHA384 = MetadataOptions(rawValue: 1 << 12)
51+
52+
/// SHA512
53+
static let SHA512 = MetadataOptions(rawValue: 1 << 13)
54+
55+
/// Location
56+
static let location = MetadataOptions(rawValue: 1 << 14)
57+
58+
/// Path
59+
static let path = MetadataOptions(rawValue: 1 << 15)
60+
61+
/// Container
62+
static let container = MetadataOptions(rawValue: 1 << 16)
63+
64+
/// Exif
65+
static let exif = MetadataOptions(rawValue: 1 << 17)
66+
67+
public let rawValue: Int
68+
69+
public init(rawValue: Int) {
70+
self.rawValue = rawValue
71+
}
72+
}
1373

1474
// MARK: - Internal Functions
1575

1676
extension MetadataOptions {
1777
static func all() -> [MetadataOptions] {
1878
return [
1979
.size, .mimeType, .fileName, .width, .height, .uploaded, .writeable, .cloud,.sourceURL, .MD5, .SHA224,
20-
.SHA256, .SHA384, .SHA512, .location, .path,.container, .exif,
80+
.SHA256, .SHA384, .SHA512, .location, .path, .container, .exif,
2181
]
2282
}
2383

@@ -37,25 +97,25 @@ extension MetadataOptions {
3797
private extension MetadataOptions {
3898
func stringValue() -> String? {
3999
switch self {
40-
case MetadataOptions.size: return "size"
41-
case MetadataOptions.mimeType:return "mimetype"
42-
case MetadataOptions.fileName:return "filename"
43-
case MetadataOptions.width:return "width"
44-
case MetadataOptions.height:return "height"
45-
case MetadataOptions.uploaded:return "uploaded"
46-
case MetadataOptions.writeable:return "writeable"
47-
case MetadataOptions.cloud:return "cloud"
48-
case MetadataOptions.sourceURL:return "source_url"
49-
case MetadataOptions.MD5:return "md5"
50-
case MetadataOptions.SHA224:return "sha224"
51-
case MetadataOptions.SHA256:return "sha256"
52-
case MetadataOptions.SHA384:return "sha384"
53-
case MetadataOptions.SHA512:return "sha512"
54-
case MetadataOptions.location:return "location"
55-
case MetadataOptions.path:return "path"
56-
case MetadataOptions.container:return "container"
57-
case MetadataOptions.exif:return "exif"
58-
default:return nil
100+
case .size: return "size"
101+
case .mimeType: return "mimetype"
102+
case .fileName: return "filename"
103+
case .width: return "width"
104+
case .height: return "height"
105+
case .uploaded: return "uploaded"
106+
case .writeable: return "writeable"
107+
case .cloud: return "cloud"
108+
case .sourceURL: return "source_url"
109+
case .MD5: return "md5"
110+
case .SHA224: return "sha224"
111+
case .SHA256: return "sha256"
112+
case .SHA384: return "sha384"
113+
case .SHA512: return "sha512"
114+
case .location: return "location"
115+
case .path: return "path"
116+
case .container: return "container"
117+
case .exif: return "exif"
118+
default: return nil
59119
}
60120
}
61121
}

Sources/FilestackSDK/Public/Enums/PolicyCall.swift

+48-44
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,43 @@ import Foundation
1212
///
1313
/// See [Creating Policies](https://www.filestack.com/docs/security/creating-policies) for more
1414
/// information about policy calls.
15-
public typealias PolicyCall = FSPolicyCall
15+
public struct PolicyCall: OptionSet {
16+
/// Allows users to upload files.
17+
static let pick = PolicyCall(rawValue: 1 << 0)
18+
19+
/// Allows files to be viewed/accessed.
20+
static let read = PolicyCall(rawValue: 1 << 1)
21+
22+
/// Allows metadata about files to be retrieved.
23+
static let stat = PolicyCall(rawValue: 1 << 2)
24+
25+
/// Allows use of the write function.
26+
static let write = PolicyCall(rawValue: 1 << 3)
27+
28+
/// Allows use of the writeUrl function.
29+
static let writeURL = PolicyCall(rawValue: 1 << 4)
30+
31+
/// Allows files to be written to custom storage.
32+
static let store = PolicyCall(rawValue: 1 << 5)
33+
34+
/// Allows transformation (crop, resize, rotate) of files, also needed for the viewer.
35+
static let convert = PolicyCall(rawValue: 1 << 6)
36+
37+
/// Allows removal of Filestack files.
38+
static let remove = PolicyCall(rawValue: 1 << 7)
39+
40+
/// Allows exif metadata to be accessed.
41+
static let exif = PolicyCall(rawValue: 1 << 8)
42+
43+
/// Allows workflows to be run.
44+
static let runWorkflow = PolicyCall(rawValue: 1 << 9)
45+
46+
public let rawValue: Int
47+
48+
public init(rawValue: Int) {
49+
self.rawValue = rawValue
50+
}
51+
}
1652

1753
// MARK: - Internal Functions
1854

@@ -38,49 +74,17 @@ extension PolicyCall {
3874
private extension PolicyCall {
3975
func stringValue() -> String? {
4076
switch self {
41-
case PolicyCall.pick:
42-
43-
return "pick"
44-
45-
case PolicyCall.read:
46-
47-
return "read"
48-
49-
case PolicyCall.stat:
50-
51-
return "stat"
52-
53-
case PolicyCall.write:
54-
55-
return "write"
56-
57-
case PolicyCall.writeURL:
58-
59-
return "write_url"
60-
61-
case PolicyCall.store:
62-
63-
return "store"
64-
65-
case PolicyCall.convert:
66-
67-
return "convert"
68-
69-
case PolicyCall.remove:
70-
71-
return "remove"
72-
73-
case PolicyCall.exif:
74-
75-
return "exif"
76-
77-
case PolicyCall.runWorkflow:
78-
79-
return "runWorkflow"
80-
81-
default:
82-
83-
return nil
77+
case .pick: return "pick"
78+
case .read: return "read"
79+
case .stat: return "stat"
80+
case .write: return "write"
81+
case .writeURL: return "write_url"
82+
case .store: return "store"
83+
case .convert: return "convert"
84+
case .remove: return "remove"
85+
case .exif: return "exif"
86+
case .runWorkflow: return "runWorkflow"
87+
default: return nil
8488
}
8589
}
8690
}

Sources/FilestackSDK/Public/Enums/TransformPosition.swift

+25-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,31 @@ import Foundation
1010
import UIKit
1111

1212
/// Represents an image transform position type.
13-
public typealias TransformPosition = FSTransformPosition
13+
public struct TransformPosition: OptionSet {
14+
/// Top
15+
static let top = TransformPosition(rawValue: 1 << 0)
16+
17+
/// Middle
18+
static let middle = TransformPosition(rawValue: 1 << 1)
19+
20+
/// Bottom
21+
static let bottom = TransformPosition(rawValue: 1 << 2)
22+
23+
/// Left
24+
static let left = TransformPosition(rawValue: 1 << 3)
25+
26+
/// Center
27+
static let center = TransformPosition(rawValue: 1 << 4)
28+
29+
/// Right
30+
static let right = TransformPosition(rawValue: 1 << 5)
31+
32+
public let rawValue: Int
33+
34+
public init(rawValue: Int) {
35+
self.rawValue = rawValue
36+
}
37+
}
1438

1539
// MARK: - Public Functions
1640

Sources/FilestackSDK/Public/Models/FileLink.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public extension FileLink {
127127
/// - Parameter options: The options that should be included as part of the response.
128128
/// - Parameter queue: The queue on which the completion handler is dispatched.
129129
/// - Parameter completionHandler: Adds a handler to be called once the request has finished.
130-
@objc func getMetadata(options: MetadataOptions,
130+
func getMetadata(options: MetadataOptions,
131131
queue: DispatchQueue? = .main,
132132
completionHandler: @escaping (JSONResponse) -> Void) {
133133
let optionQueryItems = options.toArray().map {

Sources/FilestackSDK/Public/Models/Policy.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class Policy: NSObject {
7272
}
7373

7474
/// Convenience initializer with expiry time and call permissions.
75-
@objc public convenience init(expiry: Date, call: PolicyCall) {
75+
public convenience init(expiry: Date, call: PolicyCall) {
7676
self.init(expiry: expiry,
7777
call: call,
7878
handle: nil,

0 commit comments

Comments
 (0)