Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Some more improvements
  • Loading branch information
maicki committed Feb 10, 2017
commit 28e822de62cf519312fc9473e59b02946d250e0c
153 changes: 47 additions & 106 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,49 @@ trap trap_handler INT TERM EXIT

DERIVED_DATA_PATH="~/ASDKDerivedData"
[ -d DERIVED_DATA_PATH ] || mkdir DERIVED_DATA_PATH
function clean_derived_data() {
rm -rf "$DERIVED_DATA_PATH"
}

function build_example() {
example="$1"

clean_derived_data

if [ -f "${example}/Podfile" ]; then
echo "Using CocoaPods"
if [ -f "${example}/Podfile.lock" ]; then
rm "$example/Podfile.lock"
fi
rm -rf "$example/Pods"
pod install --project-directory=$example

set -o pipefail && xcodebuild \
-workspace "${example}/Sample.xcworkspace" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
-derivedDataPath "$DERIVED_DATA_PATH" \
build | xcpretty $FORMATTER
elif [ -f "${example}/Cartfile" ]; then
echo "Using Carthage"
local_repo=`pwd`
current_branch=`git rev-parse --abbrev-ref HEAD`
cd $example

echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile"
carthage update --platform iOS

set -o pipefail && xcodebuild \
-project "Sample.xcodeproj" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build | xcpretty $FORMATTER

cd ../..
fi
}

MODE="$1"

Expand Down Expand Up @@ -58,44 +101,9 @@ if [ "$MODE" = "examples" ]; then
for example in examples/*/; do
echo "Building (examples) $example."

rm -rf ~/ModuleCache
rm -rf ~/Build
rm -rf ~/Info.plist
rm -rf ~/Logs

if [ -f "${example}/Podfile" ]; then
echo "Using CocoaPods"
if [ -f "${example}/Podfile.lock" ]; then
rm "$example/Podfile.lock"
fi
rm -rf "$example/Pods"
pod install --project-directory=$example

set -o pipefail && xcodebuild \
-workspace "${example}/Sample.xcworkspace" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
-derivedDataPath "$DERIVED_DATA_PATH" \
build | xcpretty $FORMATTER
elif [ -f "${example}/Cartfile" ]; then
echo "Using Carthage"
local_repo=`pwd`
current_branch=`git rev-parse --abbrev-ref HEAD`
cd $example

echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile"
carthage update --platform iOS

set -o pipefail && xcodebuild \
-project "Sample.xcodeproj" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build | xcpretty $FORMATTER
clean_derived_data

cd ../..
fi
build_example $example
done
trap - EXIT
exit 0
Expand Down Expand Up @@ -247,39 +255,7 @@ if [ "$MODE" = "examples-extra" ]; then
for example in $((find ./examples_extra -type d -maxdepth 1 \( ! -iname ".*" \)) | head -7 | head); do
echo "Building $example (examples-extra)."

if [ -f "${example}/Podfile" ]; then
echo "Using CocoaPods"
if [ -f "${example}/Podfile.lock" ]; then
rm "$example/Podfile.lock"
fi
rm -rf "$example/Pods"
pod install --project-directory=$example

set -o pipefail && xcodebuild \
-workspace "${example}/Sample.xcworkspace" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
-derivedDataPath "$DERIVED_DATA_PATH" \
build | xcpretty $FORMATTER
elif [ -f "${example}/Cartfile" ]; then
echo "Using Carthage"
local_repo=`pwd`
current_branch=`git rev-parse --abbrev-ref HEAD`
cd $example

echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile"
carthage update --platform iOS

set -o pipefail && xcodebuild \
-project "Sample.xcodeproj" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build | xcpretty $FORMATTER

cd ../..
fi
build_example "examples_extra/$example"
done
trap - EXIT
exit 0
Expand All @@ -290,42 +266,7 @@ if [ "$MODE" = "example" ]; then
#Update cocoapods repo
pod repo update master

example="examples/$2"
echo "Building (examples) $example."

if [ -f "${example}/Podfile" ]; then
echo "Using CocoaPods"
if [ -f "${example}/Podfile.lock" ]; then
rm "$example/Podfile.lock"
fi
rm -rf "$example/Pods"
pod install --project-directory=$example

set -o pipefail && xcodebuild \
-workspace "${example}/Sample.xcworkspace" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
-derivedDataPath "$DERIVED_DATA_PATH" \
build | xcpretty $FORMATTER
elif [ -f "${example}/Cartfile" ]; then
echo "Using Carthage"
local_repo=`pwd`
current_branch=`git rev-parse --abbrev-ref HEAD`
cd $example

echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile"
carthage update --platform iOS

set -o pipefail && xcodebuild \
-project "Sample.xcodeproj" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build | xcpretty $FORMATTER

cd ../..
fi
build_example "examples/$2"
trap - EXIT
exit 0
fi
Expand Down