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

[Bug]: 'Error loading' crash when app started to run #553

Open
1 task done
muhammedrollic opened this issue Nov 10, 2022 · 22 comments
Open
1 task done

[Bug]: 'Error loading' crash when app started to run #553

muhammedrollic opened this issue Nov 10, 2022 · 22 comments

Comments

@muhammedrollic
Copy link

muhammedrollic commented Nov 10, 2022

What happened?

I exported an iOS build with OneSignal SDK 3.0.5 from Unity. Builded the app without errors and I ran the app. During launching, app immediately closed with 'Library not loaded: '@rpath/OneSignalCore.framework/OneSignalCore' message.

I solved this issue by embeding OneSignal.xcframework to app target. In previous versions, I didn't need to embed framework manually.

Steps to reproduce?

1. Install OneSignal SDK 3.0.5 to Unity project
2. Set the SDK with OneSignal SDK Setup window
3. Export an iOS build
4. Build and run iOS project

What did you expect to happen?

I expected to build and run my iOS app without any additional configuration.

Unity version

2020.3.41f1
2021.3.13f1

OneSignal Unity SDK version

3.0.5

Platform

iOS

Relevant log output

2022-11-10 13:50:35.729029+0300 v2020[62145:2726679] Error loading /var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/UnityFramework:  dlopen(/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: '@rpath/OneSignalCore.framework/OneSignalCore'
  Referenced from: '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/UnityFramework'
  Reason: tried: '/usr/lib/swift/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/usr/lib/swift/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/System/Library/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file)
2022-11-10 13:50:35.730456+0300 v2020[62145:2726679] Error loading /var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/UnityFramework:  dlopen(/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: '@rpath/OneSignalCore.framework/OneSignalCore'
  Referenced from: '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/UnityFramework'
  Reason: tried: '/usr/lib/swift/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/usr/lib/swift/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/UnityFramework.framework/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/private/var/containers/Bundle/Application/46EB3F7D-CC1A-4E43-AF67-64A0C38B1449/v2020.app/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file), '/System/Library/Frameworks/OneSignalCore.framework/OneSignalCore' (no such file)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@shepherd-l
Copy link
Contributor

Hey, thanks for reporting. We are going to look into this

@Vladeng
Copy link

Vladeng commented Nov 22, 2022

Hey, thanks for reporting. We are going to look into this

Same problem with OneSignal SDK 3.0.6.

@muhammedrollic
Copy link
Author

Hey, thanks for reporting. We are going to look into this

Same problem with OneSignal SDK 3.0.6.

I think they did not add fix for this bug to v3.0.6. So, we have to wait for next versions.

@isInYourMind
Copy link

Same error. iOS is still crashing at startup with OneSignal 3.0.6

@vdaineko
Copy link

I have managed to fix it by switching to brew CocoaPods installation:

  1. Uninstall CocoaPods https://superuser.com/a/686319
  2. Install cocoapods with brew
    brew install cocoapods
  3. Make pod symbolik link because EMDU checks only standard paths for pod (/usr/local/bin and /usr/bin)
    sudo ln -s /opt/homebrew/bin/pod /usr/local/bin/pod

I don't know what the difference is, same CocoaPods versions (1.11.3), no errors in both cases, but somehow this fixed the problem.

@shepherd-l
Copy link
Contributor

Please make sure that you are using CocoaPods version 1.11.3. We’ve seen this issue appear when using versions lower than 1.11.3.

Try

rm Podfile.lock
pod cache clean --all
pod install --repo-update

@roointan
Copy link

roointan commented Dec 5, 2022

We have this same problem.
CocoaPods version 1.11.3
Xcode version 14.1
Unity 2021.3.14f1

What @shepherd-l suggested didn't work.
I tried adding $(inherited) to OTHER_LDFLAGS and LIBRARY_SEARCH_PATHS in Unity-iPhone target, didn't work.

Next I added
OneSignal.xcframework
OneSignalCore.xcframework
OneSignalExtension.xcframework
OneSignalOutcomes.xcframework
to UnityFramework Framework and libraries. It works fine on the development device with no startup crash, but when trying to upload to app store, we get another error:

Asset validation failed
CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value 'com.onesignal.OneSignal-Dynamic' under the iOS application ......

also for CFBundleIdentifiers "com.onesignal.OneSignalExtension"

Also another error, "UnityFramework.framework contains disallowed nested bundles"

@shepherd-l
Copy link
Contributor

Hey @roointan,

Could you check and make sure that your Ruby version is 2.7.5+ and that Cocoapods is 1.11.3 and try cleaning your pods again


We think the root cause of this issue is from updating to Xcode 14.1.

@roointan
Copy link

roointan commented Dec 5, 2022

@shepherd-l

CocoaPods is 1.11.3

system ruby version ruby --version is:
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin22]

ruby version installed by brew /usr/local/opt/ruby/bin/ruby --version is:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]

