真机调试问题 错误集合

1. 编译iPad真机时,选择了 Architetures:Standard(armv6) BaseSDK:iPhoneDevice3.2 TargetDeviceFamily:iPad.php

若编译出现以下错误:html

Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1ios

则修改 GCC4.2CodeGeneral区域中的ComplieForThumb为非选中.web

已经有了开发者证书及私钥后,可直接在越狱的手机上调试.shell

 

2. 编译连接时, "_OBJC_CLASS_$_xxx", referenced from:可能须要从新创建某个类的文件.编程

    或者:选择项目名,在detail列表中的target列(显示为一个又圆圈),把这个文件的复选选中,或者再次选中.以把它加入到这个target里面来.api

 

3.在sdk4.0及以上使用RegexKitLite报'captureCount' was not declared in this scope错误,是在非.m文件中使用了它的缘由.xcode

   http://www.cocoachina.com/bbs/read.php?tid=38784&page=e&#a浏览器

 

4.there is no sdk with the name or path.app

   从网上down的开源代码,结果运行的时候常出现这样的错,而且在deployment中没有ios deployment target 选项.

   http://blog.aztaru.com/2010/10/05/ios%E7%AD%86%E8%A8%98there-is-no-sdk-error/

   尝试 Project/Edit Active Target/ 及 Set Active SDK菜单项,来回切换一下Active Configuration。

 

5.常见的EXEC_BAD_ACCESS,EXC_BAD_INSTRUCTION错误,通常是由于访问已经被release的对象形成的。

在工程中加入NSZombieEnabled 环境变量,并设为启用,则在 EXC_BAD_ACCESS 发生时,XCode 的 Console 会打印出问题描述中,设置方法:双击Executables 下的 可执行模组,在弹出窗口中,Variables to be set in the environment,添加 NSZombieEnabled,并设定为 YES,点击选中复选框启用此变量。

能够再加入 MallocStackLogging 来启用malloc记录,以得到更多的提示来帮助定位问题。

在gdb窗口输入 (格式: shell   malloc_history <id>   <address>)    shell malloc_history 1436 0x5f7fcf0, 也能够在终端中去运行 就要去掉以上的shell 指令 如 malloc_history <id>   <address>

http://www.cocoachina.com/macdev/objc/2011/0219/2661.html

http://www.cnblogs.com/likwo/archive/2011/02/10/1950664.html

应该仅当须要调试内存时,才设置上述环境变量.

 

在xcode4中,To edit environment variables, go to Menu Product / Edit Scheme…, select the desired configuration (you probably want 'Run') from the left sidebar first and then click on the Arguments tab. Environment variables are configurable there.

 

6.运行一个IPhone程序时,弹出窗口说“程序运行失败,预置描述文件已过时” 。 解决办法是,在Xcode中, window-> Orgnazier -> 你的iphone ->删除带有红*的该程序以前的Profile 。 而后从Xcode运行该程序.

 

7. 真机编译时报 Code Sign error: The identity doesn't match any valid certificate/private key pair in the default keychain

    修改工程和Targets的get info\build 中的code signing identity为空

 

8.调试打印

   CFShow(coreFoundationThingy) will print out a description of coreFoundationThingy to the console. Output looks something like: {value = w:1186.000000 h:687.000000 type = kAXValueCGSizeType}
   If NSLog() is printing something out as an NSCFType, try CFShow().

 

9. 编译时报 Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1,修改C/C++ Compiler Version为gcc4.2

 

10.this class is not key value coding-compliant for the key viewController

可能在建立了一个基于view的工程,然后把生成的viewcontroller删除了,可是在.xib中还有对它的引用,在IB中直接用delete键删除掉它就好了。

 

11.这台电脑上已经存在一个名为“embedded.mobileprovision”的预置文件,您是否要替换么?

http://blog.sina.com.cn/s/blog_6907b67f0100o2vw.html

 

12.真机调试时报failed to upload *.app

http://hi.baidu.com/%CB%E6%B7%E7_1989/blog/item/9649f49f805f05aec8eaf466.html

http://www.shouyanwang.org/thread-462-1-1.html

 

