[QSDK] 在 iOS 中使用微信 SDK 的步骤

在 Android 中集成微信 SDK 的步骤参考:[QSDK] 在 Android 使用微信 SDK 的步骤

测试环境:

  • 微信 SDK 版本:1.7.2
  • iOS SDK 版本:9.3
  • QSDK 中的微信 SDK 相关的单元:qsdk.wechat.ios、iOSapi.CFNetwork、iOSapi.SCNetworkReachability、iOSapi.Security
  • 开发工具:Delphi 10.1

使用步骤:

1、新建一个 FMX 的空白工程;

2、将 QSDK 中的相关单元和微信 SDK 的 libWeChatSDK.a 复制到程序目录下(也可以视类型放到相应的搜索路径中,这里为了方便都统一放到程序的源码目录下)。

3、在 Project -> Options -> Delphi Compiler -> Linking 中,找到 Options passed to the LDLinker,加入 -framework CoreTelphony。

wechartopt

4、目标平台选择 iOS 设备,先 Build 一项这个新工程,以便生成 iOS 的 info.plist 模板文件 info.plist.TemplateiOS.xml。

5、在 IDE 中打开这个文件,在 <%ExtraInfoPListKeys%> 和 </dict> 中间加入以下内容:

注意替换下你微信应用开发平台的ID。

6、在主窗体中引用 qsdk.wechat.ios 和 Macapi.Helpers,然后在窗体的OnCreate 事件中注册你的应用,实际上这在你应用使用微信相关接口之前调用一次就可以了。

7、现在可以在其它地方使用 SDK 了,一个简单的验证方法测试代码:

8、编译并运行你的程序吧,如果没啥意外的话,微信的 SDK 已经工作正常了。如果遇到问题,欢迎到 QDAC 官方QQ群 (250530692)一起讨论。

运行效果截图如下:

wexin

分享到:
  1. 加了第3步,并且sdk manager也加入了该框架,出错如前。后去掉第3步,提示缺少SystemConfiguration.framework,遂加入。我的环境Delphi 10.1 Berlin OSX10105 Xcode(7A220) iPhoneOS9.0.sdk然,编译继续出错,不甚明白,请教贤长。[DCC Error] E2597 ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFE107A) is too big in libWeChatSDK.a(WXApi.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFE10B4) is too big in libWeChatSDK.a(WXApi.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFCFD2A) is too big in libWeChatSDK.a(WXApiObject.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFCFD79) is too big in libWeChatSDK.a(WXApiObject.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF8EFA) is too big in libWeChatSDK.a(AppCommunicate.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF8F4C) is too big in libWeChatSDK.a(AppCommunicate.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFD237A) is too big in libWeChatSDK.a(AppCommunicateData.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFD23D0) is too big in libWeChatSDK.a(AppCommunicateData.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF7DEA) is too big in libWeChatSDK.a(WeChatRegister.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF7E2D) is too big in libWeChatSDK.a(WeChatRegister.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFEC28A) is too big in libWeChatSDK.a(WapAuthHandler.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFEC2CD) is too big in libWeChatSDK.a(WapAuthHandler.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF409A) is too big in libWeChatSDK.a(WeChatApiUtil.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF40EC) is too big in libWeChatSDK.a(WeChatApiUtil.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFFC86A) is too big in libWeChatSDK.a(MTAWX.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFFC8AC) is too big in libWeChatSDK.a(MTAWX.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFDB6DA) is too big in libWeChatSDK.a(MTA.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFDB71E) is too big in libWeChatSDK.a(MTA.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF1FAA) is too big in libWeChatSDK.a(MTAConfig.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF1FF4) is too big in libWeChatSDK.a(MTAConfig.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFE41BA) is too big in libWeChatSDK.a(MTAEvent.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFE4203) is too big in libWeChatSDK.a(MTAEvent.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF346A) is too big in libWeChatSDK.a(MTADataConfigHolder.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF34BE) is too big in libWeChatSDK.a(MTADataConfigHolder.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF381A) is too big in libWeChatSDK.a(MTADispatcher.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF3868) is too big in libWeChatSDK.a(MTADispatcher.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFECEAA) is too big in libWeChatSDK.a(MTAHelper.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFECEF4) is too big in libWeChatSDK.a(MTAHelper.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFFCC5A) is too big in libWeChatSDK.a(MTAKeyChain.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFFCCA6) is too big in libWeChatSDK.a(MTAKeyChain.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF983A) is too big in libWeChatSDK.a(MTAReachability.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF988A) is too big in libWeChatSDK.a(MTAReachability.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFE341A) is too big in libWeChatSDK.a(MTAStore.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFE3463) is too big in libWeChatSDK.a(MTAStore.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF791A) is too big in libWeChatSDK.a(MTAEnv.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF7961) is too big in libWeChatSDK.a(MTAEnv.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF869A) is too big in libWeChatSDK.a(OpenUDID.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF86E3) is too big in libWeChatSDK.a(OpenUDID.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFFCB2A) is too big in libWeChatSDK.a(MTAPasteboard.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFFCB78) is too big in libWeChatSDK.a(MTAPasteboard.o) Undefined symbols for architecture armv7: Error: “_OBJC_CLASS_$_CTTelephonyNetworkInfo”, referenced from: objc-class-ref in libWeChatSDK.a(MTAHelper.o); ld: symbol(s) not found for architecture armv7[DCC Fatal Error] F2588 Linker error code: 1 ($00000001)

    • Error: “_OBJC_CLASS_$_CTTelephonyNetworkInfo”, referenced from: objc-class-ref in libWeChatSDK.a(MTAHelper.o); 这句说明没有指定 -framework CoreTelephony

    • 第 3 步你加了吗?另外,这个是以 10.1 为基础写的。别的版本可能需要手动引入CoreTelphony 框架