集成微信支付遇见坑

一、微信支付,首先利用CocoaPods,导入微信支付SDK

pod 'WechatOpenSDK'

注意:导入重新运行项目会报错:ld: in /Users/renhuaqian/Documents/mutableTarges/mb-ios/MosoBooksPhone/ClassLibrary/UMShareSDK/WeChat/libWeChatSDK.a(WechatAuthSDK.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/renhuaqian/Documents/mutableTarges/mb-ios/MosoBooksPhone/ClassLibrary/UMShareSDK/WeChat/libWeChatSDK.a' for architecture arm64

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

解决:

1.podFile加下面代码

post_install do |installer|  installer.pods_project.build_configurations.each do |config|    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"  endend

2.buildSetting中,加如下信息,然后clean项目, 再pod install下; 重新运行项目就能在模拟器运行了

二、在你需要使 用微信终端 API 的文件中 import WXApi.h 头文件,并增加 WXApiDelegate 协议。

#import

#import "WXApi.h"//导入微信API

@interface AppDelegate : UIResponder <UIApplicationDelegate,WXApiDelegate>

@property (strong, nonatomic) UIWindow * window;

@end

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容