Skip to content

Instantly share code, notes, and snippets.

@mlavergn
Last active November 19, 2019 15:21
Show Gist options
  • Save mlavergn/d1e7df1dee875ab74fee707312924658 to your computer and use it in GitHub Desktop.
Save mlavergn/d1e7df1dee875ab74fee707312924658 to your computer and use it in GitHub Desktop.
Xcode switcher which uses Make as it's interpreter while leveraging xcodebuild and xcode-select
#!/usr/bin/make -f
.DEFAULT_GOAL := main
# eval trick to avoid re-execing variable
SEL = $(eval SEL := $$(shell read sel && echo $$$$sel))$(SEL)
102:
sudo xcode-select -s /Applications/Xcode-102-10E125.app
xcodebuild -version
110:
sudo xcode-select -s /Applications/Xcode-110-11A420a.app
xcodebuild -version
112:
sudo xcode-select -s /Applications/Xcode-112-11B52.app
xcodebuild -version
main: prompt select
prompt:
@echo "Current $(shell xcodebuild -version)"
@echo "Xcode version"
@echo "\t1) 10.2"
@echo "\t2) 11.0"
@echo "\t3) 11.2"
@echo -n 'Selection: '
select:
@if [ ${SEL} = 1 ]; then\
$(MAKE) -f xc 102;\
fi;\
if [ ${SEL} = 2 ]; then\
$(MAKE) -f xc 110;\
fi;\
if [ ${SEL} = 3 ]; then\
$(MAKE) -f xc 112;\
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment