diff --git a/Package.swift b/Package.swift index 725a98d..9a158da 100644 --- a/Package.swift +++ b/Package.swift @@ -23,7 +23,7 @@ let package = Package( name: "OptableSDK", dependencies: [], path: "Source", - exclude: ["Info.plist"]), + exclude: ["Info.plist", "Public/ObjCSupport"]), .testTarget( name: "OptableSDKTests", dependencies: ["OptableSDK"], diff --git a/Source/OptableSDK.swift b/Source/OptableSDK.swift index 1b40b5a..5ea6aeb 100644 --- a/Source/OptableSDK.swift +++ b/Source/OptableSDK.swift @@ -111,25 +111,6 @@ public extension OptableSDK { } }) } - - // MARK: Objective-C support - /** - This is the Objective-C compatible version of the `identify(ids, completion)` API. - - Instead of completion callbacks, delegate methods are called. - */ - @objc - func identify(_ ids: [OptableSDKIdentifier]) throws { - let bridgedIds = ids.compactMap({ OptableIdentifier(objc: $0) }) - try self._identify(bridgedIds) { result in - switch result { - case let .success(response): - self.delegate?.identifyOk(response) - case let .failure(error as NSError): - self.delegate?.identifyErr(error) - } - } - } } // MARK: - Targeting @@ -177,25 +158,6 @@ public extension OptableSDK { } }) } - - // MARK: Objective-C support - /** - This is the Objective-C compatible version of the `targeting(completion)` API. - - Instead of completion callbacks, delegate methods are called. - */ - @objc - func targeting(_ ids: [OptableSDKIdentifier]) throws { - let bridgedIds = ids.compactMap({ OptableIdentifier(objc: $0) }) - try self._targeting(ids: bridgedIds, completion: { result in - switch result { - case let .success(optableTargeting): - self.delegate?.targetingOk(optableTargeting) - case let .failure(error as NSError): - self.delegate?.targetingErr(error) - } - }) - } } // MARK: - Witness diff --git a/Source/Public/ObjCSupport/OptableSDK+ObjC.swift b/Source/Public/ObjCSupport/OptableSDK+ObjC.swift new file mode 100644 index 0000000..5665f35 --- /dev/null +++ b/Source/Public/ObjCSupport/OptableSDK+ObjC.swift @@ -0,0 +1,49 @@ +// +// OptableSDK+ObjC.swift +// OptableSDK +// +// Copyright © 2026 Optable Technologies, Inc. All rights reserved. +// + +import Foundation + +// MARK: Objective-C support + +public extension OptableSDK { + + /** + This is the Objective-C compatible version of the `identify(ids, completion)` API. + + Instead of completion callbacks, delegate methods are called. + */ + @objc + func identify(_ ids: [OptableSDKIdentifier]) throws { + let bridgedIds = ids.compactMap({ OptableIdentifier(objc: $0) }) + try self._identify(bridgedIds) { result in + switch result { + case let .success(response): + self.delegate?.identifyOk(response) + case let .failure(error as NSError): + self.delegate?.identifyErr(error) + } + } + } + + /** + This is the Objective-C compatible version of the `targeting(completion)` API. + + Instead of completion callbacks, delegate methods are called. + */ + @objc + func targeting(_ ids: [OptableSDKIdentifier]) throws { + let bridgedIds = ids.compactMap({ OptableIdentifier(objc: $0) }) + try self._targeting(ids: bridgedIds, completion: { result in + switch result { + case let .success(optableTargeting): + self.delegate?.targetingOk(optableTargeting) + case let .failure(error as NSError): + self.delegate?.targetingErr(error) + } + }) + } +}