描述:
遵循React Native & Expo SDK 设置指南。 完成第 5 步后,我尝试在 XCode 中构建我的应用程序。 构建失败,出现以下错误:
ld: library not found for -lreact-native-onesignal
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我尝试按照手动链接步骤操作,但遇到了同样的错误。 想知道有人想出了解决方案吗?
谢谢!
环境
yarn add react-native-onesignal
添加 SDK 到项目播客文件
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
target 'OneSignalNotificationServiceExtension' do
pod 'OneSignal', '>= 3.0', '< 4.0'
end
target 'WellnessReactNative' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
pod 'Stripe', '~> 19.0.1'
pod 'tipsi-stripe', :path => '../node_modules/tipsi-stripe'
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
# use_flipper!
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-config'
phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
phase.shell_script = "cd ../../"\
" && RNC_ROOT=./node_modules/react-native-config/"\
" && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
" && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"
target.build_phases << phase
target.build_phases.move(phase,0)
end
end
# flipper_post_install(installer)
end
end
重现问题的步骤:
你好,
尝试从ios
目录运行pod deintegrate && pod install
。 如果这不起作用,请尝试运行干净的构建。 如果这些都不起作用,请尝试删除您的派生数据。
嗨@rgomezp ,
感谢回复! 我给了你的建议,但遇到了同样的错误。
我在想此时我需要手动链接库,因为自动链接不起作用。 清除所有内容后,我设置了手动链接。 我在 RCTOneSignalExtensionService.m 中看到以下错误:
node_modules/react-native-onesignal/ios/RCTOneSignal/RCTOneSignalExtensionService.m:4:9: 'OneSignal.h' file not found
查看RCTOneSignal.xcodeproj
的“Frameworks”目录,似乎OneSignal.h
引用指向node_modules/react-native-onesignal/ios/OneSignal.h
。 但是这个文件不存在。 这会影响手动链接吗?
这事有进一步更新吗 ? 更新到 Xcode 12 后面临同样的问题。
嗨@hugoh59 ,
我的问题是我的 Cocoapods 没有更新我的库搜索路径。 还是不知道为什么...
我通过手动将${PODS_CONFIGURATION_BUILD_DIR}/react-native-onesignal
到我的主要目标中的库搜索路径(构建设置 > 搜索路径 > 库搜索路径)来修复我的安装。
希望这可以帮助!