Xcode environment variables and path settings

Source: Internet
Author: User

I. Environment variables in the XCODE4

$ (Built_products_dir)

After the build succeeds, the final product path--can be set in the Per-configuration build products path key of the build settings parameter

$ (target_name)

Target Project Name

$ (srcroot)

Path to project files (such as nuno.xcodeproj)

$ (current_project_version)

Current Project version number

Other:

When compiling the static library, device selector simulator (IPhone 5.0 Simulator), the default base path is not set for any build settings parameters:

/users/xxx/library/developer/xcode/deriveddata/xxxworkspace-caepeadwrerdcrftijaolkkagbjf

Use $ () instead of the above a long string of Dongdong

$ (symroot) = $ ()/build/products

$ (BUILD_DIR) = $ ()/build/products

$ (build_root) = $ ()/build/products

The $ () in these three variables does not change as the build settings parameter is set

Instead, the following can be changed by setting

$ (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 emulator path

$ (CURRENTCONFIG_DEVICE_DIR) Current device path

$ (Build_dir)/$ (CONFIGURATION) $ (Effective_platform_name =

$ ()/build/products/debug-iphonesimulator

$ (Project_temp_dir)/$ (CONFIGURATION) $ (effective_platform_name) = $ ()/build/intermediates/utillib.build/ Debug-iphonesimulator

Custom variables

${configuration}-iphoneos says: Debug-iphoneos

${configuration}-iphonesimulator says: Debug-iphonesimulator

$ (currentconfig_device_dir) = ${symroot}/${configuration}-iphoneos

$ (currentconfig_simulator_dir) = ${symroot}/${configuration}-iphonesimulator

Customizing a device-independent path (used to store a variety of architectures arm6/arm7/i386 output products)

$ (creating_universal_dir) = ${symroot}/${configuration}-universal

The value represented by the custom variable

$ (CURRENTCONFIG_DEVICE_DIR) = $ ()/build/products/debug-iphoneos

$ (CURRENTCONFIG_SIMULATOR_DIR) = $ ()/build/products/debug-iphonesimulator

$ (CREATING_UNIVERSAL_DIR) = $ ()/build/products/debug-universal

Compile script under iphoneos5.0:

Xcodebuild-project "Utillib.xcodeproj"-configuration "Debug"-target "Utillib"-sdk "iphoneos5.0"-arch "ARMv6 armv7" bu ILD Run_clang_static_analyzer=no $ (build_dir) = "${build_dir}" build_root= "${build_root}"

Compile script under iphonesimulator5.0:

Xcodebuild-project "Utillib.xcodeproj"-configuration "Debug"-target "Utillib"-sdk "iphonesimulator5.0"-arch "i386" b Uild 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: Merge the static class library of iphone simulator and real machine, generate common library

Lipo-create-output "${creating_universal_dir}/${executable_name}" "${currentconfig_device_dir}/${executable_name } "" ${currentconfig_simulator_dir}/${executable_name} "

This means: Merge the. A file under the directory "${currentconfig_device_dir. A", and the. A file under directory ${currentconfig_simulator_dir},

Under the ${creating_universal_dir} directory, generate a static library that is common to two devices,

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

Analysis of common parameters of build settings in Xcode4

1.Installation Directory: Installation path

When a static library is compiled, installation directory Settings "$ (built_products_dir)" in Build settings

Skip Install set to Yes

installation directory defaults to/usr/local/lib

Because the build location defaults, the. A file is placed very long (for example:/users/xxx/library/developer/xcode/deriveddata/xxxprogram

Dalrvzehhtesxdfqhxixzafvddwe/build/products/debug-iphoneos), or the path specified by our target

Skip Install if it is no, it may be installed to the default path/usr/local/lib

2.Public Headers Folder Path: public header file path

Set as "include" (The specific header file path is: $ (built_products_dir)/include/xx.h)

Generate an include directory in the final file. A sibling directory

Default:/usr/local/include

Public Headers Folder Path This path is an external header file that relies on a project that uses this lib. After you import this path, you #include/import "Xx.h" to see

3.User Header Search Paths: Dependent external header file searching path

Set to "$ (built_products_dir)/include"

Corresponds to the path in 2

4.per-configuration Build Products Path: Final file path

For example, set as ". /app ", will be in the project file. Xcodeproj in the app directory on the top-level directory, create the final file

Default is $ (build_dir)/$ (CONFIGURATION) $ (effective_platform_name)

equals $ (Built_products_dir)

5.per-configuration Intermediate Build Files Path: temporary intermediate file paths

Default is: $ (project_temp_dir)/$ (CONFIGURATION) $ (effective_platform_name)

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

Select a certificate corresponding to bundle identifier

Library Search Paths: Gallery Searching path

Architectures: schema, set to ARMv6 or ARMV7

Valid Architectures: Application framework, can be set to ARMv6, ARMV7, or i386

Product Name: Project file name, default is $ (target_name)

Info.plist file:info file path

Build variants: Default to Normal

Other Linker Flags: Additional link tags

Set as "-OBJC"

When you import a static library that uses a category, it needs to be set to-OBJC

IOS Deployment Target:ios Deployment Object

For example, you can choose a version that is set to, IOS3 to iOS5

Prefix Header: Pre-programmed headers (e.g.: UTILLIB/UTILLIB-PREFIX.PCH)

Precompile Prefix Header: Set to "Yes" to allow precompiled headers to be added

Third, workspace (work area)

Role: Managing multiple Projects (project), multi-project linking

Iv. Workspace Multi-project linking Setup

One

1. Create a new static library project, such as Utillib, and generate UtilLib.h and UTILLIB.M files

2. Select the header file that you want to expose.

Set the target membership in the right column to public

Or, select the copy headers entry for the build phases tag of the project directory target and add the header file to be exposed in public

3.Architectures set to: ARMv6 armv7

4.Valid architectures set to: ARMv6 armv7 i386

5.Build products Path is set to: $ (srcroot)/. /build

6.per-configuration Build Products Path is set to:

$ (srcroot)/.. /build/$ (CONFIGURATION) $ (effective_platform_name)

7.per-configuration Intermediate Build Files path is set to:

$ (srcroot)/.. /build/$ (target_name). build/$ (CONFIGURATION) $ (effective_platform_name)

8. Set the installation path: Installation directory entry

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

10. Adding dependent shell scripts for a static library

Select the build phases tag of the project directory target and click the Add Build Phase button from the bottom corner.

Select the Add Run script item in the pop-up menu, and a run script item will appear in the page

Fill in the "$SRCROOT/mergearmsymbols.sh" in the black box.

Establish a dependency on this script (run this script after compiling the static library)

If the device selected at compile time is iphone simulator:

This script will be generated in the product catalog Debug-iphoneos for the iphone device, which is useful for device. A static library,

Conversely, if the device is choosing an iphone device:

This script will be generated in the product catalog Debug-iphoneos corresponding to the iphone simulator to simulator useful. A static library

Finally, this script calls the Lipo tool, merges the static library generated by this project with the static library generated by this script, and generates a. A file that is common to both simulator and device.

11. The specific bash shell script is as follows:

[Plain]View Plaincopy
  1. mergearmsymbols.sh
  2. # Version 2.0 (updated for Xcode 4, with some fixes)
  3. # Author:adam Martin-http://twitter.com/redglassesapps
  4. # Based On:original script from Eonil (main Changes:eonil ' s script would not work in Xcode gui-it would CRASH YOUR Compu TER)
  5. #
  6. # more Info:see this Stack Overflow question:http://stackoverflow.com/questions/3520977/ Build-fat-static-library-device-simulator-using-xcode-and-sdk-4
  7. #################[Tests:helps Workaround any further bugs in Xcode]########
  8. #
  9. Debug_this_script= "true"
  10. if [$DEBUG _this_script = "true"]
  11. Then
  12. echo "########### TESTS #############"
  13. echo "Use of the following variables when debugging this script; Note that they could change on recursions "
  14. echo "Build_dir = $BUILD _dir"
  15. echo "build_root = $BUILD _root"
  16. echo "Configuration_build_dir = $CONFIGURATION _build_dir"
  17. echo "Built_products_dir = $BUILT _products_dir"
  18. echo "Configuration_temp_dir = $CONFIGURATION _temp_dir"
  19. echo "Target_build_dir = $TARGET _build_dir"
  20. echo "sdk_name = $SDK _name"
  21. echo "platform_name = $PLATFORM _name"
  22. echo "CONFIGURATION = $CONFIGURATION"
  23. echo "target_name = $TARGET _name"
  24. echo "arch_to_build = $ARCH _to_build"
  25. echo "arch_to_build = $ARCH _to_build"
  26. echo "ACTION = $ACTION"
  27. echo "symroot = $SYMROOT"
  28. echo "executable_name = $EXECUTABLE _name"
  29. echo "Currentconfig_simulator_dir = $CURRENTCONFIG _simulator_dir"
  30. echo "Currentconfig_device_dir = $CURRENTCONFIG _device_dir"
  31. echo "############ #Other ###########"
  32. echo "build_dir/configuration/effective_platform_name = $BUILD _dir/$CONFIGURATION $effective_platform_name"
  33. echo "project_temp_dir/configuration/effective_platform_name = $PROJECT _temp_dir/$CONFIGURATION $effective_ Platform_name "
  34. Fi
  35. #####################[Part 1]##################
  36. # First, work out the BASESDK version number
  37. # (incidental:searching for substrings in SH is a nightmare! SOB)
  38. Sdk_version=$ (Echo ${sdk_name} | grep-o '. \{3\}$ ')
  39. # Next, work out if we ' re in SIM or DEVICE
  40. if [${platform_name} = "Iphonesimulator"]
  41. Then
  42. Other_sdk_to_build=iphoneos${sdk_version}
  43. arch_to_build= "ARMv6 armv7"
  44. Else
  45. Other_sdk_to_build=iphonesimulator${sdk_version}
  46. Arch_to_build= "i386"
  47. Fi
  48. echo "XCode have selected SDK: ${platform_name} with version: ${sdk_version} (although back-targetting: ${iphoneos_deploym Ent_target}) "
  49. echo "... therefore, Other_sdk_to_build = ${other_sdk_to_build}"
  50. #
  51. #####################[end of Part 1]##################
  52. #####################[Part 2]##################
  53. #
  54. # IF This is the original invocation, invoke whatever and other builds are required
  55. #
  56. # Xcode is already building one target ... build only the missing platforms/configurations.
  57. If ["true" = = ${alreadyinvoked:-false}]
  58. Then
  59. echo "Recursion:not The root invocation, don ' t recurse"
  60. Else
  61. # Prevent Recursion
  62. Export alreadyinvoked= "true"
  63. echo "recursion:i am the root ... recursing all missing build targets ..."
  64. echo "recursion: ... about to invoke:xcodebuild-configuration \" ${configuration}\ "-target \" ${target_name}\ "-SDK \" ${O Ther_sdk_to_build}\ "-arch \" ${arch_to_build}\ "${action} run_clang_static_analyzer=no"
  65. Xcodebuild-project "${target_name}.xcodeproj"-configuration "${configuration}"-target "${TARGET_NAME}"-SDK "${ Other_sdk_to_build} "-arch" ${arch_to_build} "${action} run_clang_static_analyzer=no build_dir=" ${BUILD_DIR} "BUILD_ root= "${build_root}" > "${build_root}.build_output"
  66. action= "Build"
  67. # Merge all platform binaries as a fat binary for each configurations.
  68. # Calculate where the (multiple) built files is coming from:
  69. currentconfig_device_dir=${srcroot}/. /build/${configuration}-iphoneos
  70. currentconfig_simulator_dir=${srcroot}/. /build/${configuration}-iphonesimulator
  71. echo "Taking device build from: ${currentconfig_device_dir}"
  72. echo "Taking simulator build from: ${currentconfig_simulator_dir}"
  73. creating_universal_dir=${srcroot}/. /build/${configuration}-universal
  74. echo "... outputing a universal arm6/arm7/i386 build to: ${creating_universal_dir}"
  75. # ... remove the products of previous runs of this script
  76. # Nb:this Directory is a created by this script-it should being safe to delete
  77. Rm-rf "${creating_universal_dir}"
  78. mkdir "${creating_universal_dir}"
  79. #
  80. echo "lipo:for Current configuration (${configuration}) Creating output file: ${creating_universal_dir}/${executable_ NAME} "
  81. Lipo-create-output "${creating_universal_dir}/${executable_name}" "${currentconfig_device_dir}/${executable_name } "" ${currentconfig_simulator_dir}/${executable_name} "
  82. ###### #custom ########
  83. #copy Universal Lib to. /libs
  84. Libsdir=. /libs
  85. Includedir=. /include
  86. Rm-rf "${libsdir}"
  87. Mkdir-p "${libsdir}"
  88. echo "Cp-r ${creating_universal_dir}/${executable_name} ${libsdir}"
  89. Cp-r "${creating_universal_dir}/${executable_name}" "${libsdir}"
  90. echo "Cp-r ${currentconfig_device_dir}/include ${includedir}"
  91. Cp-r "${currentconfig_device_dir}/include" "${includedir}"
  92. Fi


Download the image on the right and change the suffix to. SH (in fact, the above script, because the blog park can only upload pictures)

The directory structure after the static library is compiled is as follows:

Two

1. Create a new master project, such as Nuno, to add a dependency on a static library

Click Project, click the plus sign in the Build Phases tab of the link Binary with libraries to add the UTILLIB.A library

Select the red item above and in the right column, select relative to Project and set the value to: /libs/libutillib.a

2. Set the external header file path that the main project relies on: User header Search Paths entry

$ (srcroot)/.. /include

3. Set the header Search paths to: $ (srcroot)/. /include

4. Set the library Search paths to: $ (srcroot)/. /libs

Compile and run to implement the binder

(Note: Select Simulator iphone 5.0 simulator, when compiling the static library, the final file will be in Debug-iphonesimulator, even if it succeeds. A file is still red,

This is a bug that may be xcode and does not automatically switch paths

Because $ (built_products_dir) refers to a location that is Build/debug-iphonesos, not a debug-iphonesimulator that contains the final. a file;

Select iOS Device to compile the final file under Build/debug-iphonesos,. A file becomes non-red

All have to be solved with mergearmsymbols.sh script)

Reference

Http://blog.sina.com.cn/s/blog_6de18992010190kk.html

Http://www.cnblogs.com/xiaodao/archive/2012/03/28/2422091.html

Xcode environment variables and path settings

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.