Skip to content

Commit a0e0297

Browse files
Merge pull request #568 from SourcePointUSA/remove_translateMessage_includeData
enable translateMessage for tvOS only
2 parents bffbdec + b605be6 commit a0e0297

File tree

10 files changed

+99
-52
lines changed

10 files changed

+99
-52
lines changed

.github/workflows/swift.yml

+29-23
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,73 @@ defaults:
1010
working-directory: Example
1111
jobs:
1212
lint:
13-
runs-on: macos-latest
13+
runs-on: macos-latest-large
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616
- name: linting
1717
run: swiftlint lint
1818
BuildSwiftPackage:
19-
runs-on: macos-latest
19+
runs-on: macos-latest-large
2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
22+
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
2223
- name: Building Swift Package
23-
run: xcodebuild clean build -scheme SPMBuild -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
24+
run: xcodebuild clean build -scheme SPMBuild -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
2425
- uses: actions/upload-artifact@v2
2526
if: failure()
2627
name: Upload Swift Package build results
2728
with:
2829
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
2930
BuildCarthageProject:
30-
runs-on: macos-latest
31+
runs-on: macos-latest-large
3132
steps:
32-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v4
34+
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
3335
- name: Building Carthage Project
3436
run: cd ./SPCarthageTest && ./build.sh
3537
ObjC-ExampleApp-tests:
36-
runs-on: macos-latest
38+
runs-on: macos-latest-large
3739
steps:
38-
- uses: actions/checkout@v2
39-
- name: ObjC-ExampleApp testing -> iPhone 14 Pro (iOS 16.2)
40-
run: xcodebuild test -scheme ObjC-ExampleApp -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
40+
- uses: actions/checkout@v4
41+
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
42+
- name: ObjC-ExampleApp testing -> iPhone 15 (iOS 17.4)
43+
run: xcodebuild test -scheme ObjC-ExampleApp -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
4144
- uses: actions/upload-artifact@v2
4245
if: failure()
4346
name: Upload ObjCExampleApp tests results
4447
with:
4548
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
4649
ConsentViewController:
47-
runs-on: macos-latest
50+
runs-on: macos-latest-large
4851
steps:
49-
- uses: actions/checkout@v2
50-
- name: ConsentViewController testing -> iPhone 14 Pro (iOS 16.2)
51-
run: xcodebuild test -scheme ConsentViewController_Example -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
52+
- uses: actions/checkout@v4
53+
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
54+
- name: ConsentViewController testing -> iPhone 15 (iOS 17.4)
55+
run: xcodebuild test -scheme ConsentViewController_Example -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
5256
- uses: actions/upload-artifact@v2
5357
if: failure()
5458
name: Upload ConsentViewController tests results
5559
with:
5660
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
5761
AuthExample-tests:
58-
runs-on: macos-latest
62+
runs-on: macos-latest-large
5963
steps:
60-
- uses: actions/checkout@v2
61-
- name: ConsentViewController testing -> iPhone 14 Pro (iOS 16.2)
62-
run: xcodebuild test -scheme AuthExample -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
64+
- uses: actions/checkout@v4
65+
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
66+
- name: ConsentViewController testing -> iPhone 15 (iOS 17.4)
67+
run: xcodebuild test -scheme AuthExample -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
6368
- uses: actions/upload-artifact@v2
6469
if: failure()
6570
name: Upload ConsentViewController tests results
6671
with:
6772
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
6873
NativePMExampleApp:
69-
runs-on: macos-latest
74+
runs-on: macos-latest-large
7075
steps:
71-
- uses: actions/checkout@v2
72-
- name: ConsentViewController testing -> Apple TV (tvOS 16.1)
73-
run: xcodebuild test -scheme NativePMExampleApp -workspace ConsentViewController.xcworkspace -destination 'platform=tvOS Simulator,name=Apple TV,OS=16.1'
76+
- uses: actions/checkout@v4
77+
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
78+
- name: ConsentViewController testing -> Apple TV (tvOS 17.4)
79+
run: xcodebuild test -scheme NativePMExampleApp -workspace ConsentViewController.xcworkspace -destination 'platform=tvOS Simulator,name=Apple TV,OS=17.4'
7480
- uses: actions/upload-artifact@v2
7581
if: failure()
7682
name: Upload NativePMExampleApp tests results

