react-native-wechat-lib icon indicating copy to clipboard operation
react-native-wechat-lib copied to clipboard

Undefined symbol: _OBJC_CLASS_$_WXApi

Open chobitsX opened this issue 4 years ago • 4 comments

  • 使用版本:react-native 0.63.2 + xcode 11.6,配置环境IOS开发环境
  • 问题一:react-native link react-native-wechat-lib,按文档Build Setup for iOS 配置,依旧会提示WXApi.h文件找不到,通过在 header search paths里添加 "$(SRCROOT)/../node_modules/react-native-wechat-lib/ios"可以解决
  • 问题二:xcode运行项目,遇到报错:Undefined symbol: OBJC_CLASS$_WXApi

Showing Recent Issues

Build target chonglyShop of project chonglyShop with configuration Debug
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the chonglyShop editor. (in target 'chonglyShop' from project 'chonglyShop')


CompileC /Users/lusun/Library/Developer/Xcode/DerivedData/chonglyShop-cnzjduojkzecclehmgykifkfygru/Build/Intermediates.noindex/chonglyShop.build/Debug-iphonesimulator/chonglyShop.build/Objects-normal/x86_64/AppDelegate.o /Users/lusun/Documents/myCode/ReactNative/chonglyShop/ios/chonglyShop/AppDelegate.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'chonglyShop' from project 'chonglyShop')
    cd /Users/lusun/Documents/myCode/ReactNative/chonglyShop/ios
    export LANG=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -target x86_64-apple-ios10.0-simulator -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/lusun/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/lusun/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module ......
sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/lusun/Library/Developer/Xcode/DerivedData/chonglyShop-cnzjduojkzecclehmgykifkfygru/Build/Intermediates.noindex/chonglyShop.build/Debug-iphonesimulator/chonglyShop.build/chonglyShop.app-Simulated.xcent -lz -lc++ -lsqlite3.0 -framework CoreTelephony -framework SystemConfiguration -framework WebKit -lPods-chonglyShop -Xlinker -dependency_info -Xlinker /Users/lusun/Library/Developer/Xcode/DerivedData/chonglyShop-cnzjduojkzecclehmgykifkfygru/Build/Intermediates.noindex/chonglyShop.build/Debug-iphonesimulator/chonglyShop.build/Objects-normal/x86_64/chonglyShop_dependency_info.dat -o /Users/lusun/Library/Developer/Xcode/DerivedData/chonglyShop-cnzjduojkzecclehmgykifkfygru/Build/Products/Debug-iphonesimulator/chonglyShop.app/chonglyShop

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_WXApi", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


(求解决方案,万分感激)

chobitsX avatar Sep 01 '20 07:09 chobitsX

pod install了没?

vpjacob avatar Sep 03 '20 03:09 vpjacob

pod install了没?

pod install了好几次,依旧这个问题

chobitsX avatar Sep 03 '20 05:09 chobitsX

经过尝试,初步找到解决办法了,我上面反馈的问题一和问题二,都可以通过下面方法解决,在终端输入以下指令(项目根目录下)

cd ios
pod install
cd ..
npx react-native link
# 虽然前面按照文档执行了react-native link react-native-wechat-lib,但上面这一步依旧不能少

chobitsX avatar Sep 03 '20 06:09 chobitsX

应该是没有添加libRCTWechat.a, 添加到Libraries下面也可以解决

gcloudspider avatar Dec 18 '20 13:12 gcloudspider