In Xcode, we have to configure many paths in the Build Settings, then we will deal with the $(SRCROOT) and $(PROJECT_DIR) , But what the difference between them, can you show me an example, thx a lot.
$(SRCROOT) (aka $(SOURCE_ROOT) ) is a path to your location where a . xcodeproj is. It is simple to check, just put it in a field and Xcode gives you a tip. Follow this answer to receive notifications.
Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.
Exchangeable in practice, while the documentation makes these subtle theoretical distinctions:
SRCROOT
Directory path. Identifies the directory containing the target’s source files: contains the path to the project file that defines the target.
SOURCE_ROOT
is an undocumented alias to SRCROOT
PROJECT_DIR
Identifies the directory containing the project (.xcodeproj
)$(PROJECT_DIR)/build
is used as the create the default value for:
OBJROOT
SYMROOT
Typically these paths are not set per target, but are set per-project or per-user.
PROJECT_FILE_PATH
Identifies the project itself.
Equivalent to $(PROJECT_DIR)/$(PROJECT_NAME).xcodeproj
Conceptually different (#1 is about the project which defines the target while #2 is about the project independently of any target), they are always pointing to the same location since you are, in essence, always building a target.
References
Xcode 8.3 Build Settings reference
Xcode Build System Guide (Retired 2016-09-29)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With