Error, debugging

Source: Internet
Author: User
Tags key string print object

Some of them are also written in development tools/xcode

 

Http://article.ityran.com/archives/1143

 

1. When compiling an iPad, you have selected the deleetures: Standard (armv6) basesdk: iphonedevice3.2 targetdevicefamily: iPad.

If the following error occurs during compilation:

Command/developer/platforms/iphoneos. Platform/developer/usr/bin/gcc-4.2 failed with exit code 1

The complieforthumb in the gcc4.2codegeneral region is not selected.

After you have the developer certificate and private key, you can directly debug it on the jailbreaking mobile phone.

 

2. During link compilation, "_ objc_class _ $ _ XXX" and referenced from: you may need to recreate a file of a class.

Or: select the project name, and select the target column (displayed as a circle) in the detail list, check this file, or select again. to add it to this target.

 

3. When regexkitlite is used in sdk4.0 or later, the 'capturecount' was not declared in this scope error is reported, which is the reason why it is used in non-. M files.

Http://www.cocoachina.com/bbs/read.php? Tid = 38784 & page = E & #

 

4. There is no SDK with the name or path.

From the open source code of down on the Internet, this error often occurs when the result is run, and there is no IOS deployment target option in deployment.

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

Try the project/edit Active Target/and set active SDK menu items and switch back and forth to Active configuration.

 

5. The error exec_bad_access, exc_bad_instruction indicates that the app has a memory management problem, which is generally caused by access to the wild pointer object.

A memory-related crash is generally difficult to locate the source code, because this demon may have done bad things in the program for a long time. If a piece of problematic Code breaks down the memory structure, the butterfly effect may be shown in a long time later and always in different places. Therefore, if there is an impossible change in the pointer type, it is likely that the memory structure is confused by the calling of the wild pointer.

After some warnings are fixed, some memory errors may be prevented. Warning indicates a compilation warning in the Yellow triangle near the row number on the left. If you click the Yellow Triangle, xcode may pop up a "Fix-it" suggestion.
Exc_bad_access does not crash like SIGABRT, so it will not get a clear error message. However, you can use zombies! Death object tool. Open the scheme editor of this project, select the run option, and then select the diagnosics label. Check the Enable zombie objects option. After the zombie tool is enabled, the memory of the object will not be cleared even if the object is released. Therefore, the memory will be marked as "immortal ". If you try to use this memory again later, the app will be aware of your incorrect operations and will throw "Message
Sent to daellocated instance "error and stops running.

Add the nszombieenabled environment variable to the project and set it to enable. When exc_bad_access occurs, the xcode console prints the Problem description. Set this parameter to double-click the executable module under executables, in the displayed window, variables to be set in the environment, add nszombieenabled, and set it to yes. Click the check box to enable this variable.

You can add mallocstacklogging to enable the malloc record to get more prompts to help locate the problem.

In the gdb window, enter shell (Format: Shell malloc_history <ID> <address>)Malloc_history
1436
0x5f7fcf0,
You can also remove the preceding shell commands, such as malloc_history, when running on the terminal. <ID> <address>

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

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

The preceding environment variables should be set only when the memory needs to be debugged.

Note: Zombie objects should not be enabled all the time. Because this tool will never release the memory, it simply marks that the memory is not dead, and you will eventually exhaust all the memory at some time, because all allocated memory will not be reused. Therefore, zombie objects should be enabled only when memory-related errors are checked. Otherwise, zombie objects should be disabled.

 

In 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 retriable there.

 

6. When running an iPhone program, the pop-up window says "The program failed and the preset description file has expired ". Solution: In xcode, window> orgnazy> your iPhone> Delete the profile before the program with red. Then run the program from xcode.

7. Code sign error: the identity doesn't match any valid certificate/private key pair in the default keychain

The code signing identity in the get info \ build of the project and targets is changed to null.

8. debug Printing

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. Compile command/developer/platforms/iphonesimulator. Platform/developer/usr/bin/clang failed with exit code 1, and change C/C ++ compiler version to gcc4.2

10. This class is not key value coding-compliant for the key viewcontroller

You may have created a view-based project and deleted the generated viewcontroller. XIB also has references to it. In IB, delete it directly with the delete key.

11. A preset file named "embedded. mobileprovision" already exists on this computer. Do you want to replace it?

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

