iOS调试常见错误汇总 如:symbol(s) not found for architecture x86_64

 最近升级SDK,统计了调试遇到的许多问题解决方法,希望对需要的人有些帮助,仅供参考。

1、框架导入方式:

Targets—>Build Phases—>Link Binary With Libraries 中
点“+”导入系统的或Add Other导入外部的 , 

资源文件直接拖入左边文件夹中

2、文件路径设置:

Targets—>Build Settings—>Search Paths设置
相对路径:$(inherited) 继承
$(PROJECT_DIR) 指xxx.xcodeproj所在的父目录
$(SRCROOT) 根路径

例如:如果在Header Search Paths中添加$(SRCROOT)/scr,那么头文件引用直接引用 include “test.h”

Always search User Paths 可设为为NO,其他路径可相应设置(调试可设的包不同路径)
如果设置了 Always Search User Paths 为 yes,编译器会先搜索User Header Search Paths路径下的目录,在这种情况下include <string.h>,User Header Search Paths 搜索目录下的文件会覆盖系统的头文件

3、模拟器运行项目选择:

cocos2d支持多平台运行,模拟器选择的前一个文件需选择ios文件

4 .dmg文件中打开的项目提示锁定:

需项目拷贝出来运行

5、Xcode7网络设置:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
还有一种单独设置方式按情况设置不同

6、纠正后删除左边红色文件:

最新Xcode中库后缀名".dylib"可用".tbd" ,
(正常情况)通过Finder同样找不到.dylib文件,
因该文件是隐藏文件。需按快捷键 CMD+Shift+G,
输入 /usr/lib 后进入隐藏界面,然后添加需要的.dylib即可。
删除重复导入的框架

7、链接报错:symbol(s) not found for architecture x86_64  :

导致这种错误首先查看代码原因,代码没问题再查看如下配置

Xcode升级到5.1 新特性之一就是默认让所有App都通过64位编译器编译。原来在Xcode5.0.x的时候默认的Standard architectures只有(arm7,armv7s),到5.1之后默认就带上arm64的参数了。

目前临时的解决办法是 
1.把1.选中Targets—>Build Settings—>Architectures。
把build active architectures only 改为 NO。

2. 把最下面的Valid Architectures中的arm64参数删掉就可以了
   或者:
  双击Architectures,选择other,删除$(ARCH_STANDARD),然后增加armv7和armv7s(写上:$(ARCHS_STANDARD_32_BIT))。

3.clean 再build。

以上都不行则说明模拟器中不能调试,真机调试试试看

8、Xcode7以上真机调试步骤:

1.Xcode ->Preferences->Accounts->左下角“+”Add Apple ID
2.target->Build Phases->Code Signing->Code Signing Identity选择ios Developer,Provisioning Profile选择Automatic(有申请的也可以选择自己的证书)
3.General->Identity ->Team ->选择自己的账号 ,账号可能与其他企业等账户冲突则需重新注册
4.点击Fix Issue
5.运行

9、编码错误:You must rebuild it with bitcode enabled 
(Xcode setting ENABLE_BITCODE) :

Targets—>Build Settings—>Build Options->Enable Bitcode 设置为NO

10、真机运行崩溃错误:dyld`dyld_fatal_error:
                                    0x2be810c4:  trap   
                                    0x2be810c8:  nop    :

尝试:
 1.将CFNetwork框架后面改成可选的Optionnal,可能是网络请求问题
 2.把foundation框架放到CFNetwork框架上面
 3.查看控制台输出的内容,提示没有加载资源,则可能需在 General->Embedded Bnaries中导入需要的框架

11、"_GCControllerDidConnectNotification", referenced from:
      -[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
  "_OBJC_CLASS_$_GCController", referenced from:
      objc-class-ref in libcocos2dx iOS.a(CCController-iOS.o)
     (maybe you meant: _OBJC_CLASS_$_GCControllerConnectionEventHandler)
ld: symbol(s) not found for architecture armv7s

BuildSettings -> Build Phase -> Link Binary with libraries
加入:
MediaPlayer.framework
GameController.framework

12、两个静态库冲突     :

删除掉 Other Linker Flag 的 -all_load 
如果是有些库使用到了扩展函数(catagory)可以分别对这个库进行加载
使用:-force_load
-force_load  build/libs/libxx.a
(build是添加到当前目录下的)

-force_load $(BUILT_PRODUCTS_DIR)/libxx.a
(这里是直接添加静态库项目源码的做法)

13、"_ExtAudioFileSetProperty", referenced from:
      _CDloadCafAudioData in libcocos2dx.a(CDOpenALSupport.o)
  "_ExtAudioFileRead", referenced from:
      _CDloadCafAudioData in libcocos2dx.a(CDOpenALSupport.o)
  "_AudioFileReadBytes", referenced from:
      _CDloadWaveAudioData in libcocos2dx.a(CDOpenALSupport.o)
  "_ExtAudioFileDispose", referenced from:
      _CDloadCafAudioData in libcocos2dx.a(CDOpenALSupport.o)
  "_AudioFileOpenURL", referenced from:
      _CDloadWaveAudioData in libcocos2dx.a(CDOpenALSupport.o)

BuildSettings -> Build Phase -> Link Binary with libraries
加入:
AudioToolbox.framework(播放或录音库)

14、运行时出现的证书问题:

App installation failed
a vaild provsioning profile for this executable was not found

检查:

1、安装证书是否重新导入(证书最好重新安装一下)
2、调试手机是否已授权
3、确认xcode选择的调试证书是否正确,team选择是否正确  
4、设置的bundle identifier是否符合证书的命名规则

15、真机调试[UISreen mainScreen].bounds 得到的大小与实际手机的屏幕大小不一致

1、查看手机是否设置为放大模式(iPhone6及上)
2、启动图片设置问题,Lanuch Screen File选择Don't use asset catalogs,然后找到启动图片文件夹删除,再重新打开启动图,找到启动图将图片拖入启动图对应区域再运行即可。

16、Xcode上传包时错误:Unexpected CFBundleExecutable Key. The bundle at 'Payload/xxxx.app[表情]SDK_login_bundle.bundle' does not contain a bundle executable. If this bundle intentionally does not contain an executable, consider removing the CFBundleExecutable key from its Info.plist and using a CFBundlePackageType of BNDL. If this bundle is part of a third-party framework, consider contacting the developer of the framework for an update to address this issue. (ID: b2160de1-990a-4593-9dd2-6d48362f724c)

包中使用了.bundle文件,将.bundle文件显示包内容,删除里面info.plist中的Executable file 字段行(一般无其他设置也可直接将.bundle中的info.plist文件删除)

17、运行启动崩溃:

dyld`:

    0x1dcf28eb4 <+0>:  mov    x16, #0x209

    0x1dcf28eb8 <+4>:  svc    #0x80

->  0x1dcf28ebc <+8>:  b.lo   0x1dcf28edc               ; <+40>

输出: dyld[8099]: Library not loaded: @rpath/xxxx.framework/xxxx

若​​​​​​使用动态库.framework,则可检查target中 General ->Freameworks,Libraries,and Embedded Content -> 选中库的 Embed选项 ->由Do Not Embed 改为 Embed & Sign

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值