๐ŸŽ iOS/SwiftUI

git@my_private_repo.git: An unknown error occurred. reference 'refs/remotes/origin/main' not found (-1) ์˜ค๋ฅ˜ ํ•ด๊ฒฐ

JerryiOS 2023. 3. 2. 20:06

๋ฌธ์ œ์ƒํ™ฉ


git@my_private_repo.git: An unknown error occurred. reference 'refs/remotes/origin/main' not found (-1)

 

SPM์— ์ƒˆ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•  ๋•Œ ์ด๋Ÿฐ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

ํ•ด๊ฒฐ


์‰˜ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋งŒ๋“ค์–ด ํ•ด๊ฒฐํ•œ๋‹ค.

vi fix-spm-cache.sh

๋จผ์ € ์ด๋ ‡๊ฒŒ ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์ฃผ๊ณ 

#!/bin/bashif [[ $# -eq 0 ]] ; then
    echo 'Please call the script with the name of your project as it appears in the derived data directory. Case-insensitive.'
    echo 'For example: ./fix-spm-cache.sh myproject'
    exit 0
fi# Delete all directories named "remotes" from the global Swift Package Manager cache.
cd ~/Library/Caches/org.swift.swiftpm/repositoriesfor i in $(find . -name "remotes" -type d); do
    echo "Deleting $i"
    rm -rf $i
done# Find derived data directories for all projects matching the script argument, and
# delete all directories named "remotes" from source package repositories cache for those projects.cd ~/Library/Developer/Xcode/DerivedData/for project in $(find . -iname "$1*" -type d -maxdepth 1); do
    for i in $(find "$project/SourcePackages/repositories" -name "remotes" -type d); do
        echo "Deleting $i"
        rm -rf $i
    done
done

์‰˜ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌํ•ด์ฃผ๊ณ  :wq ๋ช…๋ น์–ด๋กœ ์ €์žฅํ•˜๊ณ  ๋‚˜์˜จ๋‹ค.

chmod +x fix-spm-cache.sh

๊ทธ ๋‹ค์Œ chmod ๋ช…๋ น์–ด๋กœ ํŒŒ์ผ์— ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•œ ํ›„

./fix-spm-cache.sh [๋‚ดํ”„๋กœ์ ํŠธ๋ช…]

ํŒŒ์ผ์„ ์‹คํ–‰ํ•œ๋‹ค.

์ € ์Šคํฌ๋ฆฝํŠธ๋Š” ํ”„๋กœ์ ํŠธ์˜ ํŒŒ์ƒ ๋ฐ์ดํ„ฐ ๋””๋ ‰ํ„ฐ๋ฆฌ์™€ .NET์˜ ์ „์—ญ Swift Package Manager ์บ์‹œ์—์„œ Swift ํŒจํ‚ค์ง€ ์บ์‹œ๋ฅผ ์‚ญ์ œํ•˜์—ฌ ํ•ด๊ฒฐ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋ผ๊ณ  ํ•œ๋‹ค.

์ฐธ๊ณ ํ•œ ๊ณณ

https://stackoverflow.com/questions/72631756/spm-unknown-error-reference-not-found-when-changing-branch/74130700#74130700

๋ฐ˜์‘ํ˜•