little-snow-fox / react-native-wechat-lib

🚀 WeChat login, share, favorite and payment for React-Native on iOS and Android
MIT License
673 stars 134 forks source link

WXApi genExtraUrlByReq:withAppData #49

Closed yinminqian closed 1 year ago

yinminqian commented 4 years ago

版本:1.1.16 微信版本:7.0.12

WeChat.registerApp 正常运行 WeChat.isWXAppInstalled() 和 WeChat.getApiVersion() 这种不需要传参数的api能正常调用,也能正常调用api打开微信

但是我尝试使用的分享功能时却报错了 这是我的代码 WeChat.shareText({ text: 'Text content.', scene: 0 }).then(res => { console.log('res', res); }).catch(err => { console.log('err', err); })

以下是报错信息: ExceptionsManager.js:126 Exception '+[WXApi genExtraUrlByReq:withAppData:]: unrecognized selector sent to class 0x1012706a0' was thrown while invoking shareText on target WeChat with params ( { scene = 0; text = "Text content."; }, 9663 ) callstack: ( 0 CoreFoundation 0x00000001a8188178 9624AAFD-5437-3772-A507-0F357875808D + 1253752 1 libobjc.A.dylib 0x00000001a7e9cc1c objc_exception_throw + 60 2 CoreFoundation 0x00000001a808b440 9624AAFD-5437-3772-A507-0F357875808D + 218176 3 CoreFoundation 0x00000001a818c85c 9624AAFD-5437-3772-A507-0F357875808D + 1271900 4 CoreFoundation 0x00000001a818eb60 _CF_forwarding_prep_0 + 96 5 RCTWeChat 0x000000010124ec68 +[WXApi sendReq:isAutoResend:forceScheme:completion:] + 1948 6 RCTWeChat 0x000000010124e4b8 +[WXApi sendReq:completion:] + 68 7 RCTWeChat 0x0000000101236574 -[RCTWeChat shareText::] + 504 8 CoreFoundation 0x00000001a818ed14 9624AAFD-5437-3772-A507-0F357875808D + 1281300 9 CoreFoundation 0x00000001a8057de8 9624AAFD-5437-3772-A507-0F357875808D + 7656 10 CoreFoundation 0x00000001a8058a10 9624AAFD-5437-3772-A507-0F357875808D + 10768 11 React 0x00000001015899e8 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1860 12 React 0x000000010158d45c _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 648 13 React 0x000000010158cff4 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 144 14 React 0x000000010158cf58 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28 15 libdispatch.dylib 0x000000010252dd10 _dispatch_call_block_and_release + 32 16 libdispatch.dylib 0x000000010252f18c _dispatch_client_callout + 20 17 libdispatch.dylib 0x000000010253dd14 _dispatch_main_queue_callback_4CF + 996 18 CoreFoundation 0x00000001a810341c 9624AAFD-5437-3772-A507-0F357875808D + 709660 19 CoreFoundation 0x00000001a80fe034 9624AAFD-5437-3772-A507-0F357875808D + 688180 20 CoreFoundation 0x00000001a80fd660 CFRunLoopRunSpecific + 480 21 GraphicsServices 0x00000001b250e604 GSEventRunModal + 164 22 UIKitCore 0x00000001ac2d215c UIApplicationMain + 1944 23 duonuo_xixun_app 0x000000010028a7c4 main + 128 24 libdyld.dylib 0x00000001a7f791ec 95B366E7-F5BD-3308-9416-24B35999029B + 4588 )

然后我去微信官网搜索错误信息,得到的答案都是 添加 other linker flags 选项 -Objc -all_load,但是不起任何作用,依旧是报错。

gcloudspider commented 3 years ago

npm install 完成之后,在node_modules 下面 找到 react-native-wechat-lib/RCTWechat.podspec 添加 s.static_framework = true 然后去掉 之前添加的 -all_load, force_load 之类的参数;还是不行的话,就把原来的pod目录删掉,重新pod install,我的是这么解决的