Add the SDK

The Unity Publisher SDK is built as an an Unity Package in order to work together with the Android and iOS native SDKs so that you can harness the full power of native components, such as video based on AVFoundation / VideoView technology, proper WebViews and a better fullscreen experience.

To begin integrating the SDK:

Download the latest Unity Publisher SDK: Releases

This version will contain everything you need in order to load and display banner, interstitial and video ads.

You can then import it into your Unity project as a custom assets package. You should see an image similar to this:

image-title-here

Select all the files, and click Import. If all goes well you should have a series of new folders and files in your Assets directory.

image-title-here

Once you’ve integrated the SuperAwesome SDK, you can access it by:

using tv.superawesome.sdk.publisher;

Additional steps for Android builds

dependencies {
    implementation 'com.android.support:appcompat-v7:+'
    implementation 'com.google.android.gms:play-services-ads:+'
}
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />

Additional steps for iOS builds

Set swift version to 4.2, if not already set

image-title-here

Add runpaths @executable_path/Frameworks to runpaths

image-title-here

Set C lang dialect to gnu99, if not already set

image-title-here

Enable modules (C and Obj-C), if not already enabled

image-title-here

Make sure SuperAwesome.framework is in the Embed Frameworks list and Code Sign on Copy is selected.

Go to:

Unity-iPhone target -> Build Phases -> Embed Frameworks

image-title-here

Remove Unsupported Architectures for App Store

SuperAwesome SDK framework for Unity contains both arm and x86_64 code which allows running it on a physical device and on a simulator at the same time.

However to publish your app to the App Store the unused architectures(simulator) should be removed from the binary before publishing.

(Option 1): Use SuperAwesome SDK v7.2.12 and above

We have added a post build processor script which automatically removes Simulator architecture codes from the binary when uploading to App Store.

When you build the Unity project for the first time, the SuperAwesome SDK will a build phase called SuperAwesome Strip Frameworks into the build phases.

That script is only activated when the Xcode project is archived.

(Option 2): Selecting supported architectures

In the Target > Build Settings > Valid Architectures menu, make sure i386 and x86_64 is not in the list.

image-title-here

(Option 3 - Deprecated): Removing inactive code using a Run Script

Note: This option is now deprecated in favour of `Option 1`.

After the frameworks are embedded to the binary, the unused code can be thinned using lipo command to create a new binary without simulator architecture codes.

  1. Select your project file
  2. Select the main target i.e. Unity-iPhone
  3. Click Build Phases.
  4. Click + (add) button on the top left corner, and select New Run Script Phase Note: A new run script added to the list image-title-here
  5. Expand the new run script and copy the following script in it
# Signs a framework with the provided identity
code_sign() {
  # Use the current code_sign_identitiy
  echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
  echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements $1"
  /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1"
}

echo "Stripping frameworks"
cd "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}"

for file in $(find . -type f -perm +111); do
  # Skip non-dynamic libraries
  if ! [[ "$(file "$file")" == *"dynamically linked shared library"* ]]; then
    continue
  fi
  # Get architectures for current file
  archs="$(lipo -info "${file}" | rev | cut -d ':' -f1 | rev)"
  stripped=""
  for arch in $archs; do
    if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
      # Strip non-valid architectures in-place
      lipo -remove "$arch" -output "$file" "$file" || exit 1
      stripped="$stripped $arch"
    fi
  done
  if [[ "$stripped" != "" ]]; then
    echo "Stripped $file of architectures:$stripped"
    if [ "${CODE_SIGNING_REQUIRED}" == "YES" ]; then
      code_sign "${file}"
    fi
  fi
done
echo "Stripping done"

Note: Make sure the newly added run script is at the end of the list in the build phases

Note 2: Select Run script only when installing to only use this script for archiving