ConsentViewController/Classes/SourcePointClient/IncludeData.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,21 @@ struct IncludeData: Equatable {
1414
let TCData = ["type": "RecordString"]
1515
let webConsentPayload = ["type": "string"]
1616
let categories = true
17-
let translateMessage = true
1817
let gppConfig: SPGPPConfig
18+
19+
#if os(tvOS)
20+
let translateMessage = true
21+
#endif
1922
}
2023

2124
extension IncludeData: Encodable {
2225
enum CodingKeys: String, CodingKey {
23-
case localState, TCData, webConsentPayload, categories, translateMessage
26+
case localState, TCData, webConsentPayload, categories
2427
case gppConfig = "GPPData"
28+
29+
#if os(tvOS)
30+
case translateMessage
31+
#endif
2532
}
2633

2734
var string: String? {

ConsentViewController/Classes/Views/iOS/SPWebMessageViewController.swift

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ import WebKit
3030
wv.isOpaque = false
3131
wv.backgroundColor = .clear
3232
wv.allowsBackForwardNavigationGestures = false
33+
#if compiler(>=5.8) && DEBUG
34+
if #available(iOS 16.4, *) {
35+
wv.isInspectable = true
36+
}
37+
#endif
3338
return wv
3439
}
3540
return nil

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class FocusGuideDebugView: UIView {
204204
}
205205
return button
206206
}
207-
207+
208208
@discardableResult
209209
func loadLabelText(forComponent component: SPNativeText, labelText text: String? = nil, label: UILabel) -> UILabel {
210210
let style = component.settings.style

Example/ConsentViewController.xcodeproj/project.pbxproj

+13-5
Original file line numberDiff line numberDiff line change
@@ -4310,10 +4310,11 @@
43104310
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
43114311
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
43124312
CODE_SIGN_IDENTITY = "";
4313-
CODE_SIGN_STYLE = Automatic;
4313+
CODE_SIGN_STYLE = Manual;
43144314
CURRENT_PROJECT_VERSION = 1;
43154315
DEBUG_INFORMATION_FORMAT = dwarf;
43164316
DEFINES_MODULE = YES;
4317+
DEVELOPMENT_TEAM = "";
43174318
DYLIB_COMPATIBILITY_VERSION = 1;
43184319
DYLIB_CURRENT_VERSION = 1;
43194320
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -4336,6 +4337,7 @@
43364337
OTHER_LDFLAGS = "$(inherited)";
43374338
PRODUCT_BUNDLE_IDENTIFIER = com.sourcepoint.ConsentViewController;
43384339
PRODUCT_NAME = ConsentViewController;
4340+
PROVISIONING_PROFILE_SPECIFIER = "";
43394341
SKIP_INSTALL = NO;
43404342
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
43414343
SUPPORTS_MACCATALYST = YES;
@@ -4360,9 +4362,10 @@
43604362
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
43614363
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
43624364
CODE_SIGN_IDENTITY = "";
4363-
CODE_SIGN_STYLE = Automatic;
4365+
CODE_SIGN_STYLE = Manual;
43644366
CURRENT_PROJECT_VERSION = 1;
43654367
DEFINES_MODULE = YES;
4368+
DEVELOPMENT_TEAM = "";
43664369
DYLIB_COMPATIBILITY_VERSION = 1;
43674370
DYLIB_CURRENT_VERSION = 1;
43684371
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -4384,6 +4387,7 @@
43844387
OTHER_LDFLAGS = "$(inherited)";
43854388
PRODUCT_BUNDLE_IDENTIFIER = com.sourcepoint.ConsentViewController;
43864389
PRODUCT_NAME = ConsentViewController;
4390+
PROVISIONING_PROFILE_SPECIFIER = "";
43874391
SKIP_INSTALL = NO;
43884392
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
43894393
SUPPORTS_MACCATALYST = YES;
@@ -4408,10 +4412,11 @@
44084412
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
44094413
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
44104414
CODE_SIGN_IDENTITY = "";
4411-
CODE_SIGN_STYLE = Automatic;
4415+
CODE_SIGN_STYLE = Manual;
44124416
CURRENT_PROJECT_VERSION = 1;
44134417
DEBUG_INFORMATION_FORMAT = dwarf;
44144418
DEFINES_MODULE = YES;
4419+
DEVELOPMENT_TEAM = "";
44154420
DYLIB_COMPATIBILITY_VERSION = 1;
44164421
DYLIB_CURRENT_VERSION = 1;
44174422
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -4433,6 +4438,7 @@
44334438
OTHER_LDFLAGS = "$(inherited)";
44344439
PRODUCT_BUNDLE_IDENTIFIER = com.sourcepoint.ConsentViewController;
44354440
PRODUCT_NAME = ConsentViewController;
4441+
PROVISIONING_PROFILE_SPECIFIER = "";
44364442
SDKROOT = appletvos;
44374443
SKIP_INSTALL = NO;
44384444
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG SPM";
@@ -4456,9 +4462,10 @@
44564462
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
44574463
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
44584464
CODE_SIGN_IDENTITY = "";
4459-
CODE_SIGN_STYLE = Automatic;
4465+
CODE_SIGN_STYLE = Manual;
44604466
CURRENT_PROJECT_VERSION = 1;
44614467
DEFINES_MODULE = YES;
4468+
DEVELOPMENT_TEAM = "";
44624469
DYLIB_COMPATIBILITY_VERSION = 1;
44634470
DYLIB_CURRENT_VERSION = 1;
44644471
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -4479,6 +4486,7 @@
44794486
OTHER_LDFLAGS = "$(inherited)";
44804487
PRODUCT_BUNDLE_IDENTIFIER = com.sourcepoint.ConsentViewController;
44814488
PRODUCT_NAME = ConsentViewController;
4489+
PROVISIONING_PROFILE_SPECIFIER = "";
44824490
SDKROOT = appletvos;
44834491
SKIP_INSTALL = NO;
44844492
SWIFT_ACTIVE_COMPILATION_CONDITIONS = SPM;
@@ -6004,7 +6012,7 @@
60046012
isa = XCRemoteSwiftPackageReference;
60056013
repositoryURL = "https://github.com/SourcePointUSA/ios-cmp-app";
60066014
requirement = {
6007-
branch = fix_spm_runtime;
6015+
branch = develop;
60086016
kind = branch;
60096017
};
60106018
};