13.记的release时,先置delegate为nil。

 

14.模拟器

     将xcode升级到4.3.1之后发现,ipad的模拟器,没有Home键了。Command+Shift+H就能够实现相似点击Home键的效果了。

 

How to “add existing frameworks” in Xcode 4?

 

  1. In the project navigator, selectyour project
  2. Select your target
  3. Select the 'Build Phases' tab
  4. Open 'Link Binaries With Libraries'expander
  5. Click the '+' button
  6. Select your framework
  7. (optional) Drag and drop the addedframework to the 'Frameworks' group

15.如何在Xcode 4.2 下进行 iPod touch 2代、iPhone 3G等设备的真机调试?
     http://dev.ppios.com/2012/02/%E5%A6%82%E4%BD%95%E5%9C%A8xcode-4-2-%E4%B8%8B%E8%BF%9B%E8%A1%8C-ipod-touch-2%E4%BB%A3%E3%80%81iphone-3g%E7%AD%89%E8%AE%BE%E5%A4%87%E7%9A%84%E7%9C%9F%E6%9C%BA%E8%B0%83%E8%AF%95%EF%BC%9F/

 

16.编译真机提示provising文件找不到,到project.pbxproj中,把那串标识值删除。

 

17.在xcode4.3上链接装有ios4.2的3gs,提示: Xcode has encountered an unexpected error (0xC002)
No such file or directory, at ‘/SourceCache/DTDeviceKit/DTDeviceKit-1196/DTDeviceKit/DTDeviceKit_Utilities.m:798’

     http://stackoverflow.com/questions/7922308/xcode-4-2-error-0xc002-when-trying-to-use-a-jailbroken-iphone-3g-for-develop

cd ~/Library/Developer/Xcode/iOS\ DeviceSupport/4.2.1\ \(8C148a\)/Symbols/System/Library/Caches/com.apple.dyld/
touch .copied_dyld_shared_cache_armv6
touch .processed_dyld_shared_cache_armv6
touch dyld_shared_cache_armv6
或 
touch .copied_dyld_shared_cache_armv7
touch .processed_dyld_shared_cache_armv7
touch dyld_shared_cache_armv7

 

18. xcode4添加调试断点  
     在Xcode左侧断点管理窗口(Command+6)中,点击左下角+,添加add symbolic breakpoint,输入objc_exception_throw,点击done;而后右键单击该断点选择move breakpoint to,选择项目名或User,便可以在全部项目中起做用。
    还可添加输入malloc_error_break的symbolic断点,以跟踪调试释放了2次的对象。

 

19.XCode内置GDB,调试时在输出窗口中使用GDB命令来调试程序。

     po 命令:为 print object 的缩写,显示对象的文本描述(显示从对象的 description 消息得到的字符串信息)。

     print 命令:有点相似于格式化输出,能够输出对象的不一样信息:

     info 命令:咱们能够查看内存地址所在信息

     show 命令:显示 GDB 相关的信息。如:show version 显示GDB版本信息

     help 命令:若是忘记某条命令的语法了,可使用 help 命令名 来获取帮助信息。如:help info 显示 info 命令的用法。

 

20.NSLog

    真机上NSLog会消耗资源,

    以release模式编译的程序不会用NSLog输出,而以debug模式编译的程序将执行NSLog的所有功能。

#ifndef __OPTIMIZE__
# define NSLog(...) NSLog(__VA_ARGS__)
#else
# define NSLog(...)
#endif

#ifdef __OPTIMIZE__
#define NSLog(...) 
#endif

  这个代码的魔术在于:release模式一般会定义 __OPTIMIZE__,debug模式不会。将这段代码放在头文件当中,就能够放心的使用NSLog了!

  把这些代码放到*Prefix.pch中最省事。能够把这段宏定义放到一个头文件中,再把这个头文件包含到*Prefix.pch中。

    http://lichen1985.com/blog/?p=251

   iOS中日志打印:

   自定义NSLog  #define NSLog NSLog(@"#%s##%d#",strrchr(__FILE__,'/'),__LINE__);NSLog,例如NSLog(@" begin main function"); 打印出来以下 #/main.mm##30# begin main function

   参考 http://xcodev.com/wordpress/?m=201204

 

