0

I'm on a Mac and trying to script out a few things from our build for Xcode. There are dSYM that are directories that you can inspect with Show package contents. In my script that gets run after Xcode builds, I try to copy a dSYM to the output directory.

my command is this:

cp -vR "${BUILD_PATH}/${CONFIGURATION}-${DEVICE_TYPE}/${FRAMEWORK}.dSYM" "${OUTPUT_FOLDER}/${FRAMEWORK}.dSYM"

Expanded that would basically look like

cp -vR "${BUILD_PATH}/${ANOTHER_FOLDER}/MyFramework.framework.dSYM" "${OUTPUT_FOLDER}/MyFramework.framework.dSYM"

What happens is I get my dsym folder copied into the dsym folder so it looks like this:

MyFramework.framework.dSYM/MyFramework.framework.dSYM

I can rm -rf the dSYM before I copy it over, but was more curious if there was another way without removing it and what I was doing wrong. Thanks!

0

If you don't want the MyFramework.framework.dSYM parent folder copied in, then adjust the cp command so that it starts below that directory. To match the previous behavior, where every file within the dSYM directory was copied, even dot-files, you'll have to tell your shell to pick those up; with bash, it's with shopt -s dotglob.

The new cp command would be:

shopt -s dotglob
cp -vR "${BUILD_PATH}/${CONFIGURATION}-${DEVICE_TYPE}/${FRAMEWORK}.dSYM"/* \
       "${OUTPUT_FOLDER}/${FRAMEWORK}.dSYM"

Where all I've done is append /* to the end of the source path.

A sample run:

setup

$ tree -a build_path/
build_path/
└── configuration-type
    └── framework.dSYM
        ├── a
        ├── .dotfile-here
        └── subdir
            └── b

3 directories, 3 files

execution

cp -vR build_path/configuration-type/framework.dSYM/* output_folder/MyFramework.framework.dSYM

result

$ tree -a output_folder/
output_folder/
└── MyFramework.framework.dSYM
    ├── a
    ├── .dotfile-here
    └── subdir
        └── b

2 directories, 3 files
  • So this copies everything underneath the dSYM directory into a new directory dSYM right? basically replaces everything if it exists? thanks. – Crystal Oct 24 '18 at 3:44
  • It's the same cp command as you had before, it just skips that top-level dSYM directory so it doesn't get doubled-up. The -v flag makes for verbose output, showing each file that was copied; the -R flag makes it recurse down the source directory structure. – Jeff Schaller Oct 24 '18 at 9:58
  • For other shells and dotfiles, see unix.stackexchange.com/a/279448/117549 – Jeff Schaller Oct 24 '18 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.