Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Setup] Add build phases for copying README and source code files #38

Merged
merged 3 commits into from
Jul 19, 2022

Conversation

yo1995
Copy link
Collaborator

@yo1995 yo1995 commented Jul 18, 2022

Description

This PR adds 2 build phases to the project file

  • Copy Source Code Files
  • Copy README.md Files For Source Code View

so that the README and Swift source code files can be accessed in the bundle, to be shown in the source code and README view in the app.

Linked Issue(s)

How To Test

This is the preparation for the cs-3704 mini project.

To Discuss

The shell script to copy READMEs

This script copies all the READMEs to the bundle's root folder: Samples.app/READMEs/{sample_name}

(i.e. Bundle.main.url(forResource: "name", withExtension: "md", subdirectory: "READMEs")!)

echo $BUILT_PRODUCTS_DIR

# Directory to which the readmes will be copied.
READMES_DIR=${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/READMEs
mkdir -p "${READMES_DIR}"

# Root readme for the project to skip.
DEFAULT_README=$SRCROOT/README.md

# Find all README.md files in the project.
find ${SRCROOT} -name "README.md" | while read file
do
    # Skip the root readme for project.
    if [ "$file" = "$DEFAULT_README" ]
    then
        echo $BUILT_PRODUCTS_DIR
        continue
    fi
    
    # Extract the folder name from the path.
    FILE_PATH=$(dirname "$file")
    FOLDER_NAME=$(basename "$FILE_PATH")
    
    cp "${file}" "${READMES_DIR}/${FOLDER_NAME}.md"
done

@yo1995 yo1995 self-assigned this Jul 18, 2022
@yo1995 yo1995 requested review from clee088 and philium July 18, 2022 17:30
@yo1995 yo1995 merged commit 57a45a7 into v.next Jul 19, 2022
@yo1995 yo1995 deleted the Ting/PrepREADME branch July 19, 2022 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants