Skip to content

Instantly share code, notes, and snippets.

@wangzz
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangzz/7260ba2ffaa2b201a950 to your computer and use it in GitHub Desktop.
Save wangzz/7260ba2ffaa2b201a950 to your computer and use it in GitHub Desktop.
记录有用的脚本
记录有用的脚本
@wangzz
Copy link
Author

wangzz commented Jun 11, 2014

合并真机和模拟器都兼容的framework:

#动态库
# Sets the target folders and the final framework product.
FMK_NAME=${PROJECT_NAME}

# Install dir will be the final output to the framework.
# The following line create it in the root folder of the current project.
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework

# Working dir will be deleted after the framework creation.
WRK_DIR=build
DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework
SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework

# -configuration ${CONFIGURATION} 
# Clean and Building both architectures.
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator clean build

# Cleaning the oldest.
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi

mkdir -p "${INSTALL_DIR}"

cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"

# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"

rm -r "${WRK_DIR}"

@wangzz
Copy link
Author

wangzz commented Jun 11, 2014

合并真机和模拟器都兼容的静态库:

#静态库

# Sets the target folders and the final framework product.
FMK_NAME=${PROJECT_NAME}

# Install dir will be the final output to the framework.
# The following line create it in the root folder of the current project.
INSTALL_DIR=${SRCROOT}/Products

# Working dir will be deleted after the framework creation.
WRK_DIR=build
DEVICE_DIR=${WRK_DIR}/Release-iphoneos
SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator

# Building both architectures.
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator

# Cleaning the oldest.
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi

mkdir -p "${INSTALL_DIR}"

# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/lib${FMK_NAME}.a" "${SIMULATOR_DIR}/lib${FMK_NAME}.a" -output "${INSTALL_DIR}/lib${FMK_NAME}.a"

rm -r "${WRK_DIR}"

@wangzz
Copy link
Author

wangzz commented Jul 17, 2014

编译并生成ipa文件到指定目录:

# target name.
TARGET_NAME="AMapiPhone"

# product dir will be the final output to the ipa.
PRODUCT_DIR=~/Desktop/Products

# final ipa name,for example:"AMapiPhone_20140717_11:58:12.ipa"
IPA_NAME=${TARGET_NAME}_$(date +%Y%m%d_%H:%M:%S).ipa

# go to svn root dir
cd /Users/wangzz/studio/iosapp

# update code
svn up

if [ $? != 0 ]
then
echo "**************SVN UPDATE FAILED**************"
exit 1
fi

# go to .xcodeproj file dir
cd /Users/wangzz/studio/iosapp/apps/AMapiPhone

# clean and building
xcodebuild -configuration "Release" -target "${TARGET_NAME}" -sdk iphoneos CODE_SIGN_IDENTITY="iPhone Developer: weizheng li (P7QJ74LFSA)" PROVISIONING_PROFILE="91F9FF0C-ACFD-4DE5-8A0B-934C77F4437B" clean build

if [ $? != 0 ]
then
echo "**************BUILD FAILED**************"
exit 1
fi

# cleaning the oldest.
if [ -d "${PRODUCT_DIR}" ]
then
rm -rf "${PRODUCT_DIR}"
fi

# create result dir
mkdir -p "${PRODUCT_DIR}"

# build dir will be deleted after the ipa creation.
BUILD_DIR=~+/build/Release-iphoneos

# build result .app file
APP_DIR=${BUILD_DIR}/${TARGET_NAME}.app

echo "**************IPA CREATE BEGIN**************"

# create .ipa file
xcrun -sdk iphoneos PackageApplication -v "$APP_DIR" -o "${PRODUCT_DIR}/${IPA_NAME}"

if [ $? != 0 ]
then
echo "**************IPA CREATE FAILED**************"
exit 1
fi

echo "**************IPA CREATE SUCCESS**************"

# clear build file
rm -r "${BUILD_DIR}"

cd -

@wangzz
Copy link
Author

wangzz commented Aug 8, 2014

提交博客

cd /Users/wangzz/octopress

bundle exec rake generate

if [ $? != 0 ]
then
echo "**************RAKE GENERATE FAILED**************"
exit 1
fi

git add --all .

git commit -m $1

git push origin source

bundle exec rake deploy

if [ $? != 0 ]
then
echo "**************RAKE DEPLOY FAILED**************"
exit 1
fi

echo "**************BLOG DEPLOY SUCCESS**************"

#添加 gitcafe 源
cd /Users/wangzz/octopress/_deploy

git remote add gitcafe git@gitcafe.com:wangzz/wangzz.git >> /dev/null 2>&1

#提交博客内容
echo "### Pushing to GitCafe..."
git push -u gitcafe master:gitcafe-pages
echo "### Done"

cd -

  • 示例
$ ./deploy "MOD:完善iOS屏幕旋转学习笔记"

@wangzz
Copy link
Author

wangzz commented Aug 15, 2014

同样可以使用xctool编译、生成ipa包

  • 安装xctool
$ brew install xctool
  • 执行脚本

切换到工程根目录下

#  build.sh
#  SOSOMap
#
#  Created by wangzz on 14-8-15.
#  Copyright (c) 2014年 wangzz. All rights reserved.

BUILD_DIR=/Users/wangzz/Desktop/tmp/build

PRODUCT_DIR=/Users/wangzz/Desktop/tmp/product

SCHEME_NAME=SOSOMap

APP_DIR=${BUILD_DIR}/${SCHEME_NAME}.app

rm -rf BUILD_DIR

rm -rf PRODUCT_DIR

xctool -scheme $SCHEME_NAME -arch armv7 TARGET_BUILD_DIR="$BUILD_DIR" -sdk iphoneos CODE_SIGN_IDENTITY="iPhone Developer: weizheng li (P7QJ74LFSA)" PROVISIONING_PROFILE="91F9FF0C-ACFD-4DE5-8A0B-934C77F4437B" clean build

# create .ipa file
xcrun -sdk iphoneos PackageApplication -v "$APP_DIR" -o "${PRODUCT_DIR}/${SCHEME_NAME}.ipa"

if [ $? != 0 ]
then
echo "**************IPA CREATE FAILED**************"
exit 1
fi

echo "**************IPA CREATE SUCCESS**************"


#xcodebuild -target SOSOMap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment