为什么在从命令行创建IPA时,我的构建阶段脚本不会被执行? [英] Why won't my build phase scripts be executed when creating an IPA from command line?

查看:233
本文介绍了为什么在从命令行创建IPA时,我的构建阶段脚本不会被执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题 - 简短版本:



为什么我的构建 >在从命令行创建IPA时执行?
当我运行 xcodebuild 创建IPA时,预定义的构建阶段脚本不会被执行。为什么?






问题 - 冗长版本



我有一个工作区,我想从命令行创建IPA。



这项工作很好,除了一件事情;我在目标的构建阶段有两个脚本,用于放置正确的应用程序版本( CFBundleShortVersionString )和正确的svn修订版本号( CFBundleVersion )。这些脚本在从xcode进行归档时效果很好,但由于某种原因,它们在从命令行归档时不会运行。
首先是为什么?



这里是正在工作的脚本(如果存档形式为xCode)



当从命令行存档和创建IPA时,我会执行(必需)

 #Building 
xcodebuild ARCHS =armv7 armv7sONLY_ACTIVE_ARCH = NO -workspace MyWorkspace.xcworkspace / -scheme MyScheme CONFIGURATION_BUILD_DIR = $ {PROJECT_BUILD_DIR}
$ b#创建IPA
/ usr / bin / xcrun -sdk iphoneos PackageApplication -v$ {PROJECT_BUILD_DIR} / $ {APPLICATION_NAME} .app-o$ {IPA_OUTPUT_PATH} / $ {APPLICATION_NAME} .ipa

它可以工作并创建IPA,但是没有一个构建阶段脚本被执行,版本号和版本号保持不变。



感谢所有建议!



BDASH的回答更新 >

而不是做一个干净的构建我安装为

  xcodebuild安装ARCHS =armv7 armv7sONLY_ACTIVE_ARCH = NO -workspace MyWorkspace.xcworkspace / -scheme MyScheme CONFIGURATION_BUILD_DIR = $ {PROJECT_BUILD_DIR}  - 配置发布

预定义脚本将在FACT中执行(可以在项目版本号中看到),在安装期间没有错误。



在安装应用程序之前,先创建一个大小为〜300字节(而不是〜10MB),但不能安装在设备上。 / p>

 #Building 
xcodebuild clean build ARCHS =armv7 armv7sONLY_ACTIVE_ARCH = NO -workspace MyWorkspace.xcworkspace / -scheme MyScheme CONFIGURATION_BUILD_DIR = $ {PROJECT_BUILD_DIR} - 配置发布
#安装
xcodebuild安装ARCHS =armv7 armv7sONLY_ACTIVE_ARCH = NO -workspace MyWorkspace.xcworkspace / -scheme MyScheme CONFIGURATION_BUILD_DIR = $ {PROJECT_BUILD_DIR} - 配置发布

,然后创建IPA将导致执行版本脚本和正确大小的IPA BUT ,则无法将其安装在设备上。尝试将其放在设备上会显示一条错误消息,指出

您的iPhone设备我的设备上未安装程序MyApp,因为发生未知错误。

解决方案

您至少有一个脚本阶段已选中仅在安装时运行脚本。当使用 build 操作到 xcodebuild 时,不会运行该阶段,只有使用安装操作。


Question - short version:

Why won't my build phase scripts be executed when creating an IPA from the command line? When I'm running xcodebuild to create an IPA the predefined build phase scripts does not get executed. Why is that?


Question - lengthy version:

I have a workspace with a scheme I want to create an IPA out of from command line.

This works fine except for one thing; I have two scripts in the build phases of the target that is used to put the correct app version (CFBundleShortVersionString) and the correct svn revision number (CFBundleVersion). These to scripts works fine when archiving from xcode but for some reason they do not get run when archiving from command line. First of all why is that?

Here are the scripts that are working (if archiving form xCode)

When archiving and creating the IPA from the command line I do (the essentials)

# Building
xcodebuild ARCHS="armv7 armv7s" ONLY_ACTIVE_ARCH=NO -workspace MyWorkspace.xcworkspace/ -scheme MyScheme CONFIGURATION_BUILD_DIR=${PROJECT_BUILD_DIR} -configuration Release clean build

# Creating IPA
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${PROJECT_BUILD_DIR}/${APPLICATION_NAME}.app" -o "${IPA_OUTPUT_PATH}/${APPLICATION_NAME}.ipa"

It works and creates an IPA but none of the build phase scripts gets executed leaving both the revision number and version number untouched.

All suggestions are appreciated!

UPDATE DUE TO BDASH's ANSWER

Instead of making a clean build I make an install as

xcodebuild install ARCHS="armv7 armv7s" ONLY_ACTIVE_ARCH=NO -workspace MyWorkspace.xcworkspace/ -scheme MyScheme CONFIGURATION_BUILD_DIR=${PROJECT_BUILD_DIR} -configuration Release

The predefined script will IN FACT be executed (can be seen in the project version number) with no errors during the install. However the created IPA will have a size of ~300 bytes (instead of ~10MB) and cannot be installed on a device.

Building the app before installing it, i.e.

# Building
xcodebuild clean build ARCHS="armv7 armv7s" ONLY_ACTIVE_ARCH=NO -workspace MyWorkspace.xcworkspace/ -scheme MyScheme CONFIGURATION_BUILD_DIR=${PROJECT_BUILD_DIR} -configuration Release 
# Installing
xcodebuild install ARCHS="armv7 armv7s" ONLY_ACTIVE_ARCH=NO -workspace MyWorkspace.xcworkspace/ -scheme MyScheme CONFIGURATION_BUILD_DIR=${PROJECT_BUILD_DIR} -configuration Release

and then creating the IPA will result in an IPA with executed version script and of correct size BUT it is not possible installing it on a device. Trying to put it on a device will give an error message saying
"The program "MyApp" was not installed on you iPhone device "My Device" because an unknown error has occurred."

解决方案

You have "Run script only when installing" checked for at least one of the script phases. That phase won't be run when using the build action to xcodebuild, only if using the install action.

这篇关于为什么在从命令行创建IPA时,我的构建阶段脚本不会被执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