21. 错误日志目录在Mac OS X: ~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>

 

      iOS Exception caught Crash Report,3种方法

      http://blog.sina.com.cn/s/blog_67b7cb7b010146qj.html

      在iPhone上捕获软件异常退出的信息,2种方法

      http://hi.baidu.com/coolwidy/blog/item/76f006896168ecb80f2444e7.html

      PLCrashReporter

      http://caydenliew.com/2011/11/plcrashreporter-the-iphone-crash-framework/

  

     http://blog.sina.com.cn/s/blog_60b45f230100tn5b.html

 

22. Certificate identity 'iPhone Developer: XXXXXXXX' appears more than once in the keychain. The codesign tool requires there only be one
       出错缘由:屡次为同一个计算机生成私有证书,而且每次都生成了proversionning文件,下载并按照到同一个iOS设备上,那么再次编译程序到设备上的时候就会出现这个问题。
      修改方法:在Xcode中,选择菜单Window->Organizer,在LIBRARY下面,选择Provisioning Profiles.找到前面几回生成的Provisioning profiles.删除。
                        在系统的keychains,即钥匙串管理程序中,在登陆下面,个人证书,删除早期的私有证书。
                        再次编译

 

23.在 iOS 设备上测试你的应用

     http://www.guomii.com/posts/20637

     若是你已加入 iOS 开发者计划,你如今就可使用 Xcode 进行真机运行、测试和调试了,直接在xcode4中操做。

     当你将一台安装了有效描述文件的设备,链接到 Mac 上时,这台设备的名称以及当前系统版本会出如今Edit Scheme的Destination 菜单中。

 

24.error: failed to launch '/Users/gzty1/Library/Developer/Xcode/DerivedData/TianyaQing-chiobhpmbvwnqudfqnfawdzjrtey/Build/Products/Debug-iphoneos/TianyaQing.app/TianyaQing' -- failed to send the qLaunchSuccess packet

   从新从appstore上下载安装此软件,再删除,而后尝试真机调试

 

 

 

 

Xcode 是苹果公司的集成式开发环境(IDE),能够同时用来开发 iOS 和 Mac OS X 应用程序。当你在 Mac 电脑上安装 Xcode 以后,同时也会安装 iOS SDK,其中包含了 iOS 平台开发所需的接口等。

   在线安装下载地址 https://developer.apple.com/xcode/index.php

   下载地址 登陆进入 connect.apple.com,就能够看到下载列表

 

1. 编译项目时常报如  Undefined symbols:
".objc_class_name_PlacardView", referenced from:
literal-pointer@__OBJC@__cls_refs@PlacardView in MoveMe2View.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

这样的错误.

 

解决方法参考下文:

That has happened to me a lot of times. That error is caused when the compiler can't find a class or function. Besides the obvious reasons for that to happen, you should also do something like this:

On the left of the Xcode window go to the targets, and find your application. Open it. You should see a build phase named "Compile Sources". Make sure that your implementation file is included inside that build phase. If not, drag and drop it onto that build phase.

Also, make sure that you have all frameworks included and linked to your application! To make that sure, go into your application target again, and see the "Link Binary With Libraries" build phase. See if all necessary .framework files are in there. If not, add them using drag and drop.

 

在项目的Groups&Files窗口中,打开Targets/项目名 /Compile Sources/把提示找不到的源文件拖到这里.从新编译.

 

2.接上手机(版本 4.2.1 8c148a),在Organizer中,报The version of iOS  ...  does not match any of the versions of iOS supported...,重启手机,xcode都不能解决。最后,重装xcode_3.2.5_and_ios_sdk_4.2_final.dmg。

 

3.设置字体大小:

1)打开Preferences,快捷键是“Command +,”(注意,是三个键,按住command键,而后再快速地按“+”和“,”两个键便可)

2)选择“Fonts &Colors”,选中全部的“Category”,而后双击“Font”一列,在弹出的对话框中选择适合本身的字体大小便可。

 