12. Failed to upload *. app upon real-time debugging

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

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

13. Set delegate to nil first when you record the release.

A node should not retain any reference to nodes that do not belong to it.

14. Simulator

After upgrading xcode to 4.3.1, we found that the iPad simulator does not have the home key. Command + Shift + H can achieve the effect similar to clicking the Home Key.

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. How can I debug the real machine of iPod Touch 2 generation, iPhone 3G, and other devices in xcode 4.2?
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. If the provising file cannot be found when compiling the real machine, go to project. pbxproj and delete the string id value.

17. Connect the 3gs with ios4.2 installed on xcode4.3. The prompt is xcode has encountered an unexpected error (0xc002)
No such file or directory, at '/sourcecache/dtdevicekit/DTDeviceKit-1196/dtdevicekit/dtdevicekit_utilities.m: 100'

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/

Or for ios6.1 CD/users/wangweike/library/developer/xcode/IOS devicesupport/6.1 (10b144)/symbols/system/library/caches/COM. Apple. dyld

Touch. copied_dyld_shared_cache_armv6
Touch. processed_dyld_shared_cache_armv6
Touch dyld_shared_cache_armv6
Or
Touch. copied_dyld_shared_cache_armv7
Touch. processed_dyld_shared_cache_armv7
Touch dyld_shared_cache_armv7

18. convert an exception to a breakpoint to facilitate debugging:
In the left-side breakpoint Management window of xcode (command + 6), click + in the lower left corner to add symbolic breakpoint, enter objc_exception_throw, and click done. Then, right-click the breakpoint and choose move breakpoint, select a project name or user, which can play a role in all projects.
You can also add a symbolic breakpoint that inputs malloc_error_break to track and debug objects that have been released twice.

By using exception breakpoint (exception breakpoint), xcode is told to suspend the program before an exception is thrown. In this way, the exception throws are quickly pointed out. In the breakpoint navigator, there is a small plus sign ("+") at the bottom. Click it, select Add exception breakpoint, and then click done. Run the program. If an exception occurs, the code editor will stop and point to one of the lines in the Code. It is no longer an annoying compilation code, and be sure to debug navigatot on the left) the stack information is different.

Sometimes there is no easy-to-understand error message because no exception is thrown. Before xcode tells you the cause of the exception, the exception breakpoint has been suspended. Sometimes, some partial error messages are obtained from exception breakpoint, but sometimes they are not obtained. To get all the error messages, you may need to click the "Continue Program Execution" button on the toolbar of the debugger multiple times, if the error "this class is not key value coding-compliant for the key XXX" is often caused by loading this nib, but some of the references in it may not exist. Especially when you remove the outlet attribute in the Code, the connection is not removed from nib.

19. xcode has built-in GDB. During debugging, you can use the gdb command in the output window to debug the program.

Po command: Stands for print object. It displays the text description of the object (the string information obtained from the description message of the object ).

P command: print the pointer address.

Print command: It is similar to formatting output, which can output different object information:

Info command: We can view the information of the memory address.

Show command: Displays information about GDB. For example, show version displays the gdb version.

Help Command: If you forget the syntax of a command, you can use the help command name to obtain help information. For example, help info shows the usage of the info command.

C command: A Short continue command.

 

The "po" command is short for "Print Object. "$ Eax" is a register of the cup. In the case of an exception, this register will contain a pointer to the exception object. Note: $ eax only works in the simulator. If debugging is performed on the device, use the "$ R0" register.

Po $ eax: This command will call the "Description" method for this object and print it out.

Po [$ eax class]

Po [$ eax name]

Po [$ eax reason]

20. nslog

On a real machine, nslog consumes resources,

Programs compiled in release mode do not use nslog output. programs compiled in debug mode execute all nslog functions.

# Ifndef _ optimize __
# Define nslog (...) nslog (_ va_args __)
# Else
# Define nslog (...)
# Endif

Or

# Ifdef _ optimize __
# Define nslog (...)
# Endif

The magic of this Code is that the release mode usually defines _ optimize __, but the debug mode does not. By placing this code in the header file, you can safely use nslog!

Put the code in * prefix. PCH, which is the most efficient. You can put this macro definition in a header file and then include this header file in * prefix. PCH.

Http://lichen1985.com/blog? P = 251

