jpush-react-native icon indicating copy to clipboard operation
jpush-react-native copied to clipboard

linker command failed with exit code 1 (use -v to see invocation)

Open xgxchina opened this issue 7 years ago • 16 comments

你的运行环境

Xcode 9.2

  • 插件版本: "jcore-react-native": "^1.2.5", "jpush-react-native": "^2.1.12",

  • react-native 版本: "react-native": "0.50.3",

期望效果

实现jpush-react-native消息推送功能

实际效果

Xcode 编译报错: Undefined symbols for architecture x86_64: "_kJPFNetworkIsConnectingNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o "_kJPFNetworkDidRegisterNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o "_JCOREDisplayVersion", referenced from: +[JPUSHService commonSetupWithOption:appKey:channel:apsForProduction:advertisingIdentifier:] in libjpush-ios-3.0.7.a(JPUSHService.o) "_JCOREGetBuildVersion", referenced from: +[JPUSHService commonSetupWithOption:appKey:channel:apsForProduction:advertisingIdentifier:] in libjpush-ios-3.0.7.a(JPUSHService.o) "_kJPFNetworkDidSetupNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o "_kJPFNetworkDidCloseNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o -[RCTJPushModule reactJSDidload] in RCTJPushModule.o "_kJPFNetworkDidLoginNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o -[RCTJPushModule reactJSDidload] in RCTJPushModule.o "_kJPFNetworkDidReceiveMessageNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

重现步骤

  1. 在项目根目录执行 yarn add jpush-react-native jcore-react-native 安装插件
  2. 在项目根目录执行 react-native link 安装依赖 执行中并输入key值已完成自配置
  3. 在ios项目跟目录执行 pod install 集成插件 4.打开Xcode的Build Settings的Search Paths的Header Search Paths添加路径:$(SRCROOT)/../node_modules/jpush-react-native/ios/RCTJPushModule 5.打开Xcode的Build Phases的Link Binary With Libraries添加如下库: libz.tbd CoreTelephony.framework Security.framework CFNetwork.framework CoreFoundation.framework SystemConfiguration.framework Foundation.framework UIKit.framework UserNotifications.framework libresolv.tbd 6.把UserNotifications.framework的Status改为Optional 7.把Capabilities的Push Notifiactions 值改为ON,并Steps都为√ 8.把node_modules>jpush-react-native>ios>RCTPushModule.xcodeproj添加到Xcode项目的Libraries文件夹中 9.把node_modules>jpush-react-native>ios>RCTPushModule整个文件夹添加到Xcode项目的项目根目录下

Debug logs

ios Xcode编译报错: Ld /Users/samcms/Library/Developer/Xcode/DerivedData/nnapp-dkdeqhvvcosmxqfxmtrdqiugfrvn/Build/Products/Debug-iphonesimulator/JPushRN/JPushRN.framework/JPushRN normal x86_64 cd /Users/samcms/Desktop/nnapp/ios/Pods export IPHONEOS_DEPLOYMENT_TARGET=8.0 export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk -L/Users/samcms/Library/Developer/Xcode/DerivedData/nnapp-dkdeqhvvcosmxqfxmtrdqiugfrvn/Build/Products/Debug-iphonesimulator/JPushRN -L/Users/samcms/Desktop/nnapp/ios/Pods/../../node_modules/jpush-react-native/ios/RCTJPushModule -F/Users/samcms/Library/Developer/Xcode/DerivedData/nnapp-dkdeqhvvcosmxqfxmtrdqiugfrvn/Build/Products/Debug-iphonesimulator/JPushRN -F/Users/samcms/Library/Developer/Xcode/DerivedData/nnapp-dkdeqhvvcosmxqfxmtrdqiugfrvn/Build/Products/Debug-iphonesimulator/React -filelist /Users/samcms/Library/Developer/Xcode/DerivedData/nnapp-dkdeqhvvcosmxqfxmtrdqiugfrvn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/JPushRN.build/Objects-normal/x86_64/JPushRN.LinkFileList -install_name @rpath/JPushRN.framework/JPushRN -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -mios-simulator-version-min=8.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/samcms/Library/Developer/Xcode/DerivedData/nnapp-dkdeqhvvcosmxqfxmtrdqiugfrvn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/JPushRN.build/Objects-normal/x86_64/JPushRN_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ljpush-ios-3.0.7 -lresolv -lz -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreTelephony -framework Foundation -framework Security -framework SystemConfiguration -framework UIKit -weak_framework UserNotifications -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreTelephony -framework Foundation -framework React -framework Security -framework SystemConfiguration -framework UIKit -single_module -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/samcms/Library/Developer/Xcode/DerivedData/nnapp-dkdeqhvvcosmxqfxmtrdqiugfrvn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/JPushRN.build/Objects-normal/x86_64/JPushRN_dependency_info.dat -o /Users/samcms/Library/Developer/Xcode/DerivedData/nnapp-dkdeqhvvcosmxqfxmtrdqiugfrvn/Build/Products/Debug-iphonesimulator/JPushRN/JPushRN.framework/JPushRN

Undefined symbols for architecture x86_64: "_kJPFNetworkIsConnectingNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o "_kJPFNetworkDidRegisterNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o "_JCOREDisplayVersion", referenced from: +[JPUSHService commonSetupWithOption:appKey:channel:apsForProduction:advertisingIdentifier:] in libjpush-ios-3.0.7.a(JPUSHService.o) "_JCOREGetBuildVersion", referenced from: +[JPUSHService commonSetupWithOption:appKey:channel:apsForProduction:advertisingIdentifier:] in libjpush-ios-3.0.7.a(JPUSHService.o) "_kJPFNetworkDidSetupNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o "_kJPFNetworkDidCloseNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o -[RCTJPushModule reactJSDidload] in RCTJPushModule.o "_kJPFNetworkDidLoginNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o -[RCTJPushModule reactJSDidload] in RCTJPushModule.o "_kJPFNetworkDidReceiveMessageNotification", referenced from: -[RCTJPushModule init] in RCTJPushModule.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

xgxchina avatar Mar 15 '18 03:03 xgxchina

Should link both dependencies: react-native link jpush-react-native jcore-react-native

evianzhow avatar Mar 15 '18 08:03 evianzhow

这条命令已经链接过了,并且已经执行成功了 image

xgxchina avatar Mar 16 '18 07:03 xgxchina

检查 XCode 工程中有没有 JCoreModule 如果没有手动 link jcore

huangminlinux avatar Mar 16 '18 07:03 huangminlinux

具体要链接哪些呢

xgxchina avatar Mar 19 '18 06:03 xgxchina

https://reactnative.cn/docs/0.51/linking-libraries-ios.html#content

huangminlinux avatar May 03 '18 09:05 huangminlinux

我也按照教程配置了,也是报了这个错误,该引的东西都已经引进去了

quietautumn avatar Jun 11 '18 05:06 quietautumn

同样遇到这个问题,仍然没有解决!希望官方尽快处理下这个问题。

songxiaoliang avatar Jun 11 '18 07:06 songxiaoliang

花了一天时间,目前配置应该算是成功了,能发起本地推送,也能接收到极光官网发起的推送。报错的原因主要是自动link的时候,我感觉除了AppDelegate.m里面自动配置了,其他很多东西都没有自动配置进去,还是需要手动配置,但是手动配置的东西不太全,所以容易出错,可以去搜两篇完整一点的博客对照着一点一点来试。

quietautumn avatar Jun 11 '18 09:06 quietautumn

我也遇到了这个问题,很痛苦!

aiynmm avatar Aug 06 '18 06:08 aiynmm

我也遇到了 ,求助攻

841660202 avatar Sep 13 '18 08:09 841660202

应该是你的pod使用了 use_frameworks

shinian123456 avatar Nov 12 '18 03:11 shinian123456

加上libresolv.tbd应该就好了

liusanhong avatar Nov 23 '18 10:11 liusanhong

我加了libresolv.tbd和libresolv.9.tbd 都没有效果还是报这个错误

inkCrazy avatar Dec 05 '18 08:12 inkCrazy

我也遇到了 ,求助攻

2445967009 avatar Aug 15 '19 10:08 2445967009

能否再试下新版,有较大改动

wicked-tc130 avatar Oct 25 '19 08:10 wicked-tc130

Build Phases -》Link Binaries With Libraries

以下2个可以手动添加,都在iOS 12.1下存在 libresolv.tbd UserNotifications.framework

加上就没这个错误了

sunshowerstack avatar Mar 17 '20 08:03 sunshowerstack