zoukankan      html  css  js  c++  java
  • buildingiphoneappswithhudsonpart2

    I’ve already posted before on how to set up Hudson to compile and build iPhone applications, but I just had a “OMG I <3 Hudson!” moment just now, and felt I had to share it.

    I do most of my mobile development literally while I’m mobile; on the train during my morning commute, from coffee shops on the weekend, or in front of the TV in the evenings when I’m winding down for the night. Because of this, I don’t have any consistent time when I’m making checkins, nor do I have the time to create builds for my beta users.

    One of the iPhone apps I’m building is for a client, and because my time is limited, I want to streamline communication as much as possible, especially since I have a day job that I really like and uses 8 of my precious 24 hours per day. I don’t want to have to tell them every time new features are ready to be tested. Additionally, if I have to manually compile and send a beta build to them whenever I complete a new feature, I’ll never have enough time to actually get any work done. Add to that the fact that many mail servers will block iPhone applications for one reason or another (file size limits, misfiring antivirus filters, or any number of reasons).

    So the solution I’ve come up with is an extension of my iPhone application build scripts combined with some nice plugins for Hudson. All of the above steps are completely automated away and handled for me just by checking my code into git.

    1. The first thing I did was updated my build scripts to generate an “.ipa” archive for Distribution builds containing an iTunesArtwork file, and a “.zip” archive for Release builds.
    2. My build script sets the version number of my application to the $BUILD_NUMBER of my Hudson job, so that the version is guaranteed to be unique.
    3. I added the SCP plugin to Hudson and configured a location on my web server where Hudson could upload completed builds to the website. This enables my clients to access the page to download new releases.
    4. In order to inform my clients that a new build is available, I’ve used thecustomizable email support in Hudson to send an email to a custom list of email addresses when a successful build is completed. In this email I include a link to the uploaded IPA so they can easily download the beta archive.
    5. So that I don’t have to go through the trouble of describing what changes I made, I use the $CHANGES_SINCE_LAST_SUCCESS variable in my custom email template that lists all the commit messages I’d submitted to git that were included in this build.
    6. For good measure, I SCP to the website a copy of the “.mobileprovision” certificate file that was used to build the application, so the beta tester can add it to iTunes if the contents have changed.

    The result of all this work is that I can work wherever I am, continually committing changes into git. When I’m ready to cut a new build, I submit my changes to github where a webhook script will notify Hudson that changes have been made. Hudson checks out my changes, builds them on my Mac Mini at home, SCP’s the resulting archive up to my web server, and notifies my beta testers that a new archive is available and what changes they should keep an eye out for.

    For a copy of the build scripts and configuration I use inside my projects, take a look here:

    CONFIGURATIONS="Distribution Release"
    ProvisionRelease=9807906A-42AF-425E-BD50-80D92E523997.mobileprovision
    ProvisionDistribution=9EB28E74-33F5-4DDA-9E10-A4C9CC7F5294.mobileprovision
    #!/bin/sh
    function failed()
    {
    echo
    "Failed $*: $@" >&2
    exit
    1
    }
    set
    -ex
    git clean
    -dfx
    export OUTPUT
    =$WORKSPACE/output
    rm
    -rf $OUTPUT
    mkdir
    -p $OUTPUT
    PROFILE_HOME
    =~/Library/MobileDevice/Provisioning\ Profiles/
    KEYCHAIN
    =~/Library/Keychains/login.keychain
    .
    "$WORKSPACE/autobuild/build.config"
    [
    -d "$PROFILE_HOME" ] || mkdir -p "$PROFILE_HOME"
    security unlock
    -p `cat ~/.build_password`
    agvtool new
    -version -all $BUILD_NUMBER
    for config in $CONFIGURATIONS; do
    provision
    =$(eval echo \$`echo Provision$config`)
    cert
    ="$WORKSPACE/autobuild/$provision"
    archive
    ="$OUTPUT/$JOB_NAME-$BUILD_NUMBER-$config.zip";
    ipaname
    ="$OUTPUT/$JOB_NAME-$BUILD_NUMBER-$config.ipa"
    provname
    ="$OUTPUT/$JOB_NAME-$BUILD_NUMBER-$config.mobileprovision"
    [
    -f "$cert" ] && cp "$cert" "$PROFILE_HOME"
    xcodebuild
    -activetarget -configuration $config build || failed build;
    (
    cd build
    /$config-iphoneos || failed "no build output";
    if [ "x$config" = "xDistribution" ]; then
    rm
    -rf Payload
    rm
    -f *.ipa
    mkdir Payload
    cp
    -Rp *.app Payload/
    cp
    -f $WORKSPACE/Images/icon-512.png Payload/iTunesArtwork
    zip
    -r $ipaname Payload
    cp
    $cert $provname
    else
    zip
    -r -T -y "$archive" *.app $provision || failed zip;
    fi
    )
    done
    view rawbuild.shThis Gist brought to you by GitHub.

    This assumes there’s a file in the build user’s home directory called “.build_password” that contains the password used to unlock your keychain. Run “chmod 600″ on that file in order to make it hidden to anyone else on your system.  And make sure you check in the “.mobileprovision” files your XCode project file references.  If you change your certificates, you’ll need to copy the updated mobileprovision files from your “Library/MobileDevice/Provisioning Profiles” directory.

    So you can see why I’m excited about this.  I hope you are too.

  • 相关阅读:
    Android外部SD卡的读取
    TableLayout(表格布局)
    Android中Adapter之BaseAdapter使用
    Android中Spinner下拉列表(使用ArrayAdapter和自定义Adapter实现) .
    html5新增及废除属性
    Android Studio运行程序出现Session ‘app’: Error Launching activity 解决办法
    Android的面孔_Actiyity
    初步理解类和对象
    zabbix(2)使用指南
    zabbix(1)基础知识
  • 原文地址:https://www.cnblogs.com/qq78292959/p/2077320.html
Copyright © 2011-2022 走看看