4.重构

包括重构变量名,方法名,和类名。

选择变量名,点击Edit\Refactor\Rename...,要在输入框内输入新名字后,点Preview,而后Preview变成Apply,点击Apply。

http://blog.csdn.net/f520131480315/article/details/6457927

 

5.快照

    通常在开始重构以前要备份,选择File-Make Snapshot,Xcode会记住项目当前的状态。若是发现代码被改得面目全非,选择File-Snapshot,回到作快照的那一刻。

若是发现提示:Snapshot Failed:A project snapshot cannot be created. 多是一个磁盘镜像文件被损坏了,它用来存储快照,能够到~/Library/Application Support/Developer/Shared/SnapshotRepository.sparseimage 把镜像文件删掉,而后重启xcode。

    若是发现修改了某些代码以后出了问题,利用 Xcode 快照(snapshot)功能就能够轻松恢复工程到以前的状态,甚至已删除的工程也能够。快照会保存当前工程的全部状态到磁盘上,以备以后进行恢复。Xcode 的工程管理器中列出了全部可用的快照。

    能够随时手动建立快照,也可让 Xcode 根据场合自动建立快照,例如每次构建以前或经过查找并替换修改代码以前等。

     File > Create Snapshot,输入此快照的名称和描述,点按 Create Snapshot。
此快照就会出如今工程管理器中了。要恢复到此快照,请点选 File > Restore Snapshot。

 

6.help\search

 用来查找在菜单中的功能,命令等。

 

7.在svn上增长目录时,用import.

 

8. 修改某个文件时,弹出

This file is not writable. You could either perform an SCM Edit operation on this file, or allow editing anyway. You may not be able to save your changes, but you will be able to Save a Copy somewhere else.

是因为在本地锁定了文件,显示简介 ,去掉勾选已锁定。

 

9. 制表符替换成2个空格,在编写程序代码时用空格代替Tab,能够避免因为编辑器对tab显示方式不一样引发的代码错乱,是一种良好的编程风格

Xcode Preferences->Indentation 把indent width设置为2个空格。

 

10.格式化代码

    Edit - Format->Re-Indent

   在Xcode\Preferences...\ key bindings\拷贝一份xcode default\编辑Re-Indent 同时按下想要设置的快捷键。

 

   In Xcode 4, it's been moved to Editor (注意是Editor,不是Edit)> Structure > Re-Indent command (and has a default shortcut of CTRL+I ),默认快捷键是 Ctrl加i。它好按且未与其它快捷键冲突,因此不须要修改。

 

11.打不开工程文件时,打开project.pbxproj,查找冲突mine,删除冲突标记。

 

12.换过证书,提示provising文件问题,在 project.pbxproj 中查找提示那串码,删除掉这串码保存。

 

13.xcode 4.2 svn问题

    在Respotitories中选中工程目录后,点update,弹出对话框,"Error validating server certificate for  googlecode.com:443.......",解决办法:

    好比用浏览器登陆 http://code.google.com/p/.../source/checkout,复制 svn checkout https://xxx.googlecode.com/svn/trunk/ xxx --username xxx,到控制台中运行,提示Error validating server certificate for 'https://xxx.googlecode.com:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: *.googlecode.com
 - Valid: from Wed, 11 Apr 2012 00:04:01 GMT until Thu, 11 Apr 2013 00:14:01 GMT
 - Issuer: Google Inc, US
 - Fingerprint: cb:f1:c8:ac:28:d5:61:b7:c1:9c:73:7e:3a:b6:bb:e2:e6:55:95:2a
(R)eject, accept (t)emporarily or accept (p)ermanently?  输入p,开始checkout,而后到xcode中,发现也能够成功执行更新了。

 

  但在提交上,仍然弹出  Authentication realm: <https://xxx.googlecode.com:443> Google Code Subversion Repository