Log printing in IOS:

Custom nslog # define nslog (@ "# % s # % d #", strrchr (_ file __, '/') ,__ line _); nslog, for example, nslog (@ "begin main function"); printed as follows #/main. MM ## 30 # begin Main Function

Reference http://xcodev.com/wordpress? M = 201204

21. The error log directory is in Mac OS X :~ /Library/logs/crashreporter/mobiledevice/<device_name>

IOS exception caught crash report, three methods

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

Two methods are provided to capture abnormal exit information of software on the iPhone.

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: xxxxxx' appears more than once in the keychain. The codesign tool requires there only be one
Cause of error: the private certificate is generated for the same computer multiple times, and the proversionning file is generated each time. Download and follow the instructions on the same iOS device, this problem occurs when the program is compiled to the device again.
Modify Method: In xcode, choose Window> organizer. Under the library, select provisioning profiles. Find the previous provisioning profiles. Delete.
In the system's Keychains, that is, in the key string Management Program, log on to my certificate and delete the early private certificate.
Recompile

23. Test your application on iOS devices

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

If you have joined the IOS developer program, you can now use xcode to run, test, and debug the real machine and directly operate on xcode4.

When you connect a device with a valid description file to a Mac, the device name and current system version will appear in the destination menu of Edit scheme.

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

Re-download and install the software from the appstore, delete the software, and try to debug the real machine.

25. The executable was signed with invalid entitlements.

Change provising File

26. How to make IOS apps crash with ease

Http://www.cocoachina.com/newbie/tutorial/2012/0829/4672.html

Http://www.cocoachina.com/gamedev/misc/2012/0829/4668.html

27. By default, if the method name does not exist, the compiler does not report an error, but directly causes the program to crash when the method is called. There is a relevant compiler alarm settings that can be used. In build setting, select "undeclared selector ".

28. Release packages cannot be installed on non-jailbreaking test plan mobile phones.

29. Defensive Programming

Nsassert is often used to check possible human errors. Nsassert will notify you of the changes to be made during array initialization, rather than randomly causing program crash.

For example, verify that the returned node is the cclable Class Object: 
 nsassert ([node iskindofclass: [cclabel class], @ "node is not a cclabel! ");

30. iOS unit test in xcode

Http://www.cocoachina.com/newbie/env/2012/0516/4257.html

31.

TIPS:

If a crashes in Main. M, you can set a global exception breakpoint (exception breakpoint ).

B. You have not obtained any useful information when the exception breakpoint is enabled. In this case, run the app several more times, or enter the "po $ eax" command after the debugging prompt.

C. The general cause of most crashes and some bugs are lost or wrong connections in your XIB or storyboard. These situations are not displayed in compilation errors, so you generally do not know.

D. Do not ignore the compilation warning. If you have a compilation warning, it means that something may go wrong. If you don't know why you get a compilation warning, you 'd better understand it. These are safe practices!

E. debugging on the device may be slightly different from that on the simulator. These two environments are not exactly the same and you will get different results.

For example, when you run a problematic program on iPhone 4, the first crash will occur during nsarray initialization because you lack an Nil flag, instead of crashing when the app executes setlist. So the above principle can help you find the root cause of the crash.

F do not forget the static analyzer tool, which will capture more errors. If you are a beginner, we recommend that you enable it. You can set your project on the build settings page:

32. Complete the error due to lack of various frameworks

Http://xyxdasnjss.iteye.com/blog/1748113

Other linker flags:-objc-licucore, and then add various required frameworks.

-Objc is added to both the Lib project and the project that uses Lib. This flag tells linker to load every object file Defining class or category to the static library.

33. Fixed the crash caused by pressing the lock screen key when entering Chinese Characters in IOS 6.0.

Http://code4app.com/snippets/one/%E8%A7%A3%E5%86%B3iOS-6.0-%E4%B8%8B-%E5%9C%A8%E8%BE%93%E5%85%A5%E4%B8%AD%E6%96%87%E6%97%B6-%E6%8C%89%E4%B8%8B%E9%94%81%E5%B1%8F%E9%94%AE-%E5%AF%BC%E8%87%B4%E7%9A%84%E9%97%AA%E9%80%80%E9%97% AE %E9%A2%98/50bc191c6803fa5f5c000002

34.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.