集成微信支付遇见坑

一、微信支付,首先利用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

@property (strong, nonatomic) UIWindow * window;

@end

你可能感兴趣的:(集成微信支付遇见坑)