Xcode (linker command failed with exit code 1) Error summary, xcodelinker

Source: Internet
Author: User

Xcode (linker command failed with exit code 1) Error summary, xcodelinker

This problem usually occurs when a third-party library file or multiple developers are added.

This problem is generally caused by a link error because the file cannot be found. We can troubleshoot from the following aspects.

First, you can try the following methods:  

1. Check whether the newly added file has the same name as the previous file.

2. The error message contains the name of a class. Go to the original file and check # which third-party libraries have been imported. Comment out these libraries one by one and find the database with the error, then, follow the official steps to add it again.

3. SVN or git ignores some files, such as. o files, which cannot be updated. The. o file may be red. You can add or modify the SVN (git) Ignore settings.

4. Delete the. a file and drag it back to the project to solve the problem.

5. The file may have been added again (or the Copy items if neded option may not be checked). We recommend that you delete the file and add it again.

6. If the file name in the project is repeated, the same error may occur.

7. "Build Settings"-> "Enable Bitcode" is set to NO, because some sdks do not support Bitcode.

8. It is possible to write # import "XXXXX. m" when it is referenced. If it is changed to # import "XXXXX. h"

9. The imported SDK may only run on the real machine. The simulator reports an error!

Take the following error as an example. The following error occurs after AFNetworking is installed using cocoa Pods.

 

This is the same as the file in the project, because the framework has been added before AFNetworking is installed through cocoa Pods. The project runs before it is completely deleted.

 

If multiple developers are involved, the following error occurs after synchronization is completed.
  1. Undefined symbols for architecture armv7:
  2. "_ OBJC_CLASS _ $ _ MyPageLogViewController", referenced from:
  3. Objc-class-ref in BaiduMobStatAppDelegate. o
  4. Ld: symbol (s) not found for architecture armv7
  5. Clang: error: linker command failed with exit code 1 (use-v to see invocation)


The "MyPageLogViewController" class is displayed in the error. You can find the. m file of this class and view its Target Membeship, as shown in figure

 

If not selected, click it. Then compile and view.

 

If it is a newly added third-party library and is not a static library

Repeat the first step and find Build settings> Linking> Other Linker Flags.

Modify this attribute to-all_load or-ObjC, depending on the situation. In short, you can try multiple times.

If a third-party static library (. a file) is added)  
  1. Undefined symbols for architecture armv7:
  2. "_ OBJC_CLASS _ $ _ BaiduMobStat", referenced from:
  3. Objc-class-ref in BaiduMobStatAppDelegate. o
  4. Objc-class-ref in MyPageLogViewController. o
  5. (Maybe you meant: _ OBJC_CLASS _ $ _ BaiduMobStatAppDelegate)
  6. Ld: symbol (s) not found for architecture armv7
  7. Clang: error: linker command failed with exit code 1 (use-v to see invocation)


Errors occur in all files used in this library, such as the BaiduMobStatAppDelegate class and MyPageLogViewController class.

 

In this case, the Link error may be caused by the path confusion of the static library.

Solution: Build settings-> Search Path-> Library Search Paths to add the corresponding Path of the static Library.

Library path error:

  • The error is as follows:LibraryException.

"directory not found for option '-L/..."

Solution:

Choose Project> targets> Build Setting> Library Search Paths.

Delete the path

  • The error is as follows:FrameworkException.

"directory not found for option '-F/..."

Solution:

Choose Project> targets> Build Setting> Framework Search Paths.

Delete the path

OK.

1. Framework Search Paths

The framework (.framework bundles).

2. Library Search Paths

Third-party Library (.a files), Xcode automatically sets the path to the. a file in Xcode.

 

Related Article

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.