Here is a summary of several common XcodeErrorAs well as solutions, we hope toLearningXcodehttp://www.maiziedu.com/course/234/Helpful.1. Dead Storage issuesCocoachina Cocoachina Cocoachina This issue was mentioned in the previous article, the reason for the re-listing, because this problem is also very common. The reason for this problem is that when we assign a value directly to an object, if the method that contains the object ends immediately, then the object is automatically freed, but we do not have it at all, so we have a dead storage code, and this assignment statement is actually invalid.2. Access to a non-existent methodObjC method calls are very different from C + +. C + + has bound classes and methods at compile time, and a class cannot invoke a nonexistent method, otherwise it will report a compilation error. OBJC is the runtime to find out which method should be called. Both implementations have advantages and disadvantages, and C + + binding makes it fast to invoke the method, but only with the virtual keyword to achieve limited dynamic binding. For the objective-c language, it essentially uses "message structure" rather than "function call" because OBJC is evolved by Smalltalk, the originator of a message-based language. The key difference is that, using the language of the message structure, the code that the runtime should execute is determined by the runtime environment, and the language used by the function call is determined by the compiler. If the function called in the code is polymorphic, then the language in which the function is called will follow the "virtual method table (virual table)" To find out which function to implement. A language that takes a message structure, whether polymorphic or not, always finds the method to be executed at run time. In fact, the compiler doesn't even care what type of object the message is being accepted for. An object problem that receives a message is also handled at run time, and the process is "dynamic binding." For example, here's a line of code
[Self newmethod];
Suppose we call a non-existent method, we will report the exception of unrecognized selector sent to instance. In fact, we use Respondstoselector: method to judge. In most cases, you might want to add a bit of judgment when using delegate, because delegate is usually an ID type (generic type). if ([Self respondstoselector: @selector (Newmethod)]) {[Self newmethod];}3. Stack OverflowIn most cases, the application does not need to consider the size of the heap and stack, always as large enough to be used to meet the general business development. But in fact the heap and stack are not unlimited, too many recursion will cause the stack overflow, too many alloc variables will cause the heap overflow. iOS memory layout principle is as follows: A typical distribution of a run-time process has five parts, namely code snippets, initialization data segments, uninitialized data segments, heaps, stacks.
In the memory space allocated by the application, the lowest address bit is a fixed code segment and data segment, up is a heap, used to store global variables, for OBJC, is alloc out of the variable, will be put in here, the heap is not enough when you will apply for space. The top high address bit is the stack, and the local basic type variable is placed in the stack. OBJC objects are manipulated by pointers, local variable pointers are in the stack, global variables in the heap, and no matter what the pointer, alloc out of the heap, so alloc out of the variable must remember release. For autorelease variables, each function has a corresponding autorelease pool, the function out of the stack when the pool is destroyed, and call the pool inside the variable dealloc function to achieve its internal alloc out of the variable release. The links below will help you understand the stack better, but in StackOverflow
On, all in English, you can translate step by step to help you understand.
Http://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap4. Multithreading Concurrent OperationsThis should be a problem that you will encounter in your daily development operations. When an object is modified by multiple threads, it is possible for a thread to access the object while another thread has deleted it, causing Crash. It is more common in the Network task queue, the main thread into the queue to join the task, the network thread at the same time to delete operations caused by the hang off. The solution to this problem is to add a thread lock to one of the threads, for example:
-(void) Addstudent: (Student *) Student {if (Student = = nil) {nslock* alock = [[Nslock alloc] init];//Create a thread lock [Alock lock];//plus lock [students addobject:student]; [Alock unlock];//Unlock}}
You can also use keyword synchronized to simplify your code
-(void) Addstudent: (Student *) Student {if (Student = = nil) return; @synchronized (players) {[Students addobject:student]; } }
The Synchronized keyword is actually a mutex, meaning that when the previous thread's task is not completed (locked), then the next thread will go to sleep waiting for the task to complete, and when the previous thread's task is completed, the next thread will wake up and perform the task automatically. In the daily development, try not to lock, because multithreaded development itself is to improve the program execution sequence, and the synchronization lock itself can only be a process execution, which inevitably reduce the efficiency of execution, unless it must be locked, where there is a hidden danger, there is lock, in the use of mutex, to minimize its scope, the larger the scope, The worse the efficiency. Of course, the thread lock is quite different, and the code snippet above uses just the normal thread lock. The thread lock in iOS is also available in the following ways:
1) Nsrecursivelock recursive Lock: The use of ordinary nslock if in the case of recursion or repeated lock-in case, oneself with their own resources to lead to deadlock. COCOA provides a nsrecursivelock lock that can be locked multiple times without deadlock, as long as the number of unlock is the same as the number of lock times. 2) Nsconditionlock condition Lock: Most of the time the lock is not need to care about what conditions under unlock, to use when the lock, run out of unlock will be finished. The COCOA provides this conditional lock, which can be unlocked if certain conditions are met. The lock and unlock, lockwhencondition is a random combination, can not be used to correspond. 3) pthread_mutex_t: Synchronous lock, based on the C language of the synchronization lock mechanism, the use of methods similar to other synchronous locking mechanism. 4) Nsdistributedlock Distributed Lock: This is a lock used to share resources between multiple processes.here are some specific error handling1.warning:could not resolve external type C:OBJC (CS) NSObject
Debug area error (taken from network)
I've had this problem lately, Previously written by a small project (Xcode6.2), because of the XCODE7 version of the update, resulting in a small problem such as 2-1, and then after their own changes, and in the original project integration of the Bugtags SDK, and then the compilation failed, the error occurred, then forgot. I found the debug method in stack overflow, with the following steps:
1) Go to build Settings, build Options, Debug information Format
2) Change the Debug setting from ' DWARF with DSYM File ' to ' DWARF '
3) Leave the Release setting at "DWARF with DSYM File"
The problem appears to is that Xcode is trying to create DSYM files for Debug builds. You don ' t need DSYM files for Debug builds--it's release builds where you need them.What is a dsym file? After Xcode compiles the project, we will see a DSYM file with the same name, DSYM is a transit file that holds the address mapping information of the 16 binary functions, the symbols we debug will be included in this file, and a new DSYM file will be generated each time the project is compiled, located in/users /< User Name >/library/developer/xcode/archives directory, we need to save the corresponding Archives file for each release version.2.-[__nsarrayi objectatindex:]: Index beyond bounds [0.. 1] 'The problem belongs to the array out of bounds, drop-down refresh, pull-up loading tableview when easy to appear. This problem needs to be solved in the work environment that corresponds to you, for example, if the array is to remove the marked details from scratch, it is a place where mistakes can be overlooked.3. The old project cannot load network data after upgrading Xcode7This problem, Xcode7 just updated when it is very common, this is because IOS9 introduced the new features of the APP Transport security (ATS: Simple understanding means: Application Transport security ... Translation may not be accurate, just the literal meaning of the understanding, please correct. Because the new feature requires that the Internet access within the app must be using the HTTPS protocol, the protocol is more secure than the HTTP protocol, but many companies today still use the HTTP protocol for many projects. Sometimes it can not be changed to HTTPS protocol immediately, can only be modified in the project. The steps to modify are as follows:
1) Open the project Info.plist file
2) Add the item nsapptransportsecurity in the Plist file, and the type is a dictionary.
3) Add subkey Nsallowsarbitraryloads, type Boolean, and the value is yes. 4) Command+r can be4. Empty objects exist in the array
The problem is because the inserted object in an array is a null value, and the point of debugging can be interrupted in the wrong place. Errors may not occur in debug mode, but in release mode. Because Objective-c is a dynamic language, the problem of an array object being empty may not be an error in the run-time environment, but in a working environment the object is nil error.
In fact, this problem can be optimized when writing code, that is, when creating an array, use literal syntax, which is the form of syntactic sugars. Or, the array with the null value of the object may appear and the IF statement is judged.
God book "Effective Objective-c 2.0" on this issue has a deep-seated explanation, you can go to see, the people who have seen said well.5.[beror]codesign error:certificate Identity ' iPhone distribution: *. ' appears more than once in the keychain. The Codesign tool requires there only is one.The above error occurs when the project is archive packaged. Cause: This problem occurs because of a conflict between multiple certificates. Solution: Open the Mac System utility-Keychain Access-my certificates, and if you see duplicate certificate names, remove the earlier certificate and restart Xcode. \ \6.Could executable permissions on the application.Cause: Having the same bundle identifier is already running on the device.
Workaround: Remove the app from the device or emulator.7.ld:library not found For-lmp3lameclang:error:linker command failed with exit code 1 (use-v to see invocation). /c0>Cause: In the work, it is common for many people to edit the same project when one of them did not upload a library.
Solution: Upload a specific static library8.A Valid Provisioning profile matching the application ' s Identifier ' XXXX ' could not being foundCause: When the problem occurs after compiling, either the certificate is missing or the corresponding certificate is not selected in the code Signing identity or the certificate does not correspond. Workaround: Reload the certificate and check whether the certificate is selected for correspondence.9. In the ARC project, a third-party library developed using MRC mode1) Open the targets setting to which the project belongs
2) Click the build Phases option, go to the subkey compile sources, find the file using MRC, add the-FNO-OBJC-ARC tag, indicate at compile time that the file uses MRC to compile
3) Conversely, if you want to use the arc file in an MRC project, you can use the-FOBJC-ARC tag toA link error occurred in 10.Xcode compilation, and a "duplicate symbols for architecture i386 clang" prompt appearsProblem: When linking, the project has duplicate files
Solution:
1. View Targets->bulid Phases-link Binary with libraries in xcode with or without duplicate lib
2. Full Project Search under duplicate name file11. For category in the static library, the project referencing the static library uses the category in which the "unrecognized sent to class" hint appearsProblem: The linker difference between the standard static library and OC. In the standard UNIX static library, linker symbol is generated in accordance with each category, but because the category does not produce a class, the above error is thrown. Workaround:
1. In the static library, Targets->bulid setting->linker flags-> add-OBJC
2. Targets->build setting->linker flags-> plus-all_load or-force_load in the project using this static library12.warning:ld:warning directory not found for option '-l 'Problem: Usually the path problem
Solve:
Targetstext found build Setting, then the library search Paths and framework search Paths, delete the compiler warning path. Original from:Cocoachina
Xcode Common Error Solving method