Skip to content

spm #4

Description

@kevin373738

Step 1: Create a scripts Directory

If you don’t already have a dedicated location for scripts, you can create one in your project directory or home directory:

mkdir -p ~/scripts

Step 2: Create the Script File

Inside this scripts directory (or another location of your choice), create a new file for the script:

touch ~/scripts/refresh_xcode.sh

Step 3: Edit the Script

Open the script file in a text editor to add the content:

nano ~/scripts/refresh_xcode.sh

Copy and paste the script content:

#!/bin/bash
echo "Cleaning Xcode build data and resolving package dependencies..."

# Clear DerivedData folder
rm -rf ~/Library/Developer/Xcode/DerivedData

# Clear SPM cache
rm -rf ~/Library/Caches/org.swift.swiftpm

# Open Xcode and resolve dependencies
xcrun xcodebuild -resolvePackageDependencies

echo "Done!"

Save and close the editor.

Step 4: Make the Script Executable

Make the script executable so you can run it directly from the command line:

chmod +x ~/scripts/refresh_xcode.sh

Step 5: Run the Script

To execute the script, run:

~/scripts/refresh_xcode.sh

Optional: Add to PATH

To make it easier to run the script from anywhere, add the scripts directory to your PATH by adding this line to your shell profile (e.g., ~/.bashrc or ~/.zshrc):

export PATH="$PATH:~/scripts"

Now, you can simply run:

refresh_xcode.sh

This setup makes the script easily accessible and keeps it organized in a dedicated location.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions