如果你的項目用到cocopod 第三方庫。使用xcodebulid 估計會出現
ld: library not found for -lPods
以下 是我的解決辦法
xcodebuild -workspace 項目根目錄/項目名.xcworkspace \
-scheme 項目名 \
ONLY_ACTIVE_ARCH=NO \
TARGETED_DEVICE_FAMILY=1 \
DEPLOYMENT_LOCATION=YES
重新運行命令。哈。成功了。
以下是我找到的解決方案
http://railsware.com/blog/2013/09/12/ios-integration-tests-with-appium/
http://testerhome.com/topics/151
上面問題解決了。
運行命令 bulid 成功提示 可是 release 的app 卻在~/Library/Developer/ugly_path/ 。。
如果能指定路徑就好了
http://stackoverflow.com/questions/4233581/xcode-4-build-output-directory
http://blog.csdn.net/zb12345678/article/details/17607037
哈解決。。命令后添加參數
CONFIGURATION_BUILD_DIR ='指定路徑',當前用戶要有權限。如沒有可以修改權限chomd 777 '指定路徑'
如果每次都要自己輸入命令 來打包 太麻煩了。何不把命令寫成shell 用到時 拖到終端執行下 就ok 。豈不美哉
xcode 新建。shell 文件
#!/bin/sh # ipa-build.sh # 使用 # 把該文保存 ,修改權限chmod +x 你的shell文件名 # 把文件拖到 終端 。 # 參數
# 1,你要打包工程的根目錄 2,你要輸出的ipa文件目錄(你當前用戶要有權限) 3,指定的ipa 文件名 參數用空格隔開
# eg:~
# ~/Desktop/ipa-build.sh ~/Documents/workSpace/project ~/Desktop/project projectName
#!/bin/bash #參數判斷 if [ $# != 3 ] && [ $# != 2 ]&& [ $# != 1 ];then echo "Number of params error! Need three params!" echo "1.path of project(necessary) 2.path of ipa dictionary(necessary) 3.name of ipa file(necessary)" exit elif [ ! -d $1 ];then echo "Params Error!! The 1 param must be a project root dictionary." exit elif [ ! -d $2 ];then echo "Params Error!! The 2 param must be a ipa dictionary." exit fi #工程絕對路徑 cd $1 project_path=$(pwd) #build文件夾路徑 build_path=${project_path}/build #工程配置文件路徑 project_name=$(ls | grep xcodeproj | awk -F.xcodeproj '{print $1}') project_infoplist_path=${project_path}/${project_name}/${project_name}-Info.plist #取版本號 bundleShortVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" ${project_infoplist_path}) #取build值 bundleVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleVersion" ${project_infoplist_path}) #取bundle Identifier前綴 bundlePrefix=$(/usr/libexec/PlistBuddy -c "print CFBundleIdentifier" `find . -name "*-Info.plist"` | awk -F$ '{print $1}') cd $project_path #清理工程 xcodebuild clean || exit #刪除bulid目錄 if [ -d ${build_path} ];then rm -rf ${build_path} fi #編譯工程 xcodebuild -configuration Release -workspace ${project_path}/${project_name}.xcworkspace \ -scheme ${project_name} \ ONLY_ACTIVE_ARCH=NO \ TARGETED_DEVICE_FAMILY=1 \ DEPLOYMENT_LOCATION=YES CONFIGURATION_BUILD_DIR=${project_path}/build/Release-iphoneos || exit #IPA名稱 if [ $# = 3 ]; then ipa_name=$3 fi if [ -d ./ipa-build ];then rm -rf ipa-build fi #打包 cd $build_path mkdir -p ipa-build/Payload cp -r ./Release-iphoneos/*.app ./ipa-build/Payload/ cd ipa-build zip -r ${ipa_name}.ipa * cp -r ./${ipa_name}.ipa $2 rm -rf Payload #刪除bulid目錄 if [ -d ${build_path} ];then rm -rf ${build_path} fi
受以下文章啟發
http://webfrogs.me/2012/09/19/buildipa/
有關xcodebulid
http://www.cnblogs.com/xiaodao/archive/2012/03/01/2375609.html