Installing on Obj C project without CocoaPods - SourcePointUSA/ios-cmp-app GitHub Wiki
Installing on Obj-C project without CocoaPods
- Clone ConsentViewController's repo.
- Clone Reachability's repo
- Copy the file
Sources/Reachability.swift
from the Reachability's folder into your project. If you don't have one yet, XCode will prompt you about creating a bridging header. Click on Create Bridging Header
.

- Copy the
ConsentViewController
folder from the ConsentViewController
repo to your project. Make sure to select Added folders: Create Groups
like shown in the picture below.

- Go to
ConsentViewController/Classes/ConsentViewController.swift
file and delete the import Reachability
statement.
- Finally, on your
ViewController.m
file, #import "YourProjectsProductName-Swift.h"
- You may now use
ConsentViewController
Code Example
// ViewController.m
#import "ViewController.h"
#import "ObjCSDKSample-Swift.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
ConsentViewController *cvc = [[ConsentViewController alloc] initWithAccountId:22 siteName:@"mobile.demo" stagingCampaign:false andReturnError:nil];
[cvc setTargetingParamString:@"MyPrivacyManager" value:@"true"];
[cvc setOnMessageReady:^(ConsentViewController * consentSDK) {
[self presentViewController:consentSDK animated:false completion:NULL];
}];
[cvc setOnInteractionComplete:^(ConsentViewController * consentSDK) {
[consentSDK getCustomPurposeConsentsWithCompletionHandler:^(NSArray<PurposeConsent *>* purposeConsents) {
NSLog(@"User has given consent to the purposes: %@", purposeConsents);
}];
[consentSDK dismissViewControllerAnimated:false completion:NULL];
}];
[cvc loadMessage];
}
@end
Troubleshooting
- If your project is a framework itself, you'll need to
#import "YourProductsName/YourProductsName-Swift.h"
(instead of #import "YourProductsName-Swift.h"
).
- If you're not able to import the header mentioned above, make sure your Target's Product Name is defined. Try setting it to the name of your Project.

- Some people had to set the option
Define Modules > YES
as well.
- If your project's name have spaces in it, substitute them by underscores when importing the header file like
#import "My_Project-Swift.h"