Skip to content

Commit

Permalink
Update inheritance, visibility, objc compatibility (#766)
Browse files Browse the repository at this point in the history
* initial work

* Update inheritance, visibility, objc compatibility

Also fix file headers.
resolves #763

* Update for comments

:rocket:
  • Loading branch information
taquitos authored Aug 24, 2021
1 parent cf555aa commit 3541071
Show file tree
Hide file tree
Showing 90 changed files with 1,090 additions and 646 deletions.
10 changes: 1 addition & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ import class Foundation.ProcessInfo

func resolveTargets() -> [Target] {
let objcSources = ["Purchases/Info.plist",
"Purchases/Attribution",
"Purchases/Caching",
"Purchases/FoundationExtensions",
"Purchases/Networking",
"Purchases/Public",
"Purchases/ProtectedExtensions",
"Purchases/SubscriberAttributes",
"Purchases/SwiftObjcCompatibility",
"Purchases/Identity"]
"Purchases/Public"]
let infoPlist = "Purchases/Info.plist"

let baseTargets: [Target] = [
Expand Down
12 changes: 9 additions & 3 deletions PublicSDKAPITester/RCOfferingAPI.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// RCOfferingAPI.m
// APITester
//
// Created by Joshua Liebowitz on 7/9/21.
// Copyright © 2021 Purchases. All rights reserved.
//

@import PurchasesCoreSwift;
Expand All @@ -12,7 +18,7 @@
@implementation RCOfferingAPI

+ (void)checkAPI {
RCOffering *o = [[RCOffering alloc] initWithIdentifier:@"" serverDescription:@"" availablePackages:@[]];
RCOffering *o = nil; // No public initializer.
NSString *i = o.identifier;
NSString *sd = o.serverDescription;
NSArray<RCPackage *> *a = o.availablePackages;
Expand Down
2 changes: 1 addition & 1 deletion Purchases.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@
F5E4383626B852D700841CC8 /* StoreKitExtensions */,
354895D0267AE32D001DC5B1 /* SubscriberAttributes */,
B39E811B268E885900D31189 /* SubscriberAttributes */,
37E355CBB3F3A31A32687B14 /* Transaction.swift */,
);
path = PurchasesCoreSwift;
sourceTree = "<group>";
Expand Down Expand Up @@ -1139,6 +1138,7 @@
A56F9AB026990E9200AFC48F /* PurchaserInfo.swift */,
B35042C326CDB79A00905B95 /* Purchases.swift */,
B35042C526CDD3B100905B95 /* PurchasesDelegate.swift */,
37E355CBB3F3A31A32687B14 /* Transaction.swift */,
);
path = Public;
sourceTree = "<group>";
Expand Down
8 changes: 3 additions & 5 deletions PurchasesCoreSwift/Attribution/ASIdentifierManagerProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
// https://opensource.org/licenses/MIT
//
// ASIdentifierManagerProxy.swift
// PurchasesCoreSwift
//
// Created by Juanpe Catalán on 14/7/21.
// Copyright © 2021 Purchases. All rights reserved.
//

import Foundation
Expand All @@ -29,9 +27,9 @@ class FakeASIdentifierManager: NSObject {

}

// TODO (post-migration): Make all the things internal again if possible. Test if Objc can be removed.
// TODO: Test if Objc can be removed.
@objc(RCASIdentifierManagerProxy)
public class ASIdentifierManagerProxy: NSObject {
class ASIdentifierManagerProxy: NSObject {

static let mangledIdentifierClassName = "NFVqragvsvreZnantre"
static let mangledIdentifierPropertyName = "nqiregvfvatVqragvsvre"
Expand All @@ -44,7 +42,7 @@ public class ASIdentifierManagerProxy: NSObject {
NSClassFromString(Self.mangledIdentifierClassName.rot13())
}

@objc public var adsIdentifier: UUID? {
@objc var adsIdentifier: UUID? {
guard let classType: AnyClass = Self.identifierClass else {
return nil
}
Expand Down
11 changes: 4 additions & 7 deletions PurchasesCoreSwift/Attribution/AdClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
// https://opensource.org/licenses/MIT
//
// AdClientProxy.swift
// PurchasesCoreSwift
//
// Created by Juanpe Catalán on 14/7/21.
// Copyright © 2021 Purchases. All rights reserved.
//

import Foundation

// TODO (post-migration): Make all the things internal again.
public typealias AttributionDetailsBlock = ([String: NSObject]?, Error?) -> Void
typealias AttributionDetailsBlock = ([String: NSObject]?, Error?) -> Void

// We need this class to avoid Kid apps being rejected for getting idfa. It seems like App
// Review uses some grep to find the class names, so we ended up creating a fake class that
Expand All @@ -38,9 +35,9 @@ class FakeAdClient: NSObject {

}

// TODO (post-migration): Make all the things internal again if possible. Test if Objc can be removed.
// TODO: Test if Objc can be removed.
@objc(RCAdClientProxy)
public class AdClientProxy: NSObject {
class AdClientProxy: NSObject {

private static let className = "ADClient"

Expand All @@ -49,7 +46,7 @@ public class AdClientProxy: NSObject {
}

@objc(requestAttributionDetailsWithBlock:)
public func requestAttributionDetails(_ completionHandler: @escaping AttributionDetailsBlock) {
func requestAttributionDetails(_ completionHandler: @escaping AttributionDetailsBlock) {
let client: AnyObject
if let klass = Self.adClientClass, let clientClass = klass as AnyObject as? NSObjectProtocol {
// This looks strange, but #selector() does fun things to create a selector. If the selector for the given
Expand Down
10 changes: 8 additions & 2 deletions PurchasesCoreSwift/Attribution/AttributionData.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// AttributionData.swift
// PurchasesCoreSwift
//
// Created by Madeline Beyl on 7/7/21.
// Copyright © 2021 Purchases. All rights reserved.
//

import Foundation
Expand Down
18 changes: 13 additions & 5 deletions PurchasesCoreSwift/Attribution/AttributionFetcher.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
//
// Created by Andrés Boedo on 4/8/21.
// Copyright (c) 2021 Purchases. All rights reserved.
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// AttributionFetcher.swift
//
// Created by Andrés Boedo on 4/8/21.
//

import Foundation
Expand All @@ -17,8 +26,7 @@ enum AttributionFetcherError: Error {

}

// TODO(post-migration): Make this internal
@objc(RCAttributionFetcher) public class AttributionFetcher: NSObject {
class AttributionFetcher {

private let attributionFactory: AttributionTypeFactory
private let systemInfo: SystemInfo
Expand All @@ -29,7 +37,7 @@ enum AttributionFetcherError: Error {
private let appTrackingTransparencyRequired = true
#endif

@objc public init(attributionFactory: AttributionTypeFactory, systemInfo: SystemInfo) {
init(attributionFactory: AttributionTypeFactory, systemInfo: SystemInfo) {
self.attributionFactory = attributionFactory
self.systemInfo = systemInfo
}
Expand Down
35 changes: 16 additions & 19 deletions PurchasesCoreSwift/Attribution/AttributionPoster.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

import Foundation

// TODO(post-migration): Make this internal
@objc(RCAttributionPoster) public class AttributionPoster: NSObject {
class AttributionPoster {

let deviceCache: DeviceCache
let identityManager: IdentityManager
Expand All @@ -24,22 +23,21 @@ import Foundation

private static var postponedAttributionData: [AttributionData]?

@objc public init(deviceCache: DeviceCache,
identityManager: IdentityManager,
backend: Backend,
attributionFetcher: AttributionFetcher,
subscriberAttributesManager: SubscriberAttributesManager) {
init(deviceCache: DeviceCache,
identityManager: IdentityManager,
backend: Backend,
attributionFetcher: AttributionFetcher,
subscriberAttributesManager: SubscriberAttributesManager) {
self.deviceCache = deviceCache
self.identityManager = identityManager
self.backend = backend
self.attributionFetcher = attributionFetcher
self.subscriberAttributesManager = subscriberAttributesManager
}

@objc(postAttributionData:fromNetwork:forNetworkUserId:)
public func post(attributionData data: [String: Any],
fromNetwork network: AttributionNetwork,
forNetworkUserId networkUserId: String?) {
func post(attributionData data: [String: Any],
fromNetwork network: AttributionNetwork,
networkUserId: String?) {
Logger.debug(Strings.attribution.instance_configured_posting_attribution)
if data["rc_appsflyer_id"] != nil {
Logger.warn(Strings.attribution.appsflyer_id_deprecated)
Expand Down Expand Up @@ -105,7 +103,7 @@ import Foundation
}
}

@objc public func postAppleSearchAdsAttributionIfNeeded() {
func postAppleSearchAdsAttributionIfNeeded() {
guard attributionFetcher.isAuthorizedToPostSearchAds else {
return
}
Expand All @@ -129,28 +127,27 @@ import Foundation
return
}

self.post(attributionData: attributionDetails, fromNetwork: .appleSearchAds, forNetworkUserId: nil)
self.post(attributionData: attributionDetails, fromNetwork: .appleSearchAds, networkUserId: nil)
}
}

@objc public func postPostponedAttributionDataIfNeeded() {
func postPostponedAttributionDataIfNeeded() {
guard let postponedAttributionData = Self.postponedAttributionData else {
return
}

for attributionData in postponedAttributionData {
post(attributionData: attributionData.data,
fromNetwork: attributionData.network,
forNetworkUserId: attributionData.networkUserId)
networkUserId: attributionData.networkUserId)
}

Self.postponedAttributionData = nil
}

@objc(storePostponedAttributionData:fromNetwork:forNetworkUserId:)
public static func store(postponedAttributionData data: [String: Any],
fromNetwork network: AttributionNetwork,
forNetworkUserId networkUserID: String?) {
static func store(postponedAttributionData data: [String: Any],
fromNetwork network: AttributionNetwork,
forNetworkUserId networkUserID: String?) {
Logger.debug(Strings.attribution.no_instance_configured_caching_attribution)

var postponedData = postponedAttributionData ?? []
Expand Down
6 changes: 1 addition & 5 deletions PurchasesCoreSwift/Attribution/AttributionTypeFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@
// https://opensource.org/licenses/MIT
//
// AttributionTypeFactory.swift
// PurchasesCoreSwift
//
// Created by Juanpe Catalán on 9/7/21.
// Copyright © 2021 Purchases. All rights reserved.
//

import Foundation

// TODO (post-migration): change back to internal.
@objc(RCAttributionTypeFactory)
public class AttributionTypeFactory: NSObject {
class AttributionTypeFactory {

func adClientProxy() -> AdClientProxy? {
return AdClientProxy.adClientClass == nil ? nil : AdClientProxy()
Expand Down
12 changes: 4 additions & 8 deletions PurchasesCoreSwift/Attribution/TrackingManagerProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
// https://opensource.org/licenses/MIT
//
// TrackingManagerProxy.swift
// PurchasesCoreSwift
//
// Created by Juanpe Catalán on 14/7/21.
// Copyright © 2021 Purchases. All rights reserved.
//

import Foundation

// TODO (post-migration): Make all the things internal again.
@objc public enum FakeTrackingManagerAuthorizationStatus: Int {
@objc enum FakeTrackingManagerAuthorizationStatus: Int {

case notDetermined = 0
case restricted
Expand All @@ -40,9 +37,8 @@ class FakeTrackingManager: NSObject {

}

// TODO (post-migration): Make all the things internal again if possible. Test if Objc can be removed.
@objc(RCTrackingManagerProxy)
public class TrackingManagerProxy: NSObject {
// TODO: Test if Objc can be removed.
@objc class TrackingManagerProxy: NSObject {

static let mangledTrackingClassName = "NGGenpxvatZnantre"
static let mangledAuthStatusPropertyName = "genpxvatNhgubevmngvbaFgnghf"
Expand All @@ -56,7 +52,7 @@ public class TrackingManagerProxy: NSObject {
NSClassFromString(mangledTrackingClassName.rot13())
}

@objc public var authorizationStatusPropertyName: String {
@objc var authorizationStatusPropertyName: String {
Self.mangledAuthStatusPropertyName.rot13()
}

Expand Down
Loading

0 comments on commit 3541071

Please sign in to comment.