Skip to content

Commit 35249ce

Browse files
author
Guido Marucci Blas
committed
Merge pull request #15 from guidomb/install-carthage-from-release
Install carthage using .pkg from release.
2 parents 801684a + 26f98a1 commit 35249ce

File tree

9 files changed

+90
-2
lines changed

9 files changed

+90
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ and then run `.install`, the install script will install the builds script for e
4141

4242
Keep in mind that this only works for projects that have already installed the build scripts.
4343

44+
### Carthage users
45+
46+
If you use Carthage you can specify the required carthage version by your project in `script/.env` by setting the `REQUIRED_CARTHAGE_VERSION` variable.
47+
48+
All build script will check if the Carthage version matches the required version. If that is not the case the scripts will fail.
49+
4450
### Project configuration
4551

4652
All the scripts are smart enough to detect if you are using Carthage or Cocoapods and tune their behavior to use the workflow that best suites the underlaying dependency management tool.

install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ generate_env_file ()
6161
fi
6262

6363
echo "
64+
REQUIRED_CARTHAGE_VERSION=0.9.2
6465
PROJECT_NAME=$project_name
6566
XCODE_WORKSPACE=$xcode_workspace_file
6667
XCODE_PROJECT=$xcode_project_file" > "$1/script/.env"

script/bootstrap

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ bundle_install ()
8787
"or try to install the gems globally by running the following command:"
8888
print_gem_install_cmd
8989
printf "\033[0m"
90+
exit 1
9091
fi
9192
}
9293

@@ -165,6 +166,21 @@ install_dependencies ()
165166
fi
166167
}
167168

169+
install_carthage ()
170+
{
171+
source script/common/carthage
172+
173+
if type carthage > /dev/null
174+
then
175+
echo ""
176+
echo " → Checking installed version of carthage"
177+
echo ""
178+
check_carthage_version
179+
else
180+
force_install_carthage
181+
fi
182+
}
183+
168184
main ()
169185
{
170186
source script/.env
@@ -178,7 +194,7 @@ main ()
178194

179195
if [ -f Cartfile ]
180196
then
181-
brew_install "carthage"
197+
install_carthage
182198
bootstrap_carthage
183199
fi
184200

script/build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
set -e
44

5+
source script/common/carthage
6+
57
build_using_carthage ()
68
{
9+
check_carthage_version
710
carthage_cmd="carthage build --no-skip-current --platform ios"
811
if [ "$USE_SSH" == "true" ]
912
then

script/cibuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ main ()
2626
echo ""
2727
echo "####### Bootstrap Phase #######"
2828
echo ""
29-
script/bootstrap
29+
NO_CARTHAGE_UPDATE=true script/bootstrap
3030
local status=$?
3131

3232
if [ $status -eq 0 ]

script/common/carthage

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
force_install_carthage ()
2+
{
3+
echo ""
4+
echo " → Installing carthage '$REQUIRED_CARTHAGE_VERSION'"
5+
echo ""
6+
curl -s -L -O https://github.com/Carthage/Carthage/releases/download/$REQUIRED_CARTHAGE_VERSION/Carthage.pkg > /dev/null
7+
sudo installer -pkg Carthage.pkg -target / > /dev/null
8+
rm Carthage.pkg
9+
echo " ✔ carthage '$REQUIRED_CARTHAGE_VERSION' successfully installed"
10+
echo ""
11+
}
12+
13+
uninstall_carthage ()
14+
{
15+
echo ""
16+
echo " → Uninstalling carthage"
17+
echo ""
18+
local carthage_installed_version=`carthage version`
19+
if type brew > /dev/null && [ ! -z "$(brew list --versions carthage)" ]
20+
then
21+
brew uninstall carthage > /dev/null
22+
else
23+
sudo rm -frd /Library/Frameworks/CarthageKit.framework
24+
sudo rm /usr/local/bin/carthage
25+
fi
26+
echo " ✔ carthage '$carthage_installed_version' successfully uninstalled"
27+
}
28+
29+
check_carthage_version ()
30+
{
31+
local carthage_installed_version=`carthage version`
32+
if [ "$carthage_installed_version" != "$REQUIRED_CARTHAGE_VERSION" ]
33+
then
34+
printf "\033[1;31mError: carthage version '$carthage_installed_version' is not equal to '$REQUIRED_CARTHAGE_VERSION'"
35+
printf "\033[0m"
36+
if [ ! -z "$NO_CARTHAGE_UPDATE" ]
37+
then
38+
exit 1
39+
else
40+
echo ""
41+
echo ""
42+
echo "Would you like to update carthage to version '$REQUIRED_CARTHAGE_VERSION'? [N/y]"
43+
read update_carthage
44+
if [ "$update_carthage" == "y" ]
45+
then
46+
uninstall_carthage
47+
force_install_carthage
48+
else
49+
exit 1
50+
fi
51+
fi
52+
fi
53+
}

script/test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44

55
source script/.env
66
source script/script_hooks/schemes
7+
source script/common/carthage
78

89
run_tests ()
910
{
@@ -38,6 +39,11 @@ run_tests ()
3839
eval $test_command
3940
}
4041

42+
if [ -f Cartfile ]
43+
then
44+
check_carthage_version
45+
fi
46+
4147
current_schemes=$(schemes)
4248
if [ -z "$current_schemes" ]
4349
then

script/update

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
set -e
44

55
source script/.env
6+
source script/common/carthage
67

78
if [ -f Cartfile ] && type carthage > /dev/null
89
then
10+
check_carthage_version
911
carthage_cmd="carthage update --platform ios"
1012
if [ "$USE_SSH" == "true" ]
1113
then

tests/carthage/script/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REQUIRED_CARTHAGE_VERSION=0.9.2
12
PROJECT_NAME=iOSScriptsCarthage
23
XCODE_WORKSPACE=
34
XCODE_PROJECT=iOSScriptsCarthage.xcodeproj

0 commit comments

Comments
 (0)