Skip to content

Commit db80e4d

Browse files
Merge pull request #360 from SourcePointUSA/SP-8654_fix_SPM_build
SP-8654 fix SPM build
2 parents 601d5bf + a9857fe commit db80e4d

File tree

91 files changed

+3806
-2434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3806
-2434
lines changed

.github/workflows/swift.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Swift
1+
name: Test
22
on:
33
workflow_dispatch:
44
push:
@@ -15,6 +15,19 @@ jobs:
1515
- uses: actions/checkout@v2
1616
- name: linting
1717
run: swiftlint lint
18+
BuildSwiftPackage:
19+
runs-on: macos-11
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Select Xcode version 13.0
23+
run: sudo xcode-select -s '/Applications/Xcode_13.0.app/Contents/Developer'
24+
- name: Building Swift Package
25+
run: xcodebuild clean build -scheme SPMBuild -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.0' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"
26+
- uses: actions/upload-artifact@v2
27+
if: failure()
28+
name: Upload ObjCExampleApp tests results
29+
with:
30+
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
1831
ObjC-ExampleApp-tests:
1932
runs-on: macos-11
2033
steps:

ConsentViewController/Classes/Constants.swift

+29-17
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,37 @@
66
//
77

88
import Foundation
9+
import UIKit
10+
11+
protocol SPUIValues {
12+
static var defaultFallbackTextColorForDarkMode: UIColor { get }
13+
}
914

1015
let prod = (Bundle.framework.object(forInfoDictionaryKey: "SPEnv") as? String) != "staging"
1116

1217
struct Constants {
13-
static let envParam = prod ? "prod" : "stage"
14-
static let SP_ROOT = URL(string: prod ? "https://cdn.privacy-mgmt.com/" : "https://cdn.sp-stage.net/")!
15-
static let WRAPPER_API = URL(string: "./wrapper/", relativeTo: SP_ROOT)!
16-
static let GDPR_MESSAGE_URL = URL(string: "./v2/message/gdpr", relativeTo: WRAPPER_API)!
17-
static let CCPA_MESSAGE_URL = URL(string: "./v2/message/ccpa", relativeTo: WRAPPER_API)!
18-
static let ERROR_METRIS_URL = URL(string: "./metrics/v1/custom-metrics", relativeTo: WRAPPER_API)!
19-
static let GET_MESSAGES_URL = URL(string: "./v2/get_messages/?env=\(envParam)", relativeTo: WRAPPER_API)!
20-
static let GDPR_CONSENT_URL = URL(string: "./v2/messages/choice/gdpr/", relativeTo: WRAPPER_API)!
21-
static let CCPA_CONSENT_URL = URL(string: "./v2/messages/choice/ccpa/", relativeTo: WRAPPER_API)!
22-
static let IDFA_RERPORT_URL = URL(string: "./metrics/v1/apple-tracking?env=\(envParam)", relativeTo: WRAPPER_API)!
23-
static let CUSTOM_CONSENT_URL = URL(string: "./tcfv2/v1/gdpr/custom-consent?env=\(envParam)&inApp=true", relativeTo: WRAPPER_API)!
24-
static let MMS_MESSAGE_URL = URL(string: "./mms/v2/message", relativeTo: SP_ROOT)!
25-
static let GDPR_PRIVACY_MANAGER_VIEW_URL = URL(string: "./consent/tcfv2/privacy-manager/privacy-manager-view", relativeTo: SP_ROOT)!
26-
static let CCPA_PRIVACY_MANAGER_VIEW_URL = URL(string: "./ccpa/privacy-manager/privacy-manager-view", relativeTo: SP_ROOT)!
27-
static let CCPA_PM_URL = URL(string: "./ccpa_pm/index.html", relativeTo: SP_ROOT)!
28-
static let GDPR_PM_URL = URL(string: "./privacy-manager/index.html", relativeTo: SP_ROOT)!
29-
static let defaultFallbackTextColorForDarkMode: UIColor = .black
18+
struct Urls {
19+
static let envParam = prod ? "prod" : "stage"
20+
static let SP_ROOT = URL(string: prod ? "https://cdn.privacy-mgmt.com/" : "https://cdn.sp-stage.net/")!
21+
static let WRAPPER_API = URL(string: "./wrapper/", relativeTo: SP_ROOT)!
22+
static let GDPR_MESSAGE_URL = URL(string: "./v2/message/gdpr", relativeTo: WRAPPER_API)!
23+
static let CCPA_MESSAGE_URL = URL(string: "./v2/message/ccpa", relativeTo: WRAPPER_API)!
24+
static let ERROR_METRIS_URL = URL(string: "./metrics/v1/custom-metrics", relativeTo: WRAPPER_API)!
25+
static let GET_MESSAGES_URL = URL(string: "./v2/get_messages/?env=\(envParam)", relativeTo: WRAPPER_API)!
26+
static let GDPR_CONSENT_URL = URL(string: "./v2/messages/choice/gdpr/", relativeTo: WRAPPER_API)!
27+
static let CCPA_CONSENT_URL = URL(string: "./v2/messages/choice/ccpa/", relativeTo: WRAPPER_API)!
28+
static let IDFA_RERPORT_URL = URL(string: "./metrics/v1/apple-tracking?env=\(envParam)", relativeTo: WRAPPER_API)!
29+
static let CUSTOM_CONSENT_URL = URL(string: "./tcfv2/v1/gdpr/custom-consent?env=\(envParam)&inApp=true", relativeTo: WRAPPER_API)!
30+
static let MMS_MESSAGE_URL = URL(string: "./mms/v2/message", relativeTo: SP_ROOT)!
31+
static let GDPR_PRIVACY_MANAGER_VIEW_URL = URL(string: "./consent/tcfv2/privacy-manager/privacy-manager-view", relativeTo: SP_ROOT)!
32+
static let CCPA_PRIVACY_MANAGER_VIEW_URL = URL(string: "./ccpa/privacy-manager/privacy-manager-view", relativeTo: SP_ROOT)!
33+
static let CCPA_PM_URL = URL(string: "./ccpa_pm/index.html", relativeTo: SP_ROOT)!
34+
static let GDPR_PM_URL = URL(string: "./privacy-manager/index.html", relativeTo: SP_ROOT)!
35+
}
36+
37+
struct UI {
38+
struct DarkMode: SPUIValues {
39+
static var defaultFallbackTextColorForDarkMode: UIColor { .black }
40+
}
41+
}
3042
}

ConsentViewController/Classes/SPConsentManager.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ import UIKit
311311
public func loadGDPRPrivacyManager(withId id: String, tab: SPPrivacyManagerTab = .Default) {
312312
messagesToShow += 1
313313
#if os(iOS)
314-
guard let pmUrl = Constants.GDPR_PM_URL.appendQueryItems([
314+
guard let pmUrl = Constants.Urls.GDPR_PM_URL.appendQueryItems([
315315
"message_id": id,
316316
"pmTab": tab.rawValue,
317317
"consentUUID": gdprUUID,
@@ -350,7 +350,7 @@ import UIKit
350350
public func loadCCPAPrivacyManager(withId id: String, tab: SPPrivacyManagerTab = .Default) {
351351
messagesToShow += 1
352352
#if os(iOS)
353-
guard let pmUrl = Constants.CCPA_PM_URL.appendQueryItems([
353+
guard let pmUrl = Constants.Urls.CCPA_PM_URL.appendQueryItems([
354354
"message_id": id,
355355
"pmTab": tab.rawValue,
356356
"ccpaUUID": ccpaUUID,

ConsentViewController/Classes/SPNativeMessage.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ import Foundation
101101
try container.encode(choiceType, forKey: .choiceType)
102102
}
103103

104-
enum CodingKeys: String, CodingKey { // swiftlint:disable:this nesting
104+
enum CodingKeys: String, CodingKey {
105105
case text, style, customFields, choiceType, url
106106
}
107107
}

ConsentViewController/Classes/SourcePointClient/GDPRPrivacyManagerViewResponse.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct GDPRVendor: Decodable {
2525
let vendorType: VendorType
2626
let consentCategories, legIntCategories: [Category]
2727
let iabSpecialPurposes, iabFeatures, iabSpecialFeatures: [String]
28-
28+
2929
init(from decoder: Decoder) throws {
3030
let container = try decoder.container(keyedBy: Keys.self)
3131
name = try container.decode(String.self, forKey: .name)

ConsentViewController/Classes/SourcePointClient/SPNativeUI.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import Foundation
99
import UIKit
1010

11-
// swiftlint:disable nesting
12-
1311
@objcMembers class SPNativeFont: NSObject, Codable {
1412
let fontSize: CGFloat
1513
let fontWeight: String
@@ -164,7 +162,7 @@ class SPNativeButton: SPNativeUI {
164162
class SPNativeImage: SPNativeUI {
165163
class Settings: SPNativeUISettings {
166164
let src: URL?
167-
165+
168166
required init(from decoder: Decoder) throws {
169167
let container = try decoder.container(keyedBy: Keys.self)
170168
src = try? container.decodeIfPresent(URL.self, forKey: .url) ?? (try? container.decodeIfPresent(URL.self, forKey: .src))

ConsentViewController/Classes/SourcePointClient/SPPrivacyManagerRequestResponse.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Foundation
1717
let vendorId: String?
1818
let policyUrl: URL?
1919
let vendorType: GDPRVendor.VendorType?
20-
20+
2121
init(from decoder: Decoder) throws {
2222
let container = try decoder.container(keyedBy: Keys.self)
2323
name = try container.decode(String.self, forKey: .name)

ConsentViewController/Classes/SourcePointClient/SourcePointClient.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class SourcePointClient: SourcePointProtocol {
168168
consentLanguage: consentLanguage,
169169
campaigns: CampaignsRequest(from: campaigns)
170170
)).map { body in
171-
client.post(urlString: Constants.GET_MESSAGES_URL.absoluteString, body: body) { result in
171+
client.post(urlString: Constants.Urls.GET_MESSAGES_URL.absoluteString, body: body) { result in
172172
handler(Result {
173173
try result.decoded() as MessagesResponse
174174
}.mapError({
@@ -184,8 +184,8 @@ class SourcePointClient: SourcePointProtocol {
184184
messageId: String,
185185
handler: @escaping MessageHandler
186186
) {
187-
let url = Constants.GDPR_MESSAGE_URL.appendQueryItems([
188-
"env": Constants.envParam,
187+
let url = Constants.Urls.GDPR_MESSAGE_URL.appendQueryItems([
188+
"env": Constants.Urls.envParam,
189189
"consentLanguage": consentLanguage.rawValue,
190190
"propertyId": propertyId,
191191
"messageId": messageId,
@@ -206,8 +206,8 @@ class SourcePointClient: SourcePointProtocol {
206206
messageId: String,
207207
handler: @escaping MessageHandler
208208
) {
209-
let url = Constants.CCPA_MESSAGE_URL.appendQueryItems([
210-
"env": Constants.envParam,
209+
let url = Constants.Urls.CCPA_MESSAGE_URL.appendQueryItems([
210+
"env": Constants.Urls.envParam,
211211
"consentLanguage": consentLanguage.rawValue,
212212
"propertyId": propertyId,
213213
"messageId": messageId
@@ -222,7 +222,7 @@ class SourcePointClient: SourcePointProtocol {
222222
}
223223

224224
func gdprPrivacyManagerView(propertyId: Int, consentLanguage: SPMessageLanguage, handler: @escaping GDPRPrivacyManagerViewHandler) {
225-
let url = Constants.GDPR_PRIVACY_MANAGER_VIEW_URL.appendQueryItems([
225+
let url = Constants.Urls.GDPR_PRIVACY_MANAGER_VIEW_URL.appendQueryItems([
226226
"siteId": String(propertyId),
227227
"consentLanguage": consentLanguage.rawValue
228228
])!
@@ -236,7 +236,7 @@ class SourcePointClient: SourcePointProtocol {
236236
}
237237

238238
func ccpaPrivacyManagerView(propertyId: Int, consentLanguage: SPMessageLanguage, handler: @escaping CCPAPrivacyManagerViewHandler) {
239-
let url = Constants.CCPA_PRIVACY_MANAGER_VIEW_URL.appendQueryItems([
239+
let url = Constants.Urls.CCPA_PRIVACY_MANAGER_VIEW_URL.appendQueryItems([
240240
"siteId": String(propertyId),
241241
"consentLanguage": consentLanguage.rawValue
242242
])!
@@ -253,7 +253,7 @@ class SourcePointClient: SourcePointProtocol {
253253
guard let actionUrl = URL(string: "\(actionType.rawValue)") else { return nil }
254254

255255
var components = URLComponents(url: actionUrl, resolvingAgainstBaseURL: true)
256-
components?.queryItems = [URLQueryItem(name: "env", value: Constants.envParam)]
256+
components?.queryItems = [URLQueryItem(name: "env", value: Constants.Urls.envParam)]
257257
return components?.url(relativeTo: baseUrl)
258258
}
259259

@@ -265,7 +265,7 @@ class SourcePointClient: SourcePointProtocol {
265265
pmSaveAndExitVariables: action.pmPayload,
266266
requestUUID: requestUUID
267267
)).map { body in
268-
client.post(urlString: consentUrl(Constants.CCPA_CONSENT_URL, action.type)!.absoluteString, body: body) { result in
268+
client.post(urlString: consentUrl(Constants.Urls.CCPA_CONSENT_URL, action.type)!.absoluteString, body: body) { result in
269269
handler(Result {
270270
let response = try result.decoded() as ConsentResponse
271271
switch response.userConsent {
@@ -288,7 +288,7 @@ class SourcePointClient: SourcePointProtocol {
288288
publisherData: action.publisherData,
289289
requestUUID: requestUUID
290290
)).map { body in
291-
client.post(urlString: consentUrl(Constants.GDPR_CONSENT_URL, action.type)!.absoluteString, body: body) { result in
291+
client.post(urlString: consentUrl(Constants.Urls.GDPR_CONSENT_URL, action.type)!.absoluteString, body: body) { result in
292292
handler(Result {
293293
let response = try result.decoded() as ConsentResponse
294294
switch response.userConsent {
@@ -312,7 +312,7 @@ class SourcePointClient: SourcePointProtocol {
312312
iosVersion: iosVersion,
313313
appleTracking: AppleTrackingPayload(appleChoice: idfaStatus, appleMsgId: messageId, messagePartitionUUID: partitionUUID)
314314
)).map {
315-
client.post(urlString: Constants.IDFA_RERPORT_URL.absoluteString, body: $0) { _ in }
315+
client.post(urlString: Constants.Urls.IDFA_RERPORT_URL.absoluteString, body: $0) { _ in }
316316
}
317317
}
318318

@@ -330,7 +330,7 @@ class SourcePointClient: SourcePointProtocol {
330330
categories: categories,
331331
legIntCategories: legIntCategories
332332
)).map { body in
333-
client.post(urlString: Constants.CUSTOM_CONSENT_URL.absoluteString, body: body) { result in
333+
client.post(urlString: Constants.Urls.CUSTOM_CONSENT_URL.absoluteString, body: body) { result in
334334
handler(Result {
335335
try result.decoded() as CustomConsentResponse
336336
}.mapError {
@@ -359,7 +359,7 @@ class SourcePointClient: SourcePointProtocol {
359359
propertyName: propertyName,
360360
campaignType: campaignType
361361
)).map {
362-
client.post(urlString: Constants.ERROR_METRIS_URL.absoluteString, body: $0) { _ in }
362+
client.post(urlString: Constants.Urls.ERROR_METRIS_URL.absoluteString, body: $0) { _ in }
363363
}
364364
}
365365
}

ConsentViewController/Classes/Views/tvOS/NativePrivacyManager/Common/SPNativeScreenViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ extension UILabel {
252252
func setDefaultTextColorForDarkMode() {
253253
if #available(tvOS 13.0, *) {
254254
if UITraitCollection.current.userInterfaceStyle == .dark {
255-
self.textColor = Constants.defaultFallbackTextColorForDarkMode
255+
self.textColor = Constants.UI.DarkMode.defaultFallbackTextColorForDarkMode
256256
}
257257
}
258258
}

Example/.swiftlint.yml

+6
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ identifier_name:
1717
line_length:
1818
warning: 180
1919
error: 220
20+
type_name:
21+
min_length:
22+
warning: 1
23+
nesting:
24+
type_level:
25+
warning: 3

0 commit comments

Comments
 (0)