Environment Variables of xcode4, Build Settings parameters, workspace and associated editing Settings

Source: Internet
Author: User

Original article: http://www.cnblogs.com/xiaodao/archive/2012/03/28/2422091.html

I. environment variables in xcode4

$(BUILT_PRODUCTS_DIR)

After the build is successful, the final product Path can be set in the Per-configuration Build Products Path of the Build Settings parameter.

$(TARGET_NAME)

Target Project Name

$(SRCROOT)

Path of the project file (such as Nuno. xcodeproj)

$(CURRENT_PROJECT_VERSION)

Current Project version

 

Others:

When the static library is compiled, the device selects the Simulator (iPhone 5.0 Simulator), and no Build Settings parameter is set, the default basic path is:

/Users/xxx/Library/Developer/Xcode/DerivedData/xxxWorkspace-caepeadwrerdcrftijaolkkagbjf

Use $ () to replace the long string above

$ (SYMROOT) = $ ()/Build/Products

$ (BUILD_DIR) = $ ()/Build/Products

$ (BUILD_ROOT) = $ ()/Build/Products

$ () Among the three variables will not change with the setting of the Build Settings parameter.

On the contrary, the following can be changed through settings:

$ (CONFIGURATION_BUILD_DIR) = $ ()/Build/Products/Debug-iphonesimulator

$ (BUILT_PRODUCTS_DIR) = $ ()/Build/Products/Debug-iphonesimulator

$ (CONFIGURATION_TEMP_DIR) = $ ()/Build/Intermediates/UtilLib. build/Debug-iphonesimulator

$ (TARGET_BUILD_DIR) = $ ()/Build/Products/Debug-iphonesimulator

$ (SDK_NAME) = iphonesimulator5.0

$ (PLATFORM_NAME) = iphonesimulator

$ (CONFIGURATION) = Debug

$ (TARGET_NAME) = UtilLib

$ (EXECUTABLE_NAME) = libUtilLib. a Executable File Name

$ {IPHONEOS_DEPLOYMENT_TARGET} 5.0

$ (ACTION) = build

$ (CURRENTCONFIG_SIMULATOR_DIR) Current simulator path

$ (CURRENTCONFIG_DEVICE_DIR) Current Device path

 

$ (BUILD_DIR)/$ (CONFIGURATION) $ (required tive_platform_name =

$ ()/Build/Products/Debug-iphonesimulator

$ (PROJECT_TEMP_DIR)/$ (CONFIGURATION) $ (required tive_platform_name) = $ ()/Build/Intermediates/UtilLib. build/Debug-iphonesimulator

 

Custom Variables

$ {CONFIGURATION}-iphoneos: Debug-iphoneos

$ {CONFIGURATION}-iphonesimulator: Debug-iphonesimulator

$ (CURRENTCONFIG_DEVICE_DIR) =$ {SYMROOT}/$ {CONFIGURATION}-iphoneos

$ (CURRENTCONFIG_SIMULATOR_DIR) =$ {SYMROOT}/$ {CONFIGURATION}-iphonesimulator

Customize a device-independent path (used to store products output by arm6, arm7, and i386 architectures)

$ (CREATING_UNIVERSAL_DIR) =$ {SYMROOT}/$ {CONFIGURATION}-universal

Value represented by custom Variables

$ (CURRENTCONFIG_DEVICE_DIR) = $ ()/Build/Products/Debug-iphoneos

$ (CURRENTCONFIG_SIMULATOR_DIR) = $ ()/Build/Products/Debug-iphonesimulator

$ (CREATING_UNIVERSAL_DIR) = $ ()/Build/Products/Debug-universal

 

Compile the script for iPhone os5.0:

Xcodebuild-project "UtilLib. xcodeproj "-configuration" Debug "-target" UtilLib "-sdk" iphoneos5.0 "-arch" armv6 armv7 "build RUN_CLANG_STATIC_ANALYZER = NO $ (BUILD_DIR) = "$ {BUILD_DIR}" BUILD_ROOT = "$ {BUILD_ROOT }"

 

Compile the script for iPhone simulator5.0:

Xcodebuild-project "UtilLib. xcodeproj "-configuration" Debug "-target" UtilLib "-sdk" iphonesimulator5.0 "-arch" i386 "build RUN_CLANG_STATIC_ANALYZER = NO $ (BUILD_DIR) = "$ {BUILD_DIR}" BUILD_ROOT = "$ {BUILD_ROOT }"

Add the following sentence to output to a file:

> "$ {BUILD_ROOT}. build_output"

 

Lipo script tool: combines the static class libraries of the iPhone simulator and the real machine to generate a common library

Lipo-create-output "$ {CREATING_UNIVERSAL_DIR}/$ {EXECUTABLE_NAME}" "$ {CURRENTCONFIG_DEVICE_DIR}/$ {EXECUTABLE_NAME}" $ {CURRENTCONFIG_SIMULATOR_DIR}/$ {EXECUTABLE_NAME }"

It means to merge the. a file under the "$ {CURRENTCONFIG_DEVICE_DIR} directory and the. a file under the $ {CURRENTCONFIG_SIMULATOR_DIR} directory,

Under the $ {CREATING_UNIVERSAL_DIR} directory, generate a static library for both devices,

Example: lipo-create-output xy. a x. a y.

 

2. parsing common parameters of build Settings in xcode4

1. Installation Directory: Installation path

During static library compilation, set "$ (BUILT_PRODUCTS_DIR)" in Installation Directory in Build Settings )"

