/

Xcode Integration

Shield integrates directly into your Xcode build process as a Run Script Build Phase. This ensures your application is automatically protected on every build without manual steps.


Build Phase Overview

Shield runs as a post-compilation step in your Xcode build process. The protection is applied after the binary is compiled and linked, but before code signing:

This means Shield works with the compiled Mach-O binary and does not require any changes to your source code or build settings.


Adding the Build Phase

  1. Open your project in Xcode
  2. Select your application target
  3. Go to the Build Phases tab
  4. Click + and select New Run Script Phase
  5. Drag the new phase to position it after "Compile Sources" and before "Copy Bundle Resources"
  6. Name it "Shield iOS Protection"
  7. Paste the following script:
Bash
# Shield iOS Protection
# Only run for Release builds
if [ "${CONFIGURATION}" != "Debug" ]; then
    shield-ios protect "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app" \
        -c "${PROJECT_DIR}/shield-ios.json" \
        -o "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"
fi

Skipping Debug Builds

The script above only runs for non-Debug configurations. This keeps your debug builds fast and unobfuscated for development and testing.

You can also configure this in your shield-ios.json:

JSON
{
  "projectToken": "your-project-token",
  "build_integration": {
    "skip_debug": true,
    "skip_simulator": true
  },
  "protections": {
    "symbol_renaming": true,
    "string_encryption": true,
    "anti_debug": true
  }
}

With skip_debug and skip_simulator enabled, Shield automatically skips protection when building for Debug configurations or Simulator targets.


Configuration File Location

Place your shield-ios.json in the root of your Xcode project directory (next to the .xcodeproj file). The build phase script references it using ${PROJECT_DIR}.

CODE
MyApp/
├── MyApp.xcodeproj
├── MyApp/
│   ├── AppDelegate.swift
│   └── ...
└── shield-ios.json          ← Configuration file here

Verifying the Integration

After adding the build phase, build your project for a Release configuration. You should see Shield output in the Xcode build log confirming that protections were applied.

If the build phase is configured correctly, Shield will automatically protect your application and upload build analytics to the Cloud Panel.


Previous
Installation & Setup