Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable translateMessage for tvOS only #568

Merged
merged 8 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 29 additions & 23 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,73 @@ defaults:
working-directory: Example
jobs:
lint:
runs-on: macos-latest
runs-on: macos-latest-large
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: linting
run: swiftlint lint
BuildSwiftPackage:
runs-on: macos-latest
runs-on: macos-latest-large
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
- name: Building Swift Package
run: xcodebuild clean build -scheme SPMBuild -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
run: xcodebuild clean build -scheme SPMBuild -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
- uses: actions/upload-artifact@v2
if: failure()
name: Upload Swift Package build results
with:
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
BuildCarthageProject:
runs-on: macos-latest
runs-on: macos-latest-large
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
- name: Building Carthage Project
run: cd ./SPCarthageTest && ./build.sh
ObjC-ExampleApp-tests:
runs-on: macos-latest
runs-on: macos-latest-large
steps:
- uses: actions/checkout@v2
- name: ObjC-ExampleApp testing -> iPhone 14 Pro (iOS 16.2)
run: xcodebuild test -scheme ObjC-ExampleApp -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
- uses: actions/checkout@v4
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
- name: ObjC-ExampleApp testing -> iPhone 15 (iOS 17.4)
run: xcodebuild test -scheme ObjC-ExampleApp -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
- uses: actions/upload-artifact@v2
if: failure()
name: Upload ObjCExampleApp tests results
with:
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
ConsentViewController:
runs-on: macos-latest
runs-on: macos-latest-large
steps:
- uses: actions/checkout@v2
- name: ConsentViewController testing -> iPhone 14 Pro (iOS 16.2)
run: xcodebuild test -scheme ConsentViewController_Example -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
- uses: actions/checkout@v4
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
- name: ConsentViewController testing -> iPhone 15 (iOS 17.4)
run: xcodebuild test -scheme ConsentViewController_Example -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
- uses: actions/upload-artifact@v2
if: failure()
name: Upload ConsentViewController tests results
with:
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
AuthExample-tests:
runs-on: macos-latest
runs-on: macos-latest-large
steps:
- uses: actions/checkout@v2
- name: ConsentViewController testing -> iPhone 14 Pro (iOS 16.2)
run: xcodebuild test -scheme AuthExample -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
- uses: actions/checkout@v4
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
- name: ConsentViewController testing -> iPhone 15 (iOS 17.4)
run: xcodebuild test -scheme AuthExample -workspace ConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
- uses: actions/upload-artifact@v2
if: failure()
name: Upload ConsentViewController tests results
with:
path: /Users/runner/Library/Developer/Xcode/DerivedData/**/*.xcresult
NativePMExampleApp:
runs-on: macos-latest
runs-on: macos-latest-large
steps:
- uses: actions/checkout@v2
- name: ConsentViewController testing -> Apple TV (tvOS 16.1)
run: xcodebuild test -scheme NativePMExampleApp -workspace ConsentViewController.xcworkspace -destination 'platform=tvOS Simulator,name=Apple TV,OS=16.1'
- uses: actions/checkout@v4
- run: sudo xcode-select -s /Applications/Xcode_15.3.app
- name: ConsentViewController testing -> Apple TV (tvOS 17.4)
run: xcodebuild test -scheme NativePMExampleApp -workspace ConsentViewController.xcworkspace -destination 'platform=tvOS Simulator,name=Apple TV,OS=17.4'
- uses: actions/upload-artifact@v2
if: failure()
name: Upload NativePMExampleApp tests results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ struct IncludeData: Equatable {
let TCData = ["type": "RecordString"]
let webConsentPayload = ["type": "string"]
let categories = true
let translateMessage = true
let gppConfig: SPGPPConfig

#if os(tvOS)
let translateMessage = true
#endif
}

extension IncludeData: Encodable {
enum CodingKeys: String, CodingKey {
case localState, TCData, webConsentPayload, categories, translateMessage
case localState, TCData, webConsentPayload, categories
case gppConfig = "GPPData"

#if os(tvOS)
case translateMessage
#endif
}

var string: String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ import WebKit
wv.isOpaque = false
wv.backgroundColor = .clear
wv.allowsBackForwardNavigationGestures = false
#if compiler(>=5.8) && DEBUG
if #available(iOS 16.4, *) {
wv.isInspectable = true
}
#endif
return wv
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class FocusGuideDebugView: UIView {
}
return button
}

@discardableResult
func loadLabelText(forComponent component: SPNativeText, labelText text: String? = nil, label: UILabel) -> UILabel {
let style = component.settings.style
Expand Down
18 changes: 13 additions & 5 deletions Example/ConsentViewController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4310,10 +4310,11 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -4336,6 +4337,7 @@
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.sourcepoint.ConsentViewController;
PRODUCT_NAME = ConsentViewController;
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = NO;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
Expand All @@ -4360,9 +4362,10 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -4384,6 +4387,7 @@
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.sourcepoint.ConsentViewController;
PRODUCT_NAME = ConsentViewController;
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = NO;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
Expand All @@ -4408,10 +4412,11 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -4433,6 +4438,7 @@
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.sourcepoint.ConsentViewController;
PRODUCT_NAME = ConsentViewController;
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = appletvos;
SKIP_INSTALL = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG SPM";
Expand All @@ -4456,9 +4462,10 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -4479,6 +4486,7 @@
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.sourcepoint.ConsentViewController;
PRODUCT_NAME = ConsentViewController;
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = appletvos;
SKIP_INSTALL = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = SPM;
Expand Down Expand Up @@ -6004,7 +6012,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SourcePointUSA/ios-cmp-app";
requirement = {
branch = fix_spm_runtime;
branch = develop;
kind = branch;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/SourcePointUSA/ios-cmp-app",
"state" : {
"branch" : "fix_spm_runtime",
"revision" : "f7eb60b362d7df1c07d6ba412d5669ff9790be62"
"branch" : "develop",
"revision" : "bffbdec238afea25a0c8e885b2d729ac222cfa1a"
}
}
],
Expand Down
36 changes: 29 additions & 7 deletions Example/ConsentViewController/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ struct Config {

let accountId, propertyId: Int
let propertyName: String
let gdpr, ccpa, att, usnat: Bool
let language: SPMessageLanguage
let campaigns: SPCampaigns
let gdprPmId, ccpaPmId, usnatPmId: String?
var language: SPMessageLanguage?

let myVendorId = "5ff4d000a228633ac048be41"
let myPurposesId = ["608bad95d08d3112188e0e36", "608bad95d08d3112188e0e2f"]
Expand All @@ -32,13 +32,35 @@ extension Config {
accountId = (values["accountId"] as? NSString)?.integerValue ?? defaults.accountId
propertyId = (values["propertyId"] as? NSString)?.integerValue ?? defaults.propertyId
propertyName = values["propertyName"] as? String ?? defaults.propertyName
gdpr = (values["gdpr"] as? NSString)?.boolValue ?? defaults.gdpr
ccpa = (values["ccpa"] as? NSString)?.boolValue ?? defaults.ccpa
usnat = (values["usnat"] as? NSString)?.boolValue ?? defaults.usnat
att = (values["att"] as? NSString)?.boolValue ?? defaults.att
language = SPMessageLanguage(rawValue: values["language"] as? String ?? "xx") ?? defaults.language
gdprPmId = defaults.gdprPmId
ccpaPmId = defaults.ccpaPmId
usnatPmId = defaults.usnatPmId
if let langArg = values["language"] as? String,
let langEnum = SPMessageLanguage(rawValue: langArg) {
language = langEnum
} else {
language = defaults.language
}

let gdprArg = (values["gdpr"] as? NSString)?.boolValue
let ccpaArg = (values["ccpa"] as? NSString)?.boolValue
let usnatArg = (values["usnat"] as? NSString)?.boolValue
let attArg = (values["att"] as? NSString)?.boolValue

campaigns = SPCampaigns(
gdpr: gdprArg == nil ? defaults.campaigns.gdpr :
gdprArg == true ? SPCampaign(
// sets the withoutBrowserDefault targeting param so we can test a message
// without the browser default settings enabled (otherwise, setting the language
// param has no effect).
targetingParams: language != nil ? ["withoutBrowserDefault": "true"] : [:]
) : nil,
ccpa: ccpaArg == nil ? defaults.campaigns.ccpa :
ccpaArg == true ? SPCampaign() : nil,
usnat: usnatArg == nil ? defaults.campaigns.usnat :
usnatArg == true ? SPCampaign() : nil,
ios14: attArg == nil ? defaults.campaigns.ios14 :
attArg == true ? SPCampaign() : nil
)
}
}
20 changes: 8 additions & 12 deletions Example/ConsentViewController/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class ViewController: UIViewController {
accountId: 22,
propertyId: 16893,
propertyName: "mobile.multicampaign.demo",
gdpr: true,
ccpa: true,
att: true,
usnat: false,
language: .BrowserDefault,
campaigns: SPCampaigns(
gdpr: SPCampaign(),
ccpa: SPCampaign(),
usnat: nil,
ios14: SPCampaign()
),
gdprPmId: "488393",
ccpaPmId: "509688",
usnatPmId: "943886"
Expand All @@ -34,13 +35,8 @@ class ViewController: UIViewController {
accountId: config.accountId,
propertyId: config.propertyId,
propertyName: try! SPPropertyName(config.propertyName), // swiftlint:disable:this force_try
campaigns: SPCampaigns(
gdpr: config.gdpr ? SPCampaign() : nil,
ccpa: config.ccpa ? SPCampaign() : nil,
usnat: config.usnat ? SPCampaign() : nil,
ios14: config.att ? SPCampaign() : nil
),
language: config.language,
campaigns: config.campaigns,
language: config.language ?? .BrowserDefault,
delegate: self
)}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class IncludeDataSpec: QuickSpec {
expect(stringified).to(contain(#""TCData":{"type":"RecordString"}"#))
expect(stringified).to(contain(#""webConsentPayload":{"type":"string"}"#))
expect(stringified).to(contain(#""categories":true"#))
#if os(tvOS)
expect(stringified).to(contain(#""translateMessage":true"#))
#endif
expect(stringified).to(contain(#""GPPData":{}"#))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class SPGDPRExampleAppUITests: QuickSpec {

it("Shows a translated message") {
self.app.relaunch(clean: true, resetAtt: false, args: [
"gdpr": true,
"att": false,
"ccpa": false,
"usnat": false,
Expand Down