Add the framework and use App Shielding APIs
  • 18 Oct 2024
  • 2 Minutes à lire
  • Sombre
    Lumière

Add the framework and use App Shielding APIs

  • Sombre
    Lumière

The content is currently unavailable in French. You are viewing the default English version.
Résumé de l’article

Adding the framework

When using the APIs provided by App Shielding, the header files and library must be available during compilation.

The instructions in this topic describe the process for Xcode 14.2. For other versions of Xcode, the steps can be different.

To add the framework

  1. In the project navigator, select the project with which you want to use App Shielding.

  2. In the editor view, select the target with which you want to use App Shielding.

  3. Select the General tab.

  4. Drag and drop ShieldSDK.xcframework from the App Shielding package into the Frameworks, Libraries and Embedded Content item.

  5. Verify that Embed&Sign is selected in the drop-down list for ShieldSDK.xcframework.

Dependency Managers

If you use a dependency manager that zips the XCFramework, or you zip the XCFramework yourself, you must ensure that the symlinks are preserved to avoid invalidating the signature. This is accomplished using the zip command -y option. For example:

zip -r -y ShieldSDK.xcframework.zip ShieldSDK.xcframework

If your dependency manager does not have an option to preserve symlinks, you can re-sign the XCFramework bundle with your own distribution certificate after unpacking the zip file.

Using App Shielding APIs in an application

If the application is using APIs provided by App Shielding, it needs access to those APIs during compilation, linking, and runtime.

To use App Shielding in an application

  1. Add ShieldSDK.xcframework to the project as outlined in Adding the framework.

  2. Any code that is to use an App Shielding API must import ShieldSDK/Shield.h.

  3. You also need to shield the application through the OneSpan Customer Portal or OneSpan Mobile Portal.

In the shielding procedure on the OneSpan Customer Portal or OneSpan Mobile Portal, you must process Step 3. If you skip it, the App Shielding APIs will not work because App Shielding will not be injected.

Using App Shielding APIs in another framework

It is also possible to add the ShieldSDK.xcframework to another framework. To do so, you need to link ShieldSDK.xcframework, your framework, and your app.

The application into which you integrate your framework still needs to be shielded after you added the framework!

To link ShieldSDK.xcframework, your framework, and your app

  1. Link ShieldSDK.xcframework to your framework but do not embed it.

  2. Link your framework to the application and embed it.

  3. Embed ShieldSDK.xcframework into your application; linking it is not necessary but is also an option.

After linking, shield the application through the OneSpan Customer Portal or OneSpan Mobile Portal.

You can use App Shielding APIs in your framework in the same way as in an application, and you can even use it in both an application and a framework. If you use it in both, however, they will share the same instance, so any operations performed will equally affect your application and the framework.

For callbacks to work correctly, they need to be hooked as early as possible. Since a framework usually does not implement the main AppDelegate object, you must call a framework initialize method from the didFinishLaunchingWithOptions method of your application's AppDelegate object. For this operation to succeed, you need to ensure that the callback observer is correctly set up.

 

//  Callbacks.swift

import ShieldSDK
 
internal class Callbacks: NSObject, PRMShieldEventDelegate {
 
  func start()  {
    PRMShieldEventManager.shared.add(observer: self)

    if #unavailable(iOS 16) {
      print("Developer mode status checking unavailable pre-iOS 16.")
    }
  }
 
  func jailbreak(status: isJailbroken: Bool) {
    if isJailbroken { 
      handleDeviceisJailbroken()
    }
  }

  func screenshotDetected() {
    handleScreenShotDetected()
  }
}

You can also invoke the initialization using other constructors, for example, Objective-C +load static constructor, a C++ static initializer, or a C __attribute__(constructor).


Cet article vous a-t-il été utile ?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, facilitant la découverte de connaissances grâce à l’intelligence conversationnelle