Created
February 12, 2014 06:50
-
-
Save jcayzac/8951047 to your computer and use it in GitHub Desktop.
Overwrite platform/ios/cordova/build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P) | |
PROJECT_PATH="$(dirname "$CORDOVA_PATH")" | |
XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj ) | |
PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj) | |
source "$CORDOVA_PATH/check_reqs" | |
cd "$PROJECT_PATH" | |
APP=build/$PROJECT_NAME.app | |
FLAG=${1:---debug} | |
OTHER_FLAGS=$2 | |
CONFIGURATION=Debug | |
if [ "$FLAG" == "--release" ]; then | |
CONFIGURATION=Release | |
fi | |
if [ "$OTHER_FLAGS" != "" ]; then | |
echo "More than one flag provided, specify either --debug or --release only" | |
exit 2 | |
fi | |
"$CORDOVA_PATH/clean" | |
# Install/update cocoapods | |
if [ -f Podfile.lock ] | |
then | |
pod update | |
elif [ -f Podfile ] | |
then | |
pod install | |
fi | |
# If no scheme exists yet for the app, create one | |
if [ ! -f "${PROJECT_NAME}.xcodeproj/xcshareddata/xcschemes/${PROJECT_NAME}.xcscheme" ] | |
then | |
ROOT_OBJ="$(/usr/libexec/PlistBuddy -c "Print:rootObject" "${PROJECT_NAME}.xcodeproj/project.pbxproj")" | |
TARGET_ID="$(/usr/libexec/PlistBuddy -c "Print:objects:${ROOT_OBJ}:targets:0" "${PROJECT_NAME}.xcodeproj/project.pbxproj")" | |
mkdir -p "${PROJECT_NAME}.xcodeproj/xcshareddata/xcschemes" | |
cat >"${PROJECT_NAME}.xcodeproj/xcshareddata/xcschemes/${PROJECT_NAME}.xcscheme" <<EOT | |
<?xml version="1.0" encoding="UTF-8"?> | |
<Scheme | |
LastUpgradeVersion = "0500" | |
version = "1.3"> | |
<BuildAction | |
parallelizeBuildables = "YES" | |
buildImplicitDependencies = "YES"> | |
<BuildActionEntries> | |
<BuildActionEntry | |
buildForTesting = "YES" | |
buildForRunning = "YES" | |
buildForProfiling = "YES" | |
buildForArchiving = "YES" | |
buildForAnalyzing = "YES"> | |
<BuildableReference | |
BuildableIdentifier = "primary" | |
BlueprintIdentifier = "${TARGET_ID}" | |
BuildableName = "${PROJECT_NAME}.app" | |
BlueprintName = "${PROJECT_NAME}" | |
ReferencedContainer = "container:${PROJECT_NAME}.xcodeproj"> | |
</BuildableReference> | |
</BuildActionEntry> | |
</BuildActionEntries> | |
</BuildAction> | |
<TestAction | |
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | |
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | |
shouldUseLaunchSchemeArgsEnv = "YES" | |
buildConfiguration = "Debug"> | |
<Testables> | |
</Testables> | |
<MacroExpansion> | |
<BuildableReference | |
BuildableIdentifier = "primary" | |
BlueprintIdentifier = "${TARGET_ID}" | |
BuildableName = "${PROJECT_NAME}.app" | |
BlueprintName = "${PROJECT_NAME}" | |
ReferencedContainer = "container:${PROJECT_NAME}.xcodeproj"> | |
</BuildableReference> | |
</MacroExpansion> | |
</TestAction> | |
<LaunchAction | |
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | |
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | |
launchStyle = "0" | |
useCustomWorkingDirectory = "NO" | |
buildConfiguration = "Debug" | |
ignoresPersistentStateOnLaunch = "NO" | |
debugDocumentVersioning = "YES" | |
allowLocationSimulation = "YES"> | |
<BuildableProductRunnable> | |
<BuildableReference | |
BuildableIdentifier = "primary" | |
BlueprintIdentifier = "${TARGET_ID}" | |
BuildableName = "${PROJECT_NAME}.app" | |
BlueprintName = "${PROJECT_NAME}" | |
ReferencedContainer = "container:${PROJECT_NAME}.xcodeproj"> | |
</BuildableReference> | |
</BuildableProductRunnable> | |
<AdditionalOptions> | |
</AdditionalOptions> | |
</LaunchAction> | |
<ProfileAction | |
shouldUseLaunchSchemeArgsEnv = "YES" | |
savedToolIdentifier = "" | |
useCustomWorkingDirectory = "NO" | |
buildConfiguration = "Release" | |
debugDocumentVersioning = "YES"> | |
<BuildableProductRunnable> | |
<BuildableReference | |
BuildableIdentifier = "primary" | |
BlueprintIdentifier = "${TARGET_ID}" | |
BuildableName = "${PROJECT_NAME}.app" | |
BlueprintName = "${PROJECT_NAME}" | |
ReferencedContainer = "container:${PROJECT_NAME}.xcodeproj"> | |
</BuildableReference> | |
</BuildableProductRunnable> | |
</ProfileAction> | |
<AnalyzeAction | |
buildConfiguration = "Debug"> | |
</AnalyzeAction> | |
<ArchiveAction | |
buildConfiguration = "Release" | |
revealArchiveInOrganizer = "YES"> | |
</ArchiveAction> | |
</Scheme> | |
EOT | |
fi | |
# Build workspace | |
xcodebuild -xcconfig "$CORDOVA_PATH/build.xcconfig" -workspace "$PROJECT_NAME.xcworkspace" ARCHS="armv7 armv7s" -scheme "$PROJECT_NAME" -configuration $CONFIGURATION -sdk iphoneos build VALID_ARCHS="armv7 armv7s" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build/device" | |
xcodebuild -workspace "$PROJECT_NAME.xcworkspace" -arch i386 -scheme "$PROJECT_NAME" -configuration $CONFIGURATION -sdk iphonesimulator build VALID_ARCHS="i386" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build/emulator" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment