A command-line installer for integrating the TrustArc Mobile Consent SDK into your mobile applications.
- Automated SDK Integration: Streamlined installation process for iOS, Android, and React Native projects
- Multi-Platform Support:
- iOS: Swift Package Manager (SPM) & CocoaPods
- Android: Gradle with version catalog support
- React Native: Expo & Bare Metal with auto-linking
- Sample Implementation: Automatic boilerplate code generation
- Demo App Downloads: Pull full sample projects from the private
trustarc/ccm-mobile-consent-test-appsrepository (release branch) for reference - Platform Detection: Auto-detects your project configuration
- Git-Safe: Validates git status before making changes
Run the installer directly from GitHub:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/trustarc-ci/trustarc-cli/refs/heads/main/install.sh)"If you need the latest version and want to bypass any caching:
bash -c "$(curl -fsSL -H 'Cache-Control: no-cache, no-store, must-revalidate' https://raw.githubusercontent.com/trustarc-ci/trustarc-cli/refs/heads/main/install.sh)"If you don't have curl installed:
bash -c "$(wget https://raw.githubusercontent.com/trustarc-ci/trustarc-cli/refs/heads/main/install.sh -O -)"For development or offline use:
git clone https://github.com/trustarc-ci/trustarc-cli.git
cd trustarc-cli
./install.shBefore running the installer, make sure you have:
- Operating System: macOS or Linux
- Xcode: Required for iOS integration (macOS only)
- Git: Recommended for better change tracking
- GitHub Token: Personal Access Token with
repoandread:packagescopes- Create one at: https://github.com/settings/tokens
- Required scopes:
repo,read:package - Must have access to
trustarc/trustarc-mobile-consentandtrustarc/ccm-mobile-consent-test-apps
If you're using CocoaPods:
- CocoaPods: Install with
sudo gem install cocoapods - Ruby: CocoaPods requires Ruby (usually pre-installed on macOS)
- Authentication: Securely stores your GitHub token
- Platform Detection: Identifies your project type (iOS, Android, React Native, Flutter)
- Dependency Management: Adds TrustArc SDK to your project
- Code Generation: Creates implementation boilerplate
- Verification: Confirms successful integration
The CLI supports:
- Swift Package Manager (SPM)
- CocoaPods
- Swift 5.0+ and iOS 12.0+
CocoaPods: Automatically adds the pod with git URL and branch to your Podfile and runs pod install
pod 'TrustArcConsentSDK', :git => 'https://TOKEN@github.com/...', :branch => 'release'SPM: Provides step-by-step instructions for adding the package in Xcode with authentication.
// Initialize SDK on app launch
TrustArcConsentImpl.shared.initialize()
// Show consent dialog
TrustArcConsentImpl.shared.openCm()The CLI supports:
- Gradle (Groovy & Kotlin DSL)
- Version Catalog (libs.versions.toml)
- Android API 28+ (minSdk)
- Kotlin required
Automatic Configuration:
- Adds Maven repository to
settings.gradle - Configures dependency in
app/build.gradleor version catalog - Installs required dependencies (AndroidX, Retrofit, Material)
- Validates AGP-Kotlin compatibility
// Initialize in Application class
TrustArcConsentImpl.initialize(this)
// Show consent dialog
TrustArcConsentImpl.openCm()
// Get consent data
val consents = TrustArcConsentImpl.getConsentData()The CLI supports both:
- Expo (Managed): Uses
expo prebuildto generate native code - Bare Metal: Direct iOS (CocoaPods) and Android (Gradle) integration
Automatic Detection:
- Detects project type (Expo vs Bare Metal)
- Identifies package manager (npm/yarn)
- Verifies native module linking
Expo Flow:
- Configures
.npmrcfor GitHub Package Registry authentication - Adds
@trustarc/trustarc-react-native-consent-sdkto package.json - Runs
npm installoryarn install - Executes
npx expo prebuildto generate native directories - Verifies iOS (Podfile.lock) and Android (build.gradle) integration
Bare Metal Flow:
- Configures
.npmrcfor GitHub Package Registry authentication - Adds SDK package to package.json
- Runs package manager install
- Executes
pod installfor iOS (if needed) - Verifies auto-linking for Android
- Confirms native modules are properly linked
.npmrc Configuration:
The CLI automatically creates or updates .npmrc with:
@trustarc:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${TRUSTARC_TOKEN}
This configuration:
- Routes
@trustarcscoped packages to GitHub Package Registry - Uses
TRUSTARC_TOKENenvironment variable for authentication - Preserves existing
.npmrcsettings (appends if file exists) - Creates backup before modification
// Initialize in App.tsx or _layout.tsx
useEffect(() => {
TrustArcConsentImpl.initialize();
}, []);
// Show consent dialog
TrustArcConsentImpl.openCm();
// Listen for consent changes
useEffect(() => {
const unsubscribe = TrustArcConsentImpl.onConsentChange((data) => {
console.log('Consent changed:', data);
});
return unsubscribe;
}, []);
// Get consent data
const consents = await TrustArcConsentImpl.getConsentData();- Choose "Integrate SDK" from the main menu
- Provide your project path
- Confirm git status is clean
- CLI auto-detects platform type
- Enter your TrustArc domain
- Follow the guided integration process
- Optionally generate implementation boilerplate
The CLI stores configuration in two places:
Your GitHub token is saved to your shell configuration file:
- zsh:
~/.zshrc - bash:
~/.bashrcor~/.bash_profile - fish:
~/.config/fish/config.fish
The token is exported as TRUSTARC_TOKEN environment variable.
Project preferences are stored in ~/.trustarc-cli-config:
- Last used domain
- Platform preferences
- Other settings
To remove all CLI configuration and tokens:
-
Run the installer again:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/trustarc-ci/trustarc-cli/refs/heads/main/install.sh)" -
Select option 3) Clean up (remove token and config)
-
Restart your terminal for changes to take effect
This will:
- Remove
TRUSTARC_TOKENfrom your shell configuration - Delete
~/.trustarc-cli-config - Create a backup of your shell config
- Verify your token has
repoandread:packagescopes - Ensure the token has access to
trustarc/trustarc-mobile-consentrepository - Try regenerating your GitHub token
- Make sure you're in a valid iOS project directory
- Look for
.xcodeproj,.xcworkspace, orPodfilefiles
- Commit or stash your changes before running integration
- Use
git statusto see uncommitted files - Run
git commitorgit stash
- Close and reopen Xcode
- Clean build folder (Cmd+Shift+K)
- Verify the package appears in Package Dependencies tab
- Verify the podspec exists in the repository
- Check that CocoaPods is installed:
pod --version - Try running
pod repo update
- Check that
.npmrcexists in your project root - Verify
.npmrccontains the GitHub registry configuration:@trustarc:registry=https://npm.pkg.github.com //npm.pkg.github.com/:_authToken=${TRUSTARC_TOKEN} - Ensure
TRUSTARC_TOKENenvironment variable is set:echo $TRUSTARC_TOKEN # Should output your token
- Restart your terminal after setting the token
- Try clearing npm cache:
npm cache clean --force - For yarn:
yarn cache clean
- Ensure you ran
npm installoryarn installafter adding the package - For Expo: Run
npx expo prebuildto generate native directories - For Bare Metal iOS: Run
cd ios && pod install - For Bare Metal Android: Clean and rebuild with
cd android && ./gradlew clean - Restart Metro bundler:
npx react-native start --reset-cache
- Check that all dependencies are properly installed
- Verify
app.jsonhas correct configuration - Try removing
ios/andandroid/directories and running prebuild again - Check Expo CLI version:
npx expo --version
- Verify
use_native_modules!is in your iOS Podfile - Check
applyNativeModulesSettingsGradleis in Android settings.gradle - Clean both platforms:
- iOS:
cd ios && pod deintegrate && pod install - Android:
cd android && ./gradlew clean
- iOS:
Use the cache-bypass command:
bash -c "$(curl -fsSL -H 'Cache-Control: no-cache, no-store, must-revalidate' https://raw.githubusercontent.com/trustarc-ci/trustarc-cli/refs/heads/main/install.sh)"For issues or questions, please visit:
Copyright © 2024 TrustArc. All rights reserved.