Relative Path and absolute path settings in Xcode, xcode absolute path

Source: Internet
Author: User

Relative Path and absolute path settings in Xcode, xcode absolute path

Recently, there was nothing to worry about, and there was nothing to do with the loose in the blog garden. Suddenly, the yanxia shines on the magical place where Xiang Rui steamed and smoked song Zhu Cui xiuqi flowers were everywhere. Such beautiful scenery makes the hearts of the people yearn for, so you can't extricate yourself in it, Lele is not as good as everyone:

Relative and absolute paths for iOS development

Https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html

In iOS projects, especially before CocoaPods is used, a static library or Framework is often dragged directly to the project and compiled and run. Is this all right? Generally, when we configure a header file that contains the project directory in xcode, it must be associated with the relative path and absolute path. If you only use this project, it is not a problem to use the absolute path, however, if you send a project to someone else, someone else must change the absolute path. At this time, the disadvantages of the absolute path will immediately emerge.

XCode users can use Header Search Paths to configure environment variables. However, there is another parameter, User Header Search Paths. What is the difference between the two?

First, it is clear that Header Search Paths, as its name implies, is used to store the root cause of the Header file in the Project. Header files that are not added to the Project can be introduced by configuring Header Search Paths, this benefit prevents the project from containing too many files for easy management.

The obvious difference is that there are two methods for introducing header files through # include During encoding <> and "". <> Only Search from Header Search Paths, while "" can Search from Header Search Paths and User Header Search Paths. In other words, if you add the path to the User Header Search Paths, you can use the # include <file. h> method to introduce the corresponding Header file, and an error is returned. If you add the Header Search Paths, there is no problem.

The specific difference is: <> Search for files from the system directory space (corresponding to the Header Search Paths), "" is from the User directory space (corresponding to the User Header Search Paths). If you add the path to the User Header Search Paths, but <> you cannot find the newly added path from the system directory space, an error is returned.

 

Therefore, when modifying the User Header Search Paths option

"$ (SRCROOT)/Name of the current project/folder containing the header file"

After you copy the strings in the double quotation marks, you will find that the "$ (SRCROOT)" will automatically become the directory of the current project.

In this way, you can send it to others, and no one else needs to modify the path.

 

1. c/c ++ header file reference

Include <> reference the header file in the compiler's class library path

Include "" refers to the header file of the relative path of the project directory

Include is a Compilation instruction. during compilation, the compiler will replace the relative path with the absolute path. Therefore, the absolute path of the header file = search path + relative path.

Search Paths setting Search path under Xcode Build Settings

Header Search Paths: Header file Search path settings

$ (SRCROOT) macro and $ (PROJECT_DIR) macro both indicate the parent directory of xxx. xcodeproj.

 

For example, reference the header file testDemo/scr/test. h of the project,

Add $ (SRCROOT) to Header Search Paths and reference it as include "scr/test. h"

If $ (SRCROOT)/scr is added to the Header Search Paths, the Header file references include "test. h" directly"

 

1.

$ (Inherited) "$ (SRCROOT) modify the path of the. a file-Library Search Paths

$ (Inherited) "$ (SRCROOT)/. a file name"

// If multiple. a files are in this format

$ (Inherited) "$ (SRCROOT)/xxxx" "$ (SRCROOT)/xx"

If the relative absolute path is obtained, moving the project to another place may cause an error in running. Therefore, you need to change it to a relative path.

2.

Other Linker Flags: Other link labels

Set to "-ObjC"

When the imported static library uses a category, you must set it to-ObjC.

The above original Reprinted from http://www.cnblogs.com/muyushifang07/p/4460688.html

Thanks to the author for his originality of "Mu Yu Shifang 07.

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.