Skip to content

Commit

Permalink
scripts were changed and improved regarding new paths
Browse files Browse the repository at this point in the history
  • Loading branch information
yoalex5 committed Sep 4, 2019
1 parent a1e486a commit 09d6912
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Temporary Items
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
generated/
DerivedData/

## Various settings
Expand Down
60 changes: 25 additions & 35 deletions scripts/buildPrebidMobile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,45 @@ fi
# Set bash script to exit immediately if any commands fail.
set -e

cd ../

# 2
# Setup some constants for use later on.
FRAMEWORK_NAME="PrebidMobile"
GENERATED_FOLDER_NAME="generated"

LOG_DIR="$GENERATED_FOLDER_NAME/log"
LOG_FILE="$LOG_DIR/prebid_mobile_build.log"
LOG_FILE_ABSOLUTE="$PWD/$LOG_FILE"

cd ../src/PrebidMobile/
XCODE_BUILD_DIR="$GENERATED_FOLDER_NAME/xcodebuild"
XCODE_BUILD_IPHONE_FILE_ABSOLUTE="$PWD/$XCODE_BUILD_DIR/Build/Products/Release-iphoneos/$FRAMEWORK_NAME.framework"

FRAMEWORK_NAME="PrebidMobile"
LOGDIR=../../build/out/log
mkdir -p "$LOGDIR"
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# 3
# If remnants from a previous build exist, delete them.
if [ -d "build" ]; then
rm -rf "build"
if [ -d "$GENERATED_FOLDER_NAME" ]; then
rm -rf "$GENERATED_FOLDER_NAME"
fi

LOGFILE="$LOGDIR"/prebid_mobile_build.log
touch "$LOGFILE"
mkdir -p "$LOG_DIR"
touch "$LOG_FILE"

echo $PWD
gem install cocoapods --user-install
pod install --repo-update

# 4
# Build the framework for device and for simulator (using
# all needed architectures).
echo "Building the framework for device"
xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch arm64 only_active_arch=no defines_module=yes -sdk "iphoneos" > "$LOGFILE" 2>&1 || { echo "Error in build check log "$LOGFILE""; exit 1;}

echo "Building the framework for simulator"
xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch x86_64 only_active_arch=no defines_module=yes -sdk "iphonesimulator" > "$LOGFILE" 2>&1 || { echo "Error in build check log "$LOGFILE""; exit 1;}
# 5
# Remove .framework file if exists on Desktop from previous run.
if [ -d "${HOME}/Desktop/${FRAMEWORK_NAME}.framework" ]; then
rm -rf "${HOME}/Desktop/${FRAMEWORK_NAME}.framework"
fi
echo -e "${GREEN}-Building the framework for device${NC}"
xcodebuild -workspace PrebidMobile.xcworkspace -scheme "PrebidMobile" -configuration Release -arch arm64 only_active_arch=no defines_module=yes -sdk "iphoneos" -derivedDataPath $XCODE_BUILD_DIR > "$LOG_FILE" 2>&1 || { echo -e "${RED}Error in build check log "$LOG_FILE_ABSOLUTE"${NC}"; exit 1;}

# 6
# Copy the device version of framework to Desktop.
cp -r "build/Release-iphoneos/${FRAMEWORK_NAME}.framework" "${HOME}/Desktop/${FRAMEWORK_NAME}.framework"
echo -e "${GREEN}-Building the framework for simulator${NC}"
xcodebuild -workspace PrebidMobile.xcworkspace -scheme "PrebidMobile" -configuration Release -arch x86_64 only_active_arch=no defines_module=yes -sdk "iphonesimulator" -derivedDataPath $XCODE_BUILD_DIR > "$LOG_FILE" 2>&1 || { echo -e "${RED}Error in build check log "$LOG_FILE_ABSOLUTE"${NC}"; exit 1;}

# 7
# Replace the framework executable within the framework with
# a new version created by merging the device and simulator
# frameworks' executables with lipo.
lipo -create -output "${HOME}/Desktop/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "build/Release-iphoneos/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "build/Release-iphonesimulator/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}"

echo "Done! You can find the Prebid Mobile framework on your Desktop"
echo "Build logs are also available in the build/out/log/ folder."

# 8
# Delete the most recent build.
if [ -d "build" ]; then
rm -rf "build"
fi
echo -e "${GREEN}Done!${NC} \nPrebid Mobile framework for iPhone path is "$XCODE_BUILD_IPHONE_FILE_ABSOLUTE""
echo "Build logs path is "$LOG_FILE_ABSOLUTE""
11 changes: 7 additions & 4 deletions scripts/testPrebidDemo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ if [ -d "scripts" ]; then
cd scripts/
fi

echo "Running integration tests"
cd ../example/Swift/PrebidDemo/

cd ..
echo $PWD
gem install cocoapods --pre

gem install cocoapods --user-install
pod install --repo-update
xcodebuild -workspace PrebidDemo.xcworkspace test -scheme "PrebidDemoTests" -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.2' | xcpretty -f `xcpretty-travis-formatter` --color --test

echo "Running integration tests"
xcodebuild test -workspace PrebidMobile.xcworkspace -scheme "PrebidDemoSwiftTests" -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.2' | xcpretty -f `xcpretty-travis-formatter` --color --test

# Make the keychain the default so identities are found
security default-keychain -s ios-build.keychain
Expand Down
17 changes: 11 additions & 6 deletions scripts/testPrebidMobile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@ if [ -d "scripts" ]; then
cd scripts/
fi

cd ../src/PrebidMobile/
set -e

cd ..
echo $PWD

gem install xcpretty --user-install
gem install xcpretty-travis-formatter --user-install

gem install cocoapods --user-install
pod install --repo-update

echo "Running unit tests"
xcodebuild test -workspace PrebidMobile.xcworkspace -scheme "PrebidMobileTests" -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.2' | xcpretty -f `xcpretty-travis-formatter` --color --test

gem install xcpretty
gem install xcpretty-travis-formatter
xcodebuild test -project PrebidMobile.xcodeproj -scheme "PrebidMobileTests" -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.2' | xcpretty -f `xcpretty-travis-formatter` --color --test
if [[ ${PIPESTATUS[0]} == 0 ]]; then
echo "✅ Unit Tests Passed"
else
echo "🔴 Unit Tests Failed"
exit 1
fi

cd ../src/PrebidMobile/
echo $PWD
echo "Running swiftlint tests"
swiftlint --config .swiftlint.yml

0 comments on commit 09d6912

Please sign in to comment.