Example/ConsentViewController.xcworkspace/xcshareddata/swiftpm/Package.resolved

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"kind" : "remoteSourceControl",
1616
"location" : "https://github.com/SourcePointUSA/ios-cmp-app",
1717
"state" : {
18-
"branch" : "fix_spm_runtime",
19-
"revision" : "f7eb60b362d7df1c07d6ba412d5669ff9790be62"
18+
"branch" : "develop",
19+
"revision" : "bffbdec238afea25a0c8e885b2d729ac222cfa1a"
2020
}
2121
}
2222
],

Example/ConsentViewController/Config.swift

+29-7
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ struct Config {
1818

1919
let accountId, propertyId: Int
2020
let propertyName: String
21-
let gdpr, ccpa, att, usnat: Bool
22-
let language: SPMessageLanguage
21+
let campaigns: SPCampaigns
2322
let gdprPmId, ccpaPmId, usnatPmId: String?
23+
var language: SPMessageLanguage?
2424

2525
let myVendorId = "5ff4d000a228633ac048be41"
2626
let myPurposesId = ["608bad95d08d3112188e0e36", "608bad95d08d3112188e0e2f"]
@@ -32,13 +32,35 @@ extension Config {
3232
accountId = (values["accountId"] as? NSString)?.integerValue ?? defaults.accountId
3333
propertyId = (values["propertyId"] as? NSString)?.integerValue ?? defaults.propertyId
3434
propertyName = values["propertyName"] as? String ?? defaults.propertyName
35-
gdpr = (values["gdpr"] as? NSString)?.boolValue ?? defaults.gdpr
36-
ccpa = (values["ccpa"] as? NSString)?.boolValue ?? defaults.ccpa
37-
usnat = (values["usnat"] as? NSString)?.boolValue ?? defaults.usnat
38-
att = (values["att"] as? NSString)?.boolValue ?? defaults.att
39-
language = SPMessageLanguage(rawValue: values["language"] as? String ?? "xx") ?? defaults.language
4035
gdprPmId = defaults.gdprPmId
4136
ccpaPmId = defaults.ccpaPmId
4237
usnatPmId = defaults.usnatPmId
38+
if let langArg = values["language"] as? String,
39+
let langEnum = SPMessageLanguage(rawValue: langArg) {
40+
language = langEnum
41+
} else {
42+
language = defaults.language
43+
}
44+
45+
let gdprArg = (values["gdpr"] as? NSString)?.boolValue
46+
let ccpaArg = (values["ccpa"] as? NSString)?.boolValue
47+
let usnatArg = (values["usnat"] as? NSString)?.boolValue
48+
let attArg = (values["att"] as? NSString)?.boolValue
49+
50+
campaigns = SPCampaigns(
51+
gdpr: gdprArg == nil ? defaults.campaigns.gdpr :
52+
gdprArg == true ? SPCampaign(
53+
// sets the withoutBrowserDefault targeting param so we can test a message
54+
// without the browser default settings enabled (otherwise, setting the language
55+
// param has no effect).
56+
targetingParams: language != nil ? ["withoutBrowserDefault": "true"] : [:]
57+
) : nil,
58+
ccpa: ccpaArg == nil ? defaults.campaigns.ccpa :
59+
ccpaArg == true ? SPCampaign() : nil,
60+
usnat: usnatArg == nil ? defaults.campaigns.usnat :
61+
usnatArg == true ? SPCampaign() : nil,
62+
ios14: attArg == nil ? defaults.campaigns.ios14 :
63+
attArg == true ? SPCampaign() : nil
64+
)
4365
}
4466
}

Example/ConsentViewController/ViewController.swift

+8-12
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ class ViewController: UIViewController {
2020
accountId: 22,
2121
propertyId: 16893,
2222
propertyName: "mobile.multicampaign.demo",
23-
gdpr: true,
24-
ccpa: true,
25-
att: true,
26-
usnat: false,
27-
language: .BrowserDefault,
23+
campaigns: SPCampaigns(
24+
gdpr: SPCampaign(),
25+
ccpa: SPCampaign(),
26+
usnat: nil,
27+
ios14: SPCampaign()
28+
),
2829
gdprPmId: "488393",
2930
ccpaPmId: "509688",
3031
usnatPmId: "943886"
@@ -34,13 +35,8 @@ class ViewController: UIViewController {
3435
accountId: config.accountId,
3536
propertyId: config.propertyId,
3637
propertyName: try! SPPropertyName(config.propertyName), // swiftlint:disable:this force_try
37-
campaigns: SPCampaigns(
38-
gdpr: config.gdpr ? SPCampaign() : nil,
39-
ccpa: config.ccpa ? SPCampaign() : nil,
40-
usnat: config.usnat ? SPCampaign() : nil,
41-
ios14: config.att ? SPCampaign() : nil
42-
),
43-
language: config.language,
38+
campaigns: config.campaigns,
39+
language: config.language ?? .BrowserDefault,
4440
delegate: self
4541
)}()
4642

Example/ConsentViewController_ExampleTests/IncludeDataSpec.swift

+2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class IncludeDataSpec: QuickSpec {
2828
expect(stringified).to(contain(#""TCData":{"type":"RecordString"}"#))
2929
expect(stringified).to(contain(#""webConsentPayload":{"type":"string"}"#))
3030
expect(stringified).to(contain(#""categories":true"#))
31+
#if os(tvOS)
3132
expect(stringified).to(contain(#""translateMessage":true"#))
33+
#endif
3234
expect(stringified).to(contain(#""GPPData":{}"#))
3335
}
3436
}

Example/SPGDPRExampleAppUITests/SPGDPRExampleAppUITests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class SPGDPRExampleAppUITests: QuickSpec {
146146

147147
it("Shows a translated message") {
148148
self.app.relaunch(clean: true, resetAtt: false, args: [
149+
"gdpr": true,
149150
"att": false,
150151
"ccpa": false,
151152
"usnat": false,

0 commit comments

Comments
 (0)