Set Skip Install to YES

The default Installation Directory is/usr/local/lib.

By default, the. a file is stored for a long time (for example,/Users/xxx/Library/Developer/Xcode/DerivedData/xxxProgram ).

Dalrvzehhtesxdfqhxixzafvddwe/Build/Products/Debug-iPhoneos) path, or the path specified by target

If the Skip Install is NO, it may be installed to the default path/usr/local/lib.

2. Public Headers Folder Path: Path of the exposed header file

Set it to "include" (the specific header file path is: $ (BUILT_PRODUCTS_DIR)/include/xx. h)

Generate an include directory under the directory of the final file.

Default Value:/usr/local/include

Public Headers Folder Path this Path is the external header file required for a project using this lib. After importing this Path, # include/import "xx. h" can be seen

3. User Header Search Paths: the dependent external Header file Search path

Set to "$ (BUILT_PRODUCTS_DIR)/include"

Corresponds to the path in 2.

4. Per-configuration Build Products Path: Final file Path

For example, if it is set to "../app", the final file will be created in the app directory under the directory of the project file. xcodeproj.

The default value is $ (BUILD_DIR)/$ (CONFIGURATION) $ (inclutive_platform_name)

Equal to $ (BUILT_PRODUCTS_DIR)

5. Per-configuration Intermediate Build Files Path: Temporary Intermediate file Path

Default Value: $ (PROJECT_TEMP_DIR)/$ (CONFIGURATION) $ (inclutive_platform_name)

6. Code Signing Identity: Certificate selection for real machine debugging

Select a certificate corresponding to Bundle identifier

Library Search Paths: Library Search path

Ubuntures: Architecture, set to armv6 or armv7

Valid ubuntures: application framework, which can be set to armv6, armv7, or i386

Product Name: project file Name. Default Value: $ (TARGET_NAME)

Info. plist File: info File path

Build Variants: The default value is normal.

Other Linker Flags: Other link labels

Set to "-ObjC"

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

IOS Deployment Target: ios Deployment object

For example, you can select a version from ios3 to ios5.

Prefix Header: Pre-compiled Header file (for example: UtilLib/UtilLib-Prefix.pch)

Precompile Prefix Header: set to "Yes", which indicates that precompilation headers are allowed.

 

3. workspace)

Role: manage multiple projects and associate multiple projects

 

Iv. workspace multi-project Association settings

I,

1. Create a static library project, such as UtilLib, and generate the UtilLib. h and UtilLib. m files.

2. Select the header file to be published,

Set Target Membership to public in the right column

Alternatively, select the copy headers item of the Build Phases tag of the target project directory and add the header file to be published in public.

3. Set ubuntures to armv6 armv7.

4. Valid ubuntures is set to armv6 armv7 i386

5. Set the Build Products Path to $ (SRCROOT)/../build

6. Set Per-configuration Build Products Path:

$ (SRCROOT)/../build/$ (CONFIGURATION) $ (inclutive_platform_name)

7. Per-configuration Intermediate Build Files Path is set:

$ (SRCROOT)/../build/$ (TARGET_NAME). build/$ (CONFIGURATION) $ (inclutive_platform_name)

8. Set the Installation path: Installation Directory

9. Set the Public header file Path: Public Headers Folder Path entry

 

10. Add the dependent shell script for the static library

Select the Build Phases tag of the target project directory and click the Add Build Phase button of the project.

Select Add run script in the pop-up menu, and an additional Run Script item will appear on the page.

Enter "$ SRCROOT/mergeArmSymbols. sh" in the black box"

Establish the dependency on this script (this script will be run after the static library is compiled)

If the device selects the iphone simulator during compilation:

The script will generate the. a static library useful to the device in the Debug-iphoneos product directory of the corresponding iphone device,

Conversely, if the device is an iphone device:

This script will generate a. a static library useful to simulator in the Debug-iphoneos product directory of the corresponding iphone simulator.

Finally, this script calls the lipo tool to merge the static library generated by this project with the static library generated by this script to generate a. a file common to both the simulator and device.

 

11. The specific bash shell script is as follows:

MergeArmSymbols. sh

Download the image on the right and change the suffix to. sh (in fact, it is the script above, because the blog can only upload images)

The directory structure after static library compilation is as follows:

 

II,

1. Create a master project, such as Nuno, and add the dependency on the static library.

Click project, and in the Link Binary With Libraries item of the Build Phases label, click the plus sign to add UtilLib. a library.

Select the red item above, select Relative to Project in Location on the right bar, and set the value to ../libs/libUtilLib.

2. Set the external Header file path that the main project depends on: User Header Search Paths item

$ (SRCROOT)/../include

3. Set the Header Search Paths to $ (SRCROOT)/../include

4. Set the Library Search Paths to $ (SRCROOT)/../libs

Compile and run the code to enable Association

 

(Note: select the simulator iphone 5.0 simulator. when compiling the static library, the final file will be in Debug-iphonesimulator, even if the. a file is successful, it will still be red,

This may be an xcode bug and will not automatically switch the path.

Because $ (BUILT_PRODUCTS_DIR) refers to the position of build/Debug-iphonesos, not the Debug-iphonesimulator that contains the final. a file;

Select ios Device and the final file compiled is under build/Debug-iphonesos. The. a file is not red.

All solutions must be implemented using the mergeArmSymbols. sh script)

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.