Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneSignal OneSignalNotificationExtension build fail on Xcode 12 related to cocoapods / architecture / simulator issues #1036

Closed
dowmeister opened this issue Aug 31, 2020 · 34 comments · Fixed by #1053
Assignees

Comments

@dowmeister
Copy link

dowmeister commented Aug 31, 2020

Description:

Just updated from Xcode 10 to Xcode 12, before on v10 this project built and run successful.

OneSignalNotificationExtension target build fail:

Undefined symbol: _swift_getObjCClassMetadata

Undefined symbol: type metadata accessor for Foundation.UUID

Undefined symbol: Swift._bridgeAnythingToObjectiveC<A>(A) -> Swift.AnyObject

Undefined symbol: protocol descriptor for Swift.ExpressibleByFloatLiteral

Undefined symbol: associated conformance descriptor for Swift.ExpressibleByFloatLiteral.Swift.ExpressibleByFloatLiteral.FloatLiteralType: Swift._ExpressibleByBuiltinFloatLiteral

Undefined symbol: associated type descriptor for Swift.ExpressibleByFloatLiteral.FloatLiteralType

Undefined symbol: protocol descriptor for Swift.ExpressibleByIntegerLiteral

Undefined symbol: associated type descriptor for Swift.ExpressibleByIntegerLiteral.IntegerLiteralType

Undefined symbol: method descriptor for Swift.ExpressibleByIntegerLiteral.init(integerLiteral: A.IntegerLiteralType) -> A

Undefined symbol: static Foundation.UUID._unconditionallyBridgeFromObjectiveC(__C.NSUUID?) -> Foundation.UUID

Undefined symbol: value witness table for Builtin.Int32

Undefined symbol: protocol witness table for Swift.Int : Swift._ExpressibleByBuiltinIntegerLiteral in Swift


and 100 errors more

I'm not so good on Xcode and Mac so I'm sorry if it's no clear or misleading.

Thank you

Environment

react-native 0.63.2
onesignal-react-native 3.9.1
Xcode 12
Installed via npm and linked with pods

Steps to Reproduce Issue:

  1. Build
@rgomezp
Copy link
Contributor

rgomezp commented Sep 1, 2020

Howdy,
What does your NotificationService.swift file look like? It should be something like:

import UserNotifications

import OneSignal

class NotificationService: UNNotificationServiceExtension {
    
    var contentHandler: ((UNNotificationContent) -> Void)?
    var receivedRequest: UNNotificationRequest!
    var bestAttemptContent: UNMutableNotificationContent?
    
    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.receivedRequest = request;
        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
        
        if let bestAttemptContent = bestAttemptContent {
            OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    }
    
    override func serviceExtensionTimeWillExpire() {
        // Called just before the extension will be terminated by the system.
        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
            OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    }
    
}

Take a look at step 4.3.6 in the setup instructions and continue from there to ensure you've set up everything correctly.

Hope this helps. Cheers

@dowmeister
Copy link
Author

Thanks for the feedback.

I'm using the Objective-C file. Should I use the swift one?

@rgomezp
Copy link
Contributor

rgomezp commented Sep 1, 2020

I thought you were using Swift. If you're using Obj-C use the Objective C one. Enjoy!

@carloscuesta
Copy link
Contributor

carloscuesta commented Sep 21, 2020

I’m having some issues too with Xcode 12

I can successfully build the project on Xcode 11. However as soon as I open the Xcode12 and build the project I get the following error:

▸ Linking OneSignalNotificationServiceExtension

❌  clang: error: no such file or directory: '/Users/carloscuesta/project-folder/ios/build/project/Build/Products/Debug-iphonesimulator/libRCTOneSignal.a'

This doesn’t seems an error from OneSignal side. Looks like there’s something weird with cache or something like that,
things I tried:

  • Delete Xcode Derived Data - rm -rf ~/Library/Developer/Xcode/DerivedData/
  • Clear react-native, yarn cache and reinstall dependencies.
  • Reset simulator data and contents
  • Restarted the computer

I don't know what else I should try, I would say that everything is linked properly since the application is working good on Production and the build works with Xcode 11.

I have the library linked manually using the OneSignal guide, any idea on how to fix this ? 🙏🏼

Typically when I got this issue it was solved by cleaning the DerivedData but I can't get rid of the error 😞

@carloscuesta
Copy link
Contributor

I've discovered something weird,

If I try to build the application with Xcode 12, it always fails. However If I build the application first with Xcode 11 and then open up Xcode 12 and build the app it works 🤯

However as soon as I clean build and try to rebuild again with Xcode 12 it starts to fail with the same error again 😖

@stefanocapitanio
Copy link

Same error here with with Xcode 12 and onesignal-react-native 3.9.1 :-(
Projects were working before the update.

@bugsniper
Copy link

Same error.
Onesignal SDK -> 2.15.2
react-native-onesignal -> 3.9.1
Worked well on xCode 11.

@rgomezp
Copy link
Contributor

rgomezp commented Sep 24, 2020

Howdy,
That's strange @carloscuesta . Have you tried seeing a diff between the project on Xcode 11 vs 12? Perhaps 12 is changing some important build settings for some reason.

@mattop1709
Copy link

Got similar issue when I updated my Xcode from 11 to 12..

@carloscuesta
Copy link
Contributor

carloscuesta commented Sep 25, 2020

Hey @rgomezp

I can confirm that there's no changes from Xcode 11 to Xcode 12. The git status of the repo is unmodified.

However I can still reproduce the build failed. And whenever I build on Xcode 11 and Xcode 12 after works for the first time 😕

Screenshot 2020-09-25 at 12 12 40

Screenshot 2020-09-25 at 12 18 39

@rgomezp
Copy link
Contributor

rgomezp commented Sep 25, 2020

Howdy,
I believe this is related to the ongoing Cocoapods issue which was previously reported here.

This might work add x86_64 to VALID_ARCH if need to run app on simulator, e.g., x86_64 arm64 arm64e

This stack overflow might contain the solution you need.

@carloscuesta
Copy link
Contributor

carloscuesta commented Sep 28, 2020

Hey! Thanks for your help @rgomezp

I will tell you the results of my experiments!

Add Excluded Architectures

I introduced arm64 as suggested on the StackOverflow post on the Project> Architectures > Excluded Architectures.

Screenshot 2020-09-28 at 13 40 32

This didn't fix the problem. I've got the same error complaining about x86_64.

Screenshot 2020-09-28 at 13 39 50

So I went ahead and added x86_64 to the Excluded Architectures.

Screenshot 2020-09-28 at 13 41 12

After the following change, the following error seems to be fixed. However I've got another error regarding to the OneSignalNotificationServiceExtension.appex.

Embedded binary is not signed with the same certificate as the parent app. Verify the embedded binary target's code sign settings match the parent app's.

However I did not change anything related with CodeSign 🤔 – The Xcode11 build works fine

Screenshot 2020-09-28 at 11 36 29

After cleaning the DerivedData build and restart the computer. I'm seeing another error: Link app (i386).

If I open the error, I see that a lot of files are not being found on the DerivedData folder. None of them related with OneSignal. However I don't know why this is failing if it works properly on Xcode 11. I'm so confused right now 😅

Use VALID_ARCHS

This hasn't worked for me either. I also read that this is deprecated on Xcode 12 and Excluded Architecturesshould be used instead.

I didn't had any User-Defined Setting for this. Since I'm not using CocoaPods and I've got the module linked manually.

@carloscuesta
Copy link
Contributor

carloscuesta commented Sep 28, 2020

I found and interesting link that talks about the "same certificate" error with Xcode after excluding arm64.

It says that the extensions should not exclude those architectures. Same error unfortunately :(

I'm out of ideas for today 😅

@carloscuesta
Copy link
Contributor

carloscuesta commented Sep 29, 2020

I can confirm that building and running the application on a real device does not throws any error without the "Excluded Architectures" modifications.

So it's something related 100% with the architecture of the simulator itself

Screenshot 2020-09-29 at 09 17 24

@rgomezp rgomezp changed the title OneSignalNotificationExtension build fail on Xcode 12 OneSignal OneSignalNotificationExtension build fail on Xcode 12 related to cocoapods / architecture / simulator issues Oct 1, 2020
@rgomezp
Copy link
Contributor

rgomezp commented Oct 1, 2020

Hola Carlos,
Thank you for the detailed investigation. For visibility, I also found this stack overflow thread.

To summarize @carloscuesta issue,

  1. The Embedded binary is not signed with the same certificate as the parent app... error is resolved by adding arm64 and x86_64 to the Excluded Architectures, per guidance to use this over VALID ARCHS.
  2. The workaround posted in the Cocoapods repository didn't work for you because you have the library manually linked.

Carlos, at this point I am not sure what else can be done since this sounds like a non-OneSignal issue.

Can other folks please confirm that the Cocoapods workaround linked above works for them if they are using Cocoapods?

@carloscuesta
Copy link
Contributor

carloscuesta commented Oct 2, 2020

Hey @rgomezp

Thanks for all the help you provided.

Carlos, at this point I am not sure what else can be done since this sounds like a non-OneSignal issue.

I'm not 100% sure with this statement since If I unlink the whole OneSignal library and I remove the OneSignalNotificationServiceExtension the project builds on Xcode12. I don't know where the error is coming from that's for sure and maybe that's a specific case since the library is manually linked. And I don't have to touch anything related with architectures

But yeah, let's see if we can found another use cases 👍🏼

@stanleyctcl
Copy link

It seems Xcode 12 build for simulator with architecture - arm64, i386, x86_64.

So my workaround solution is

  1. Add arm64 in Excluded Architectures of Project Build setting
  2. Remove VALID ARCHS from RCTOneSignal subproject build setting.
    (VAILD ARCHS was moved to User-Defined of build setting in Xcode 12)

It works well in my project.

@carloscuesta
Copy link
Contributor

carloscuesta commented Oct 7, 2020

@stanleyctcl Your solution works! 🎉

I didn't saw the RCTOneSignal target inside of the RCTOneSignal library had the VALID_ARCHS defined as a User-Defined setting. This is something we should remove from the Library side! I'm going to make a PR to fix the issue!

Screenshot 2020-10-07 at 10 22 44

That's why all my changes didn't work. Because the OneSignal library has this User-Setting defined.

@abdullahizzuddiin
Copy link

abdullahizzuddiin commented Oct 8, 2020

Hey, thanks @stanleyctcl
Your solution worked for me.

Previously, my build on release mode to iOS Simulator is failed. I got building for iOS Simulator, but linking in object file built for iOS, file onesignal error. But, I can build release mode on real device without any errors appeared. The solution above solved this issue.

Unfortunately, after I implemented your solution, I could not Archive my app. I got this error.

No architectures to compile for (ARCHS=arm64, VALID_ARCHS=arm64 arm64e armv7 armv7s, EXCLUDED_ARCHS=(
    arm64
))

any clue?

@carloscuesta
Copy link
Contributor

@abdullahizzuddiin Make sure you only Excluded the architecture for iOS simulators

@abdullahizzuddiin
Copy link

abdullahizzuddiin commented Oct 8, 2020

Ah, my bad. I forgot the little detail. Thanks @carloscuesta for pointing me. It turned out that I only need set Excluded Architecture without removed VALID ARCHS from RCTOneSignal subproject build setting. 🤔

= = =
I think, I got difference error. I have archived successfully. But, after I chose "Automatically Manage Signing", I got this error
image

I can deploy an app to Appstore without any problem on previous version of Xcode. Previously, I used 11.7. Now, I used 12.0 and I instantly got this error without any changes on my repo.

//package.json
react-native-onesignal: 3.8.1

//Podfile
pod 'OneSignal', '>= 2.14.2', '< 3.0'
...
target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignal', '>= 2.14.2', '< 3.0'
end

Any clue? or should I create separated issue?

p.s:
I also have submitted my issue to Apple Developer Forum just in case that is not this library's problem.

@mattop1709
Copy link

i am using react-native-onesignal 3.9.1 on react native 0.60.0 version...I am able to resolve this issue by including x86_64 inside User-Defined settings (VALID_ARCHS)

@rgomezp
Copy link
Contributor

rgomezp commented Oct 26, 2020

Howdy y'all,
I think this issue is safe to close since it doesn't seem to be a OneSignal issue.


@abdullahizzuddiin
(Different Issue, consider opening a separate ticket)

For visibility, I will post one of the responses to the Apple Dev Forum thread:

PROBLEM:
Trying to run build on actual device failed, even though the build is successful on my MacBook Pro.
The following error occurred with this message:
Provisioning profile "iOS Team Provisioning Profile: com.xxxxxxxxxxxx.Name of -App" doesn't include the currently selected device "iPhone" (identifier 0000xxxx-000xxxxxxxxxxxxxxxxxx).

Xcode Help Online Manual

Accounts preferences
Use Accounts preferences to manage developer account assets (signing certificates and provisioning profiles), add repositories, and add servers.

To open Accounts preferences, choose Xcode > Preferences and click Accounts.
I Then I clicked on, manage certificates, and added a new certificate by clicking on the plus symbol.

PROBLEM SOLVED:
I then ran my build and my signing error cleared, app was installed on my iPhone 11 Pro Max.
Hopefully this solution helps you.

@rgomezp rgomezp closed this as completed Oct 26, 2020
@carloscuesta
Copy link
Contributor

Hey @rgomezp

This issue was a mix of different problems. The one you're pointing has nothing to do with the Simulator issue itself, that is something that has to do with RCTOneSignal because the usage of VALID_ARCHS

I don't know if we should close this issue completely until the simulator one is solved.

@abdullahizzuddiin
Copy link

Hi @rgomezp

I've followed the suggestion from Apple Dev Forum that you excerpted above. But, it didn't solved my problem.

Temporarily, I downgraded Xcode version to 11.7 and I able to build, run, and archived successfully. But, I still can do those act in Xcode 12.0

@rgomezp
Copy link
Contributor

rgomezp commented Oct 27, 2020

I will leave this open to be closed automatically by #1053

@rgomezp rgomezp reopened this Oct 27, 2020
@haorh
Copy link

haorh commented Nov 2, 2020

It seems Xcode 12 build for simulator with architecture - arm64, i386, x86_64.

So my workaround solution is

1. Add **arm64** in  **Excluded Architectures** of Project Build setting

2. Remove **VALID ARCHS** from RCTOneSignal subproject build setting.
   **(VAILD ARCHS was moved to User-Defined of build setting in Xcode 12)**

It works well in my project.

This works for me. Remember to delete it. Not just make it blank "" as it would not work

edit:
My project uses manual linking One signal 3.2.12.
react-native 0.59.9
xcode 12

I tried stanleyctcl solution which works in simulator for debug and release build. But when build for Generic device/Archive I faced the same problem as abdullahizzuddiin

No architectures to compile for (ARCHS=arm64, VALID_ARCHS=arm64 arm64e armv7 armv7s, EXCLUDED_ARCHS=(
arm64
))

The solution that worked for me is
Apply this only

2. Remove **VALID ARCHS** from RCTOneSignal subproject build setting.
   **(VAILD ARCHS was moved to User-Defined of build setting in Xcode 12)**

This should make Archive work but simulator release fail. To fix that. you need to go All project target's and pod's target -> Build Settings -> Architecture -> Build Active Architecture Only -> Set 'Yes' for release mode

Explanation and Steps on: https://stackoverflow.com/a/64139830/9232424.
Further read: https://medium.com/macoclock/deep-drive-xcode-build-settings-827c3ce4811c.

@MoeMamdouh
Copy link

Ah, my bad. I forgot the little detail. Thanks @carloscuesta for pointing me. It turned out that I only need set Excluded Architecture without removed VALID ARCHS from RCTOneSignal subproject build setting. 🤔

= = =
I think, I got difference error. I have archived successfully. But, after I chose "Automatically Manage Signing", I got this error
image

I can deploy an app to Appstore without any problem on previous version of Xcode. Previously, I used 11.7. Now, I used 12.0 and I instantly got this error without any changes on my repo.

//package.json
react-native-onesignal: 3.8.1

//Podfile
pod 'OneSignal', '>= 2.14.2', '< 3.0'
...
target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignal', '>= 2.14.2', '< 3.0'
end

Any clue? or should I create separated issue?

p.s:
I also have submitted my issue to Apple Developer Forum just in case that is not this library's problem.

Same issue happened with me in xcode 12, Did you solve the issue? @abdullahizzuddiin or u just downgrade the xcode to 11.7

thank you

@zanuzzorz
Copy link

To run in the simulator, I have to add "arm64" in "Excluded architectures".
But, to run the application on a real device, I have to leave it without the "Excluded Architectures" modifications.
So I have to make this change every time I run.

I hope this helps.

@hugoh59
Copy link

hugoh59 commented Mar 1, 2021

Same issue here, it came back.

@bonzoq
Copy link

bonzoq commented Mar 19, 2021

Same

1 similar comment
@pbassut
Copy link

pbassut commented May 17, 2021

Same

@Ingibjorg
Copy link

Ingibjorg commented Sep 16, 2021

@rgomezp I'm seeing this issue after updating to "react-native-onesignal": "^4.3.0" and pod 'OneSignal', '>= 3.0', '< 4.0'. Archiving the build fails with:

ValidateEmbeddedBinary myapp.app/PlugIns/OneSignalNotificationServiceExtension.appex (in target 'myapp' from project 'myapp')
    cd myapp/ios
    /Applications/Xcode.app/Contents/Developer/usr/bin/embeddedBinaryValidationUtility /Library/Developer/Xcode/DerivedData/myapp-gudlkkufjyxbavdfhrwmmgvvdtfo/Build/Intermediates.noindex/ArchiveIntermediates/myapp\ staging/InstallationBuildProductsLocation/Applications/myapp.app/PlugIns/OneSignalNotificationServiceExtension.appex -signing-cert 6FA2A86CDFC1FEAA77CB97359B8B7FFE6B1748E4 -info-plist-path /Library/Developer/Xcode/DerivedData/myapp-gudlkkufjyxbavdfhrwmmgvvdtfo/Build/Intermediates.noindex/ArchiveIntermediates/myapp\ staging/InstallationBuildProductsLocation/Applications/myapp.app/Info.plist

error: Embedded binary is not signed with the same certificate as the parent app. Verify the embedded binary target's code sign settings match the parent app's.

EDIT
This ended up solving my issue: https://stackoverflow.com/a/27908394/3629481

@pinchez254
Copy link

i am using react-native-onesignal 3.9.1 on react native 0.60.0 version...I am able to resolve this issue by including x86_64 inside User-Defined settings (VALID_ARCHS)

Where do I find this settings in xcode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.