dyld:库未加载:@rpath/OneSignal.framework/OneSignal

8

我正在尝试将OneSignal集成到我的React Native应用程序中。

我按照文档 https://documentation.onesignal.com/docs/react-native-sdk-setup 中提到的所有说明进行操作。

应用程序的构建成功了,但是在将应用程序附加到设备时出现错误。

Xcode打开一个标题为dyld__abort_with_payload的线程。

这是它的图片。 enter image description here

当我查看错误时,错误看起来像这样。

dyld: Library not loaded: @rpath/OneSignal.framework/OneSignal
  Referenced from: /Users/sakshyaarora/Library/Developer/CoreSimulator/Devices/357B8E50-B8A6-4F9D-AE06-40DD8004351E/data/Containers/Bundle/Application/242BEDF6-76CD-4516-BF58-C86C43F6C4D4/Test.app/Test
  Reason: image not found
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/sakshyaarora/Library/Developer/CoreSimulator/Caches/dyld/20F71/com.apple.CoreSimulator.SimRuntime.iOS-14-5.18E182
DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
DYLD_LIBRARY_PATH=/Users/sakshyaarora/Library/Developer/Xcode/DerivedData/Test-djshtsdmeowdbaebqzmujevyppyj/Build/Products/Debug-iphonesimulator:/Users/sakshyaarora/Sites/projects/Test/Builds/iOS/build/Debug/-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applica

我已经尝试了好几个小时了,希望能得到帮助。谢谢提前。

谢谢:)


你最终解决了这个问题吗?我也遇到了同样的问题。 - Audee Velasco
是的,我已经解决了这个问题,但解决方案非常奇怪...这就是为什么我没有在答案中发布它的原因...我会在一段时间内更新答案,也许可以帮助到其他人。 - sakshya73
2个回答

8

我得到的解决方案非常奇怪,只是在尝试时出现了,并且能够为我解决这个问题。因此,如果这里有任何人遇到相同的错误,可以尝试一下以下方法。

步骤

打开 Xcode -> 选择你的应用程序 -> 转到“常规”选项卡 -> 框架、库和嵌入式内容

点击+。在其中搜索OneSignal并添加OneSignal.xcframework

enter image description here

这里来了一个奇怪的部分。

添加OneSignal.xcframework后,只需通过选择并单击-来删除此OneSignal.xcframework

现在重新构建您的应用程序即可让它正常运行。


1
据我所见,这个奇怪的操作将"@executable_path/Frameworks"添加到链接 -> 运行路径搜索路径中。 - Sergei Nikitin
是的,没错 - 添加路径后应用程序正常启动! - Sergei Nikitin
3
我可以按照您的方式解决这个问题,方法是添加"OneSignalCore"和"OneSignalOutcomes",并将其保留在框架列表中作为"嵌入并签名"。此外,将这些pods从"OneSignalNotificationServiceExtension"移动到应用程序主目标中。更多信息请参见https://github.com/OneSignal/react-native-onesignal/issues/1459。 - Pelanes

1
如果您在Flutter或React-Native中遇到相同的问题,则应尝试在目标中创建一个OneSignalNotificationServiceExtension,并将此扩展添加到Target>GeneralFrameworks,Libraries and Embedded Content部分。
您可以按照以下步骤进行操作:
  1. 从项目的iOS文件夹中打开Runner.xcworkspace
  2. 点击“+”图标以添加一个目标,并搜索Notification Service Extension

enter image description here

将以下文本翻译成中文:
  1. 为OneSignal创建一个新的通知服务扩展,选择您的团队,其余保持默认。

  2. 在下一步中,转到常规标签 > 框架、库和嵌入式内容,通过单击“+”图标添加“OneSignalCore.xcframework”、“OneSignalOutcomes.xcframework”,并将其保留在框架列表上,作为“嵌入并签名”,还要按照下面的截图添加新创建的通知服务扩展

enter image description here

下一步是添加和删除(是的,没错)“OneSignal.xcframework”,所以您需要在“General Tab > Frameworks,Libraries and Embedded Content”中通过单击“+”图标添加OneSignal.xcframework,然后通过选择此列表项并单击“-”图标来删除它(请注意名称,这个只是 onesignal...)。 完成这些步骤后,您可以简单地清理您的项目并运行它,它应该可以工作!

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接