iOS EAS Build with OneSignal NotificationExtension

Hey everyone! :slight_smile:

After installing the OneSignal library in an ejected app through the Bare Workflow, I’m having some trouble building the .ipa for a TestFlight submission.

The OneSignal installation requires creating an extension. Since I’m using Expo Application Services, and therefore the eas build --platform ios command to build my app, I get the following output.

// ♥ eas build --platform ios
★ eas-cli@0.3.0 is now available, please upgrade.
Proceeding with outdated version

✔ Linked to project [redacted]
✔ Using remote iOS credentials (Expo server)
If you provide your Apple account credentials we will be able to generate all necessary build credentials and fully validate them.
This is optional, but without Apple account access you will need to provide all the values manually and we can only run minimal validation on them.
✔ Do you want to log in to your Apple account? … yes

› Log in to your Apple Developer account to continue
✔ Apple ID: … [redacted]
› Restoring session [redacted]
› Team [redacted]
› Provider [redacted]
✔ Logged in Local session
✔ Bundle identifier registered com.open.baton
✔ Synced capabilities
✔ Fetched Apple distribution certificates
Wrong bundleIdentifier found in provisioning profile; expected: com.test.sample, found (in provisioning profile): com.test.sample.OneSignalNotificationServiceExtension
✔ Fetched Apple provisioning profiles
✔ Generate a new Apple Provisioning Profile? … yes
✔ Created Apple provisioning profile
✔ Created provisioning profile

Project Credentials Configuration:
 Project: [redacted]
  Provisioning profile (ID: [redacted])
  Apple Team ID: [redacted] , Apple Team Name: ---------

 Distribution Certificate - Certificate ID: [redacted]
  Apple Team ID: [redacted] , Apple Team Name: ---------

All credentials are ready to build [redacted]

✔ Uploaded to EAS 2s

Build details: [redacted]

Waiting for build to complete. You can press Ctrl+C to exit.
✖ Build failed
  Error: Standalone build failed!

Here’s the output after running expo diagnostics:

Expo CLI 4.0.17 environment info:
  System:
   OS: macOS 11.1
   Shell: 3.2.57 - /bin/bash
  Binaries:
   Node: 14.5.0 - /usr/local/bin/node
   Yarn: 1.21.1 - /usr/local/bin/yarn
   npm: 6.13.7 - ~/.npm-global/bin/npm
   Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
   CocoaPods: 1.10.0 - /usr/local/bin/pod
  SDKs:
   iOS SDK:
    Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
  IDEs:
   Android Studio: 4.1 AI-201.8743.12.41.6953283
   Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  npmPackages:
   expo: ~40.0.0 => 40.0.0 
   react: 16.13.1 => 16.13.1 
   react-dom: 16.13.1 => 16.13.1 
   react-native: ~0.63.4 => 0.63.4 
   react-native-web: ~0.13.12 => 0.13.18 
   react-navigation: ^4.0.10 => 4.0.10 
  npmGlobalPackages:
   expo-cli: 4.0.17
  Expo Workflow: bare

For some reason, I keep getting this message: Wrong bundleIdentifier found in provisioning profile; expected: com.test.sample, found (in provisioning profile): com.test.sample.OneSignalNotificationServiceExtension

For those who have ejected into the Bare Workflow and have installed either OneSignal or a library that creates an extension in Xcode, how have you navigated using Expo to continue to build your projects? Is this possibly a bug with Expo Application Services?

Thanks in advance for your help!

1 Like

Hi! This is an excellent question- you actually need to do some additional configuration to get multiple targets working with EAS Build- specifically you need to provide the provisioning profile for the second target. Read here for more details on that.

Hi charlie, thanks for the quick response!

Understandably; however, how will EAS Build retrieve the credentials.json file? Does this happen automatically?

Also, how do I retrieve the provisioning and distribution certificate for my main app target? How do I retrieve the provisioning for my extension target?

Finally, is there a community/forum/slack for people who use EAS? I think this will be very helpful, especially since not all Expo users have migrated over to EAS. These forums are helpful; however, when we’re posting issues where a small number of users can relate to, it begs the question of is there a focused space where we can discuss these matters with users of EAS who are going through something similar?

I’m sure that there’s a substantial portion of Expo users who have ejected into the Bare Workflow in order to use OneSignal and are perhaps using the 30 day trial of EAS.

how will EAS Build retrieve the credentials.json file

Automatically, if there is a credentials.json file present. You can read about that in the documentation I linked above

For your provisioning profiles, Expo can create the one for your main app target, but you’ll need to follow OneSignal’s guide on credentials for the additional target, I’m not familiar with that flow. Once you create it (my assumption is via Xcode), you can export the .provisioning file.

We don’t have a community specifically for EAS, but there is now a category specifically for EAS-related questions, thanks for that suggestion!

Gotcha! I assume that if I check “Automatically manage signing” in my main app target > Signing and Capabilities tab, is this when Expo automatically creates the provisioning profile?

Also, if Expo is automatically creating a provisioning profile for Expo, does that mean that I should exclude the multitarget’s code logic from the credentials.json file below?

{
  "ios": {
    "multitarget": {
      "provisioningProfilePath": "ios/certs/multitarget-profile.mobileprovision",
      "distributionCertificate": {
        "path": "ios/certs/dist.p12",
        "password": "DISTRIBUTION_CERTIFICATE_PASSWORD"
      }
    },
    "shareextension": {
      "provisioningProfilePath": "ios/certs/shareextension-profile.mobileprovision",
      "distributionCertificate": {
        "path": "ios/certs/another-dist.p12",
        "password": "ANOTHER_DISTRIBUTION_CERTIFICATE_PASSWORD"
      } }
  }
}

You can only allow Xcode to automatically manage signing when you’re running builds locally on your own machine, that’s why through Expo you need to provide credentials (either via credentials.json or by storing them on our servers). For apps with multiple targets, you must use credentials.json.

Also, if Expo is automatically creating a provisioning profile for Expo, does that mean that I should exclude the multitarget’s code logic from the credentials.json file below?

No- I meant that Expo can create that for you. But if you use local credentials, you still need to provide it manually (if you’ve already let Expo generate those credentials for you, you can get them with eas credentials- but like I said, that will only be your app target’s credentials, not your notification extension credentials. For a build to succeed, you must provide both in credentials.json).

Understandably, I see now.

So after adding the certificates and provisioning profiles and the necessary code logic for the paths to the credentials.json file, should I run the eas credentials command and choose “update the credentials on the Expo servers with values from credentials.json?” Once doing so, I assume that running eas build --platform ios will hopefully build successfully?

Also, if Expo will in turn use the credentials from credentials.json, what will happen to the push certificate that Expo created since I’m also using expo-notifications? Will the OneSignal extension overwrite the push certificate that Expo had created, and therefore, rendering the expo-notifications functionality in my app now useless?

I’ve gone ahead and did the following.

  • Added credentials.json at the root of my project.

  • Completed the credentials.json file.

  • Added the necessary provisioning profiles and distribution certificates for both the main app target and the extension.

  • Ran the command eas build --platform ios.

Unfortunately, I’m met with this error:

Error: credentials.json is not valid [ValidationError: "ios.provisioningProfilePath" is 
    required. "ios.distributionCertificate" is required]

I’m not sure why this is happening. Here are the contents of my credentials.json file:

{
  "ios": {
    "Looper": {
      "provisioningProfilePath": "/Users/[redacted]/Documents/Development-ReactNative/Looper/ios/Certs/profile.mobileprovision",
      "distributionCertificate": {
        "path": "/Users/[redacted]/Documents/Development-ReactNative/Looper/ios/Certs/dist-cert.p12",
        "password": "[redacted]"
      }
    },
    "AppExtension": {
      "provisioningProfilePath": "/Users/[redacted]/Documents/Development-ReactNative/Looper/ios/Certs/extension-profile.mobileprovision",
      "distributionCertificate": {
        "path": "/Users/[redacted]/Documents/Development-ReactNative/Looper/ios/Certs/extension.p12",
        "password": "[redacted]"
      } }
  }
}

It seems that EAS is assuming that I’m just building an app with out a target, hence the error that it’s looking for ios.provisioningProfilePath and ios.distributionCertificate. I’m confused as to why this is happening even after following the documentation listed here. Effectively, it doesn’t seem that EAS is actually looking for my app and extension target.

should I run the eas credentials command and choose “update the credentials on the Expo servers with values from credentials.json?” Once doing so, I assume that running eas build --platform ios will hopefully build successfully?

As it says in the docs you need to use local credentials for multi-target apps, so updating the credentials on Expo’s servers doesn’t matter- you want to get your existing credentials for you main target from Expo’s servers (depending on how exactly you handle your credentials), and then supply them locally

what will happen to the push certificate that Expo created since I’m also using expo-notifications ? Will the OneSignal extension overwrite the push certificate that Expo had created, and therefore, rendering the expo-notifications functionality in my app now useless?

I think using both expo-notifications and OneSignal could cause some complications, so I’m curious why you’re doing this instead of relying on just a single service? Regardless, the OneSignal extension does not require it’s own APN key, so it shouldn’t have any effect (I could be wrong here, you may have to comb through OneSignal’s docs or ask them for some help)

What version of eas-cli are you running? Support for multi targets was just released, so you should make sure you’re on the most recent version

Here’s what happens when I run eas

Screen Shot 2021-01-24 at 7.48.24 PM (2)

It doesn’t seem like I’m in fact using the latest version as I’m prompted with this.

Screen Shot 2021-01-24 at 7.41.28 PM (2)

How do I upgrade EAS?

Nevermind, it seems that I was able to figure it out. I ended up upgrading both expo-cli and eas-cli using npm install -g expo-cli and npm install -g eas-cli, respectively.

Now, when I run eas it shows this.

Screen Shot 2021-01-24 at 8.03.15 PM (2)

You aren’t running any command, you’re just running eas which is the name of the CLI tool

I think using both expo-notifications and OneSignal could cause some complications, so I’m curious why you’re doing this instead of relying on just a single service? Regardless, the OneSignal extension does not require it’s own APN key, so it shouldn’t have any effect (I could be wrong here, you may have to comb through OneSignal’s docs or ask them for some help)

Currently, I’m using Expo for local notifications. However, I’ve decided to integrate OneSignal so that I can use remote notifications that will allow for measuring metrics and analytics. I didn’t know that there would be a conflict when using both services, expo-notifications and one-signal.

Thank you again for the help, I was able to successfully get a build. The only tricky part was getting the .p12 file. For those who need guidance later on, this link will help.

I’ll proceed with the testing OneSignal and report back if there are any issues having both expo-notifications and one-signal co-existing in the same project.

1 Like