当前位置:  开发笔记 > 运维 > 正文

使用带代码签名的命令行创建ipa文件

如何解决《使用带代码签名的命令行创建ipa文件》经验,为你挑选了1个好方法。

我正在尝试使用xcode命令行创建一个ipa文件,包括签名.我试着搜索它,我得到了用代码签名创建ipa的命令.

我需要命令主要与hudson CI集成.

请建议.

-Prahasa



1> jr...:

这是我用来与Hudson和我的iPhone应用程序集成的脚本.

#!/bin/sh

CONFIGURATION="AdHoc" # or Release or Debug

# location of files included in dist (.mobileprovision, iTunesArtwork, README)
DISTDIR="_distfiles"

. build.config

MARKETING_VERSION=`agvtool what-marketing-version -terse1`

build_xcode ()
    {
    xcodebuild -configuration "$CONFIGURATION" -sdk $SDK
}

# CONFIGURATION for xcode build can be overridden from commandline
NEWCONFIG="$1"
if ! test "$NEWCONFIG"x = x; then
    echo "=== using configuration from command line $NEWCONFIG"
    CONFIGURATION="$NEWCONFIG"
fi

# XCODE check build available for specified configuration
CHECKCONFIGURATION=`xcodebuild -list | egrep "$CONFIGURATION($|\ )"`
if test "$CHECKCONFIGURATION"x = x; then
    echo "ERROR: xcodebuild could not find valid build configuration $CONFIGURATION"
    echo
    xcodebuild -list
    echo
    exit
fi

VERSION="$MARKETING_VERSION ($BUILD_NUMBER)"
#######
echo "=== Building distribution package for $RELEASE - $VERSION"
echo "=== setting build number to $BUILD_NUMBER"
agvtool new-version -all "${BUILD_NUMBER}"

# XCODE make sure buildpath exists for configuration, build if missing
BUILDPATH="build/$CONFIGURATION-iphoneos"
build_xcode 
if [ $? != 0 ]; then
    echo "ERROR: xcodebuild not successful"
    exit 1
fi
if test ! -d "$BUILDPATH"; then
    echo "ERROR: xcodebuild could not build configuration $CONGIRUATION ($BUILDPATH)"
exit
fi
echo "=== Successfully built configuration $CONFIGURATION ($BUILDPATH)"

# HACK : accomodate configurations with spaces, chdir to determine app name
cd "$BUILDPATH"
# derive name of .app dir (application)
APPDIR=`ls -d *.app`
cd ../..

APPPATH="$BUILDPATH/$APPDIR"
DSYMPATH="$BUILDPATH/$APPDIR.dSYM"
if test "$APPDIR"x = x; then
    APPPATH="$BUILDPATH/.app"
fi


# XCODE make sure app dir exists in buildpath, build if missing
if test ! -d "$APPPATH"; then

    echo "missing $APPPATH build in $BUILDPATH, trying to build"
    build_xcode

    # HACK : accomodate configurations with spaces, chdir to determine app name
    cd "$BUILDPATH"
    # derive name of .app dir (application)
    APPDIR=`ls -d *.app`
    cd ../..

    # check again for APPDIR/APPPATH
    APPPATH="$BUILDPATH/$APPDIR"
    if test "$APPDIR"x = x; then
        APPPATH="$BUILDPATH/.app"
    fi

    if test ! -d "$APPPATH"; then
        echo "ERROR: xcodebuild could not build $APPPATH configuration $CONGIRUATION ($BUILDPATH)"
        exit
    fi
    echo "=== Successfully built $APPDIR configuration $CONFIGURATION ($BUILDPATH)"
fi

# Create directory for release package
echo " -  Creating release dir"
RELEASEDIR="$RELEASEBASE/$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
mkdir -p "$RELEASEDIR"

echo "RELEASEDIR = $RELEASEDIR"
echo "BUILDPATH = $BUILDPATH"
echo "APPPATH = $APPPATH"
echo "DSYMPATH = $APPPATH"

# Copy other files
cp $DISTDIR/* "$RELEASEDIR"

# .IPA file: iphone app archive file, installable by itunes
IPA=`echo $APPDIR | sed "s/\.app/\.ipa/"`
echo " -  Creating $IPA payload"
mkdir -p "$RELEASEDIR/Payload/"
echo " - Copying $APPPATH to $RELEASEDIR/Payload/"
# Copy built .app to payload/ itunes-specific install dir
cp -Rp "$APPPATH" "$RELEASEDIR/Payload/"

# Build .IPA file
#   this is just a zipfile with a payload/ dir with the .app, and artwork
cd "$RELEASEDIR"
# include 512x512 png of artwork, if foudn
if test -f "iTunesArtwork"; then
    zip -y -r "$IPA" iTunesArtwork Payload/
    rm -rf Payload iTunesArtwork
else 
    zip -y -r "$IPA" Payload/
    rm -rf Payload 
fi

cd ..
pwd
# Create .zip packaged Distribution
ZIPFILE="$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER.zip"
DSYMZIPFILE="$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER-dSYM.zip"
echo " -  zipfile is $ZIPFILE"
echo " -  Compressing release $ZIPFILE"
zip -y -r "$ZIPFILE" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
cp -pR "../$DSYMPATH" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
echo " - creating zip of dSYM file"
zip -y -r "$DSYMZIPFILE" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER/$APPDIR.dSYM"
cd ..

echo "=== Build complete for $RELEASEBASE/$ZIPFILE"

然后,我的hudson配置如下所示:

./build.sh AdHoc
./build.sh Release

最后,我要归档的文件如下所示:

_release/MobilePracticePro-*-${BUILD_NUMBER}*.zip

希望这对你有所帮助!使用Hudson非常棒.此外,实现您的签名密钥需要安装在与hudson运行相同的框中并以同一用户身份运行.至少这对我来说是这样的.

推荐阅读
可爱的天使keven_464
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有