skip to Main Content

In Xcode, pressing ⌘B (build target) can build the project, it will generate the build in the path ~/Library/Developer/Xcode/DerivedData/{AppName}-{hash}.

  • How could I know the whole path of the build (with the hash value) by a script? Can I find that path in my .xcodeproj?
  • When I use ⇧⌘U (build test target only), where can I find the test target build?

2

Answers


  1. The build paths can be controlled using BUILT_PRODUCTS_DIR , PROJECT_TEMP_DIR , CONFIGURATION_BUILD_DIR and CONFIGURATION_TEMP_DIR etc . https://help.apple.com/xcode/mac/11.4/#/itcaec37c2a6

    There’s no need to extract them from some non-public file format specification.

    If you must do it, init a temporary git repo with a xcodeproj file in it. Commit it. Make a change in one of the variables and then run git diff.

    Login or Signup to reply.
    1. How could I know the whole path of the build (with the hash value) by a script?
    1. Change to the same folder where your project or workspace is
    2. Run xcodebuild -showBuildSettings
    3. May need to add the proper scheme or target. See man xcodebuild

    See sample below to find by script

    1. When I … build for test target only, where can I find the test target build?

    It will be in the same folder with a name similar to <Test_Target_Name>-Runner.app. This is useful as you can use for Cloud device testing services.


    # This example works with Xcode project with a single scheme
    # Echo to stdout
    xcodebuild -showBuildSettings
    xcodebuild -showBuildSettings | grep CONFIGURATION_BUILD_DIR
    
    # save to a variable for use in your script
    #   A little brutal, so I'm open to other ways to do this.
    CONFIGURATION_BUILD_DIR=$(xcodebuild -showBuildSettings 2> /dev/null | grep CONFIGURATION_BUILD_DIR | sed 's/[ ]*CONFIGURATION_BUILD_DIR = //')
    echo $CONFIGURATION_BUILD_DIR
    

    If you are using Xcode Server Bots

    cd ${XCS_PRIMARY_REPO_DIR}
    xcodebuild -showBuildSettings
    

    Sample output:

    /Users/roblabs/Library/Developer/Xcode/DerivedData/openmaptiles-ios-demo-eectbiabcmhajpdbcoqnaipiaqpd/Build/Products/Release-iphoneos


    As noted in https://stackoverflow.com/a/57512068,

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


    For further documentation on the build setting properties, see Build Setting Reference at developer.apple.com. The link that @puio listed is also useful.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search