also, I should note, macOS version is 13.0.1

we had to update Xcode to version 14.1, because we have Firebase in our project too. Firebase has removed bitcode support, and we had to disable bitcode for other targets too. But after doing that project was not building with the old Xcode version, and the only solution we found was upgrading to 14.1

I removed ~/.cocoapods and retried pod install, didn't help.

I'm going to try what vdaineko suggested next.

@shepherd-l
Copy link
Contributor

@roointan

If that doesn’t work, you can try setting your system ruby to match your brew installed ruby so that your system ruby --version is 2.7.5+

And after that, clean with this again:

rm Podfile.lock
pod cache clean --all
pod install --repo-update

@roointan
Copy link

roointan commented Dec 6, 2022

@shepherd-l

using this ruby:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]

didn't help.
still getting an error on game start, but the error just looks different.

warning: UnityFramework was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb)

Thread 1 Queue : com.apple.main-thread (serial)
#0 0x000000010ada4390 in GetPreallocatedMemory [inlined] at /Users/bokken/build/output/unity/unity/Runtime/Allocator/MemoryManager.cpp:385
#1 0x000000010ada4390 in ::InitializeMemory() at /Users/bokken/build/output/unity/unity/Runtime/Allocator/MemoryManager.cpp:589
.
.
#22 0x000000010ada3618 in ::operator new() at /Users/bokken/build/output/unity/unity/Runtime/Allocator/MemoryManager.cpp:273
#23 0x000000019d0c3d74 in ___lldb_unnamed_symbol25507 ()

@roointan
Copy link

roointan commented Dec 6, 2022

I went a long way,
Uninstalled Pod (that was installed with brew) and reinstalled it with gem (With 3.1.2p20 as the system ruby)
ran rm -rf ~/cocoapods
exported the project from Unity again, disabled bitcode on OneSignalNotificationServiceExtension target, and built again.
all to get back to
dyld[2239]: Library not loaded: @rpath/OneSignalCore.framework/OneSignalCore
error on game start.

@roointan
Copy link

roointan commented Dec 6, 2022

I can build and run on device successfully by adding the following 4 to Framework and libraries of UnityFramework target
OneSignal.xcframework
OneSignalCore.xcframework
OneSignalExtension.xcframework
OneSignalOutcomes.xcframework

But can't upload to app store, because of the following errors:

Asset validation failed
CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value 'com.onesignal.OneSignal-Dynamic' under the iOS application ......

also for CFBundleIdentifiers "com.onesignal.OneSignalExtension"

Also another error, "UnityFramework.framework contains disallowed nested bundles"

@shepherd-l Do you have a solution for that?

@roointan
Copy link

roointan commented Dec 8, 2022

Is there any plan to solve this issue in short-term?
or even long term?
Or do we have to find a solution ourselves?

@emawby
Copy link
Contributor

emawby commented Dec 8, 2022

@roointan Do you have an example project with the issue that we can use to try to reproduce? We have not been able to reproduce this issue when using Cocoapods 1.11.3 and Ruby 2.7.5+. We have received example projects in other platforms (iOS native, flutter, and react native) that have the issue and it is always resolved when pod install is run on a machine using the versions I listed above (also running pod cache clean --all pod install --repo-update and removing derived data). We have not yet been able to pin down exactly what changed in our distributed binaries/folks build environments to cause this

@roointan
Copy link

roointan commented Dec 8, 2022

@emawby I'm working on a now large project, and I'd need to remove lots of things to be able to upload a sample project for you. I hope I can prepare something that builds, and doesn't have anything that I can not share. it could take some time.

But besides that, is there any way I can debug and get verbose information on the problem?
If running those pod commands is supposed to fix the issue, I guess it's something with pod.
So, is there a way to get verbose information of what is happening, or any log of a missing dependency or something that may help find the root cause of this?

@emawby
Copy link
Contributor

emawby commented Dec 8, 2022

@roointan Totally understandable I know that getting a sample project is not a small ask. Out of curiosity have you tried reproducing the issue on a brand new Unity project? I will work on identifying some more debugging steps for you. In the meantime you could also try OneSignal Unity version 3.0.3 or lower since I have seen some reports that the iOS SDK included in that version does not have this issue.

@roointan
Copy link

roointan commented Dec 8, 2022

@emawby Thanks.
Good idea with a brand new project. I'll try that later, and get back with an update.

@gpcoder
Copy link

gpcoder commented Dec 10, 2022

Hi,

I have exactly the same problem as roointan with the same version as him (xcode, ruby, cocoapods).

It's a very annoying bug that forces me to manage 2 different projects under Unity, one with the latest sdk for Android (otherwise I can't submit an update in API 31) and the other with a version 2 of Onesignal for iOS.

Solution:

Cocoapods 1.11.3
Ruby 3.0.0+
Delete your Xcode project
Generate a new Xcode project with unity
Open xcworkspace
OneSignalNotificationServiceExtension, Build settings, Build Options, Enable Bitcode NO

Good luck!

@roointan
Copy link

roointan commented Dec 11, 2022

Ok!!
My issue is resolved.

it seems starting Unity project output in Xcode 14 on a device with iOS 16 has issues!

Getting to this issue:

warning: UnityFramework was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb)

means Onesignal dependency is fine, just need to do something else to be able to start running the project on the iOS 16 device. (or just install on device, and start it there)

More info:

https://forum.unity.com/threads/unity-2021-3-6f1-xcode-14-ios-16-problem-unityframework-crash-before-main.1338284/#post-8486840

(Caution, Google-Mobile-Ads-SDK 9.14 is also having issues, use 9.13 if you are using it in your project. What is the odds of 3 external issues happening at the same time?)

@roointan
Copy link

So, what needs to be done (What actually worked for me):

Have no instance of Unity or Xcode running.
go to the folder of Xcode export of your Unity project (if you haven't removed it), and run the following:
rm Podfile.lock
pod cache clean --all

remove cocoapods by running the following command in the terminal:

gem list --local --no-version | grep cocoapods | xargs gem uninstall

then run this:
sudo rm -rf ~/.cocoapods

next, install the latest verrsion of ruby using brew:

brew upgrade ruby -v

(you need to have brew installed of course)

run this:

rm -rfv ~/Library/Developer/Xcode/DerivedData

add the following to the end of ~/.zshrc file, if it doesn't already exist there:

if [ -d "/usr/local/opt/ruby/bin" ]; then
export PATH=usr/local/opt/ruby/bin:$PATH
export PATH=gem environment gemdir/bin:$PATH
fi

Then restart your computer.

next, open up your terminal, and make sure your installed versions of Ruby and RubyGems are 3+, by checking the output of these two commands:
ruby --version
gem env

Next, export the Xcode project from Unity, but don't open it.
Again open terminal and go to that folder, and run:
rm Podfile.lock
pod cache clean --all
pod install --repo-update

You should be able to open the Xcode project and build successfully after all this.

refer to the following if you have the warning: UnityFramework was compiled with optimization - stepping may behave oddly; variables may not be available. (lldb) error: https://forum.unity.com/threads/unity-2021-3-6f1-xcode-14-ios-16-problem-unityframework-crash-before-main.1338284/#post-8486840

Also make sure you are not using version 9.14.0 of Google-Mobile-Ads-SDK (it's buggy for the mean time. you can hardcode version 9.13 in the Podfile to be safe)

@xinatcg
Copy link

xinatcg commented Mar 29, 2023

same issue. and resolved by upgrading the pod from 1.10.2 to 1.12.0.

sudo gem install cocoapods

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

No branches or pull requests

9 participants