Password for '用户名': 
Authentication realm: <https://xxx.googlecode.com:443> Google Code Subversion Repository
Username: svn: Commit failed (details follow):
svn: MKACTIVITY of '/svn/!svn/act/19511c13-1823-4c4e-a551-3e0dfd8c0510': authorization failed: Could not authenticate to server: rejected Basic challenge (https://xxx.googlecode.com)

 

14.在xcode4.2中,

      Product -> Profile 再选择leaks,启用内存泄漏监测。

      相比之下,Product \ Analyze 是更好的工具,它分析一些垃圾代码,及潜在的内存泄漏,而且指出精确的代码行。能够看出,它建议全部自定义函数都返回自动释放的对象,不然会被列入潜在的内存泄漏中,potential leaks。

    添加framework,

  1. In the project navigator, selectyour project
  2. Select your target
  3. Select the 'Build Phases' tab
  4. Open 'Link Binaries With Libraries'expander
  5. Click the '+' button
  6. Select your framework
  7. (optional) Drag and drop the addedframework to the 'Frameworks' group

      且在xcode4中新建工程时,去掉Use storyboards,Use ARC,include Unit Tests三个复选。

 

15.  编译可执行文件时,报object file format invalid or unsuitable

       打开终端:

       sudo su 

       查看/usr/bin目录下是否存在codesign_allocate程序,若是存在,执行更名操做
       sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old

       将xcode目录下的codesign作一个软连接
       sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin

 

16. 真机调试时,提示 No provisioned IOS devices are available.Connect an IOS device or choose an IOS simulator as the destination.

      修改IOS Deployment Target,不要高于真机的版本。

http://rainbird.blog.51cto.com/211214/646828

 

17.添加预约义宏

    打开工程 Project--->Edit Project Editting(选着build)选项--->找到GCC Preprocessing->Preprocessor Macros ,例如设置其值为DEBUG=1

 

18.xcode4中修改编译生成文件的位置

   File\project settings\Derived data location\,选择Project-relative,输入文件夹名字

 

19. 真机调试报 error: failed to launch '/Users/gzty1/Library/Developer/Xcode/DerivedData/应用名-chiobhpmbvwnqudfqnfawdzjrtey/Build/Products/Debug-iphoneos/应用名.app/应用名' -- No such file or directory (/Users/gzty1/Library/Developer/Xcode/DerivedData/应用名-chiobhpmbvwnqudfqnfawdzjrtey/Build/Products/Debug-iphoneos/应用名.app/应用名)

     出现的缘由多是正在从appstore上安装此程序,同时又在真机调试安装些程序,致使后面真机调试安装此程序一直失败。

     解决方法:从新完成从appstore上安装此程序后,再尝试真机调试安装。

 

20. Xcode 提供了一系列用来管理整个开发流程的工具,从建立应用到测试、优化应用,直至上传应用到 App Store。

      http://www.guomii.com/posts/20273

      原英文版地址

      https://developer.apple.com/library/ios/#referencelibrary/GettingStarted/RoadMapiOS/Tools/CreateYourAppinXcode/StartYourProjectinXcode/StartYourProjectinXcode.html

      本《iOS应用开发入门指南》译自苹果官方的 Start Developing iOS Apps Today 系列教程。

      http://www.guomii.com/posts/20250

 

      Provisioning Portal 配置门户

      在建立新工程向导中,Class Prefix,应用委托就会被命名为 [Class Prefix]AppDelegate

 

21.Storyboards,故事板

     故事板里包含了定义此应用程序用户界面的对象、过渡(Transition)以及链接(Connection)。查看源文件发现MainStoryboard.storyboard是xml格式的内容。

     http://www.guomii.com/posts/20868

     利用 Xcode 检视器(Inspector),来观察视图控制器的状态等信息。

     须要注意的是,当选择一个视图时 Xcode 会将其高亮显示,此时画布中的颜色由于叠加可能会和 Colors 窗口中所选的颜色不彻底一致。

     对齐引导线,它们能帮你轻松在视图中将 UI 元素对齐到边界或中心位

 

22.IBAction和Outlet

    在 Xcode 中,给某个 UI 元素添加动做并设定相应的动做方法的途径是:按住 Control 键,并从画布上的该元素拖动到合适的源文件上(通常而言就是视图控制器的源文件)。故事板会把经过这种方式创建的链接进行存档。以后,当应用运行载入故事板时,这些链接就会被还原出来。

   在 Xcode 工具条里,点按 Utilities(实用工具)按钮关闭实用工具区域,而后点按辅助编辑器按钮(Assistant Editor)调出辅助编辑器面板。
确保辅助编辑器里显示的是视图控制器的头文件。在画布中,按住 Control 并从 Hello 按钮拖动到 HelloWorldViewController.h 的方法声明部分(即 @interface 语句到 @end 语句之间的部分)。

   在非苹果键盘上control键依然是Ctrl键。
   IBAction 是一个特殊的关键词,用来告诉 Xcode 把一个方法当成目标-动做链接来看待。IBAction 被定义为 void。

   插座变量(Outlet)描述的是两个对象之间的链接。当你须要让一个对象(例如视图控制器),与它所包含的一个对象(例如文本框)进行沟通时,你就会把被包含的那个对象称为插座变量。当应用运行起来时,你在 Xcode 里建立的插座变量就被还原出来了,这样在运行时这些对象就能够相互交流了。

   给文本框设置委托对象:按住 Control 键并从文本框拖动到场景坞里的黄色球体上(黄色球体表明视图控制器对象),当半透明面板出现时,选择 Outlets(插座变量)部分的delegate。

 

23.源代码控制管理(SCM)

     可以提供比快照更加细致入微的变动跟踪管理。(若是你在团队中与他人协同工做,源代码控制管理还能帮你提升团队效率。)SCM 系统会在磁盘中对每一个文件保存多个版本,并存储各个文件各个版本的元数据到 SCM 仓库中。

     Xcode 支持两种流行的 SCM 系统:Git 和 Subversion。Xcode 包含了一个版本编辑器,不管使用哪一种 SCM 系统均可以轻松对比保存在仓库中文件的不一样版本。若是你发现代码中出现了漏洞,则能够将最新的版本和以前的某个正常运行的版本拿来比较,让你捉出产生问题的“臭虫”。




24.分发和发布应用
     Xcode 可以让你轻松地将还没有正式发布到 App Store 的应用分享给测试者们。要分发应用,请在方案编辑器中建立一个应用归档。而后就可使用 Xcode 的归档管理器来让测试者们分享你的应用。

     当你准备正式发布应用的时候,能够先使用归档管理器来评估一下你的应用可否达到 App Store 审核的标准。这项评估可以经过则能够保障正式审核过程尽量地快速。而后就能够在 Xcode 正式向 App Store 提交你的应用了。

 

学习进度

http://www.guomii.com/posts/20284

 

25.在instruments中查看内存

    

The Living bytes, or Net bytes is how much memory your application is using at the time you select in the timeline. That will include leaked memory, since leaked memory is never deallocated.

#Living is how many allocations of a certain size/object type happened (and are still allocated). This is very useful when looking for leaks. For example, if you repetitively perform an action (like coming in an out of a modal view controller), and you see that #Living of an object grows by the same amount each time, then you're probably leaking those objects. You can then confirm by drilling down and seeing the exact line of code that is allocating the objects, and even see the time index each one was created.

Overall bytes includes memory that has been released. It's useful to track that number for performance optimization purposes, but not if you're just trying to see your current memory footprint or look for leaks.

 

笔画输入面板打开后,内存使用增长了20M

 

苹果bug--获取键盘有内存泄露问题
memory leaks in open_handle_to_dylib_path and UIKeyboardInputManagerClassForInputMode
If you're developing an iPhone app that uses UITextField objects and you're rigorous enough to check for memory leaks using Instruments, chances are you'd discover some leaks in UIKit and CoreGraphics libraries, stemming from some allocations done in dyld::mkstringf, called from dyld::loadPhase5.
According to some reports found on the web, it seems that this is a bug in the tools from Apple, and it appears only on the simulator, not when testing on the actual device. So you could safely ignore it. In any case you couldn't do anything about it, as the traceback leading to the leak goes through code outside of your control, that is, unless you happen to work for Apple :).

 

26.安装后能够看到还有一个dashcode,它用于web开发

相关文章
相关标签/搜索