Troubleshoot Issues in iOS Service Extensions

This guide provides a structured approach to troubleshooting common issues in iOS Service Extensions, ensuring seamless integration and functionality.

Resolve Embedded Binary Signing Issues 

Embedded binary signing errors occur when you disable automatic signing and your Main Target and Notification Service Extension are signed with different certificates. If you encounter build failures or runtime issues related to code signing, follow these troubleshooting steps.

Check Your Certificates 

  1. Make sure that the certificate you used for the parent app (main app) is the same as the one you used for the embedded extension.
  2. Use the same distribution certificate for both targets.

Verify Provisioning Profiles 

  1. On Xcode, navigate to Preferences > Accounts and make sure you selected the correct provisioning profile.
  2. Make sure that both the parent app and the embedded binary share the same provisioning profile, and includes the right entitlements for both.
  3. In case of manual profiles, download and install the latest provisioning profiles from the Apple Developer website.

Update the Embedded Binary’s Signing Settings 

  1. In the Xcode project navigator, select the embedded binary.
  2. Go to General > Signing & Capabilities.
  3. Make sure Automatically manage signing is checked. If not, manually set the correct Team, Signing Certificate, and Provisioning Profile.
  4. Make sure the embedded binary uses the same certificate and provisioning profile as the main app.

Check App Settings 

  1. Make sure both the main app target and the embedded binary target are set to use the same provisioning profile and the same signing certificate.
  2. Check each target’s Signing & Capabilities tab to verify this.

Validate Entitlements and Permissions 

Make sure both your app and its extension are set up to use the same App Group. Check the entitlements file and the App Groups setting in both the app and extension targets.

Example entitlements file
1<plist version="1.0">
2  <dict>
3    <!-- App Group for your app and extensions -->
4    <key>com.apple.security.application-groups</key>
5    <array>
6      <string>group.com.yourcompany.yourapp.shared</string>
7    </array>
8  </dict>
9</plist>

Check Info.plist Configuration 

A common source of errors in Service Extensions is incorrect Info.plist settings. To avoid potential issues, review these key configurations.

Extension Key 

Make sure the NSExtension key in your extension’s Info.plist is set up correctly. For the Notification Service Extension, make sure that NSExtensionPrincipalClass is properly set. If you’re using Swift, prefix it with $(PRODUCT_MODULE_NAME) to link to the Swift class.

Swift example
1<key>NSExtensionPrincipalClass</key>
2<string>$(PRODUCT_MODULE_NAME).NotificationService</string>
Objective-C example
1<key>NSExtensionPrincipalClass</key>
2<string>NotificationService</string>

AppGroup Key 

Make sure that the SF_MARKETINGCLOUD_APP_GROUP_KEY key in the Info.plist of your extension is set to the correct value.

Check NotificationService Setup 

To make sure your Notification Service Extension functions correctly with the SDK, verify these configurations.

Verify Correct Class Inheritance 

Make sure your NotificationService class inherits from SFMCNotificationService. Incorrect inheritance can cause the extension to not work properly.

Enable Debug Logging 

Enable debug-level logging using the sfmcProvideConfig() method to help debug any issues when setting up the SDK.

Swift example
1override func sfmcProvideConfig() → SFNotificationServiceConfig {
2        return SFNotificationServiceConfig(logLevel: .debug)
3    }
Objective-C example
1- (SFMCNotificationServiceConfig *)sfmcProvideConfig {
2        return [[SFMCNotificationServiceConfig alloc] initWithLogLevel:SFMCExtensionSdkLogLevelDebug];
3    }

Check for Background Task Limitations 

Notification Service Extension has a limited time to handle notifications. Make sure your code doesn’t exceed these limits. For more information, see the official documentation on Apple Developer.

Handle App Crashes or Freezing 

Service extensions can have memory issues or use too many resources. Use Xcode’s Instruments (like Allocations and Leaks) to monitor memory usage and stay within limits.