【问题标题】:How to build a Kony iOS Project using commandline如何使用命令行构建 Kony iOS 项目
【发布时间】:2015-02-19 14:29:33
【问题描述】:

我的目标是为 Jenkins CI 构建一个 Kony 项目。所以基本上我需要知道如何在 unix 命令行上构建项目。使用 Kony Studio 时,我的项目构建没有问题。

我已经设法在项目目录中的build.xml 上使用ant 构建了一个android .apk。这也为 ios 构建了一个 .kar 文件。 我现在如何使用命令行通过 xcode 触发 ipa 构建

环境:Mac OSX 10.10.2 和 Kony Studio 6.0。

【问题讨论】:

  • 要从命令行构建iOS应用,你可以使用xcodebuild

标签: android ios ant jenkins temenos-quantum


【解决方案1】:

您需要复制“com.kony.ios_5.5.x.jar”文件并重命名为“com.kony.ios_5.5.x.zip强>”。

    Unzip the "com.kony.ios_5.5.x.zip",
    The unzipped folder contains 5 files, one of it is "**iOS-GA-5.5.x.zip**".
    Make sure that you DO NOT delete any of these 5 files.

    Unzip the "iOS-GA-5.5.x.zip" , it will give you the "VMAppWithKonylib" folder.

    Now, close all the xcodes you might have open.

    Then delete data at path Users/(UserName)/Library/Developer/Xcode/DerivedData

    Now go to Terminal

    Navigates upto Gen folder using cd (e.g. cd /Users/foo/Desktop/VMAppWithKonylib/gen)

    Type pearl extract.pl <KAR file path> and launch the Xcode and do a build. (e.g. perl extract.pl /Users/foo/Downloads/konyappiphone-193.kAR)

Now type open <xcodeproj path>. (e.g. open /Users/foo/Desktop/VMAppWithKonylib/VMAppWithKonylib.xcodeproj)

现在应用程序将在 xcode 中运行。存档并继续生成 IPA。

【讨论】:

    【解决方案2】:

    编辑开始

    从 Kony 7 开始,有一种更好的方法来进行无头构建:

    http://docs.kony.com/konylibrary/visualizer/visualizer_user_guide/Content/CommandLine.htm

    基本上使用 HeadlessBuild.properties 来配置您的构建并使用 ant 启动它。一开始很困难,但我们通过 Jenkins 成功构建了 android 和 iOS。

    注意:同时构建多个项目似乎不起作用(例如,对于多种构建类型)并导致错误消息。您必须按顺序构建。

    如果您对进一步的构建过程感兴趣,请发表评论,我会考虑写一篇关于此的博客文章 :)

    编辑结束

    完成了第一个版本的 shell 脚本,用于为 Jenkins 构建适用于 Android 和 iOS 的 Kony 项目。 它远非优雅或完美,但对于任何偶然发现这篇文章的人来说,这可能是一个好的开始。

    首先我创建了一个包含我的构建配置的设置脚本(所有要输入的值都显示为&lt;value&gt;标签):

    #!/bin/bash
    
    # This script builds a Kony Project with following steps
    # 1.  Inject settings into global.properties, build.properties, middleware properties
    # 2.  Build Project by executing ant build.xml 
    # 2.1 When building android apps these are already packed as .apk
    # 2.2 APK is signed 
    # 3.  If iOS app is build the iOS dumyWorkspace (VMAppWithKonylib) is unzipped and filled with KAR file from ant build
    # 3.1 the iOS app is archived 
    # 3.2 this iOS app is signed and exported as ipa
    # 4.  all APK and IPA files are copied to deploys folder.
    
    # Note: The Directory the Kony Project is inside must be the name of the Kony Project. otherwise it will not build. This means, that if you clone your project from repository you'll have to put it into a folder or already have it checkedin as a folder.
    
    _project_name=<Kony Application Project name. e.g. KonyTemplate>
    
    # Targets
    _target_android_phone=true
    _target_android_tablet=false
    _target_ios_phone=true
    _target_ios_tablet=false
    
    # Middleware Config
    _middleware_ipaddress=127.0.0.1
    _middleware_httpport=8080
    _middleware_httpsport=443
    
    # tools
    _android_home=<android sdk home>
    _android_zipalign=<zipalign in android build-tools>
    _eclipse_equinox=<eclipse equinox jar in kony studio. e.g. /Users/userxyz/Kony_Studio/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
    _ant_bin_dir=<ant binary directory e.g. /usr/local/bin>
    
    # you will need this parameter if you build an ios project. It is the You can retrieve it like this:
    # - search for file "com.kony.ios_x.x.x.GA_vxxxxxxxxxxxx.jar" in Kony_Studio/plugins/ Folder
    # - copy it to another folder and rename it as .zip
    # - unzip 
    # - retrieve file "iOS-GA-x.x.x.zip" and copy it to destination referenced in _ios_dummy_project_zip variable
    _ios_dummy_project_zip=<location of kony ios workspaced (zipeed). e.g. /Applications/Kony/Kony_Studio/iOS-GA-6.0.2.zip>
    
    # OS Code Signing
    _ios_code_sign_identity='<code sign identity>'
    _ios_provisioning_profile_uuid='<xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>'
    _ios_provisioning_profile_name='<provisioning profile name'
    
    # Android signing
    _android_storepass=<keystore password>
    _android_keyalias=<keystore alias>
    _android_keypass=<key password>
    _android_keystore=<keystore file within kony project directory. e.g. keystore.jks>
    
    # Settings End
    ############################################################
    
    # Execute
    sh ./jenkins_build_internal.sh $_project_name $_target_android_phone $_target_android_tablet $_target_ios_phone $_target_ios_tablet $_middleware_ipaddress $_middleware_httpport $_middleware_httpsport $_removeprintstatements $_build $_android_home $_eclipse_equinox $_ant_bin_dir $_ios_dummy_project_zip "$_ios_code_sign_identity" "$_ios_provisioning_profile_uuid" "$_ios_provisioning_profile_name" $_android_zipalign $_android_storepass $_android_keyalias $_android_keypass $_android_keystore
    

    然后,我得到了执行第一个脚本顶部所描述的构建工作的实际脚本。在这里,我们还做了 Sam 发布的魔术。

    #!/bin/bash
    
    ####################
    # Settings
    
    _project_name=$1
    
    # Targets
    _target_android_phone=$2
    _target_android_tablet=$3
    _target_ios_phone=$4
    _target_ios_tablet=$5
    
    # Middleware Config
    _middleware_ipaddress=$6
    _middleware_httpport=$7
    _middleware_httpsport=$8
    
    # Build confif
    _removeprintstatements=$9
    _build=${10}
    
    # Build tools Config
    _android_home=${11}
    _eclipse_equinox=${12}
    _ant_bin_dir=${13}
    _ios_dummy_project_zip=${14}
    
    # OS Code Signing
    _ios_code_sign_identity=${15}
    _ios_provisioning_profile_uuid=${16}
    _ios_provisioning_profile_name=${17}
    
    # Android signing
    _android_zipalign=${18}
    _android_storepass=${19}
    _android_keyalias=${20}
    _android_keypass=${21}
    _android_keystore=${22}
    
    
    
    _sleep_while_xcode_startup=15
    
    
    #######################
    # Define functions
    
    
    function escape_slashes {
        sed 's/\//\\\//g' 
    }
    
    function change_line {
        local OLD_LINE_PATTERN=$1; shift
        local NEW_LINE=$1; shift
        local FILE=$1
    
        local NEW=$(echo "${NEW_LINE}" | escape_slashes)
        sed -i .bak '/'"${OLD_LINE_PATTERN}"'/s/.*/'"${NEW}"'/' "${FILE}"
        mv "${FILE}.bak" /tmp/
    }
    
    
    #######################
    # Dump Settings
    echo "##### Executing Jenkins Kony Build #####"
    echo "#     Android Phone = " $_target_android_phone
    echo "#     Android Tablet = " $_target_android_tablet
    echo "#     iOS Phone = " $_target_ios_phone
    echo "#     iOS Tablet = " $_target_ios_tablet
    echo "##### Executing Jenkins Kony Build #####"
    echo ''
    
    #######################
    # Clean 
    
    echo "# cleaning up"
    rm -rf binaries
    rm -rf jssrc
    
    #######################
    # Inject properties 
    echo "# injecting properties"
    
    change_line "^android=" "android=$_target_android_phone" build.properties
    change_line "^androidtablet=" "androidtablet=$_target_android_tablet" build.properties
    change_line "^iphone=" "iphone=$_target_ios_phone" build.properties
    change_line "^ipad=" "ipad=$_target_ios_tablet" build.properties
    
    change_line "^android.home=" "android.home=$_android_home" global.properties
    change_line "^eclipse.equinox.path=" "eclipse.equinox.path=$_eclipse_equinox" global.properties
    
    change_line "^httpport=" "httpport=$_middleware_httpport" middleware.properties
    change_line "^httpsport=" "httpsport=$_middleware_httpsport" middleware.properties
    change_line "^ipaddress=" "ipaddress=$_middleware_ipaddress" middleware.properties
    
    
    #######################
    # Execute Main Build - Ant
    
    echo "## Execute Kony Ant Build - Start ##"
    export PATH=$PATH:${_ant_bin_dir}
    ant -file build.xml
    echo "## Execute Kony Ant Build - Done ##"
    echo ''
    
    #######################
    # Android app signing
    
    if [ ${_target_android_phone} == "true" -o  ${_target_android_tablet} == "true" ]
        then
        set +x
        echo "## Execute Android signing APK - Start ##"
        cd binaries/android
    
        jarsigner -storepass "${_android_storepass}" -keypass "${_android_keypass}" -keystore ../../${_android_keystore} luavmandroid.apk ${_android_keyalias} -signedjar luavmandroid-signed_unaligned.apk
        ${_android_zipalign} -v 4 luavmandroid-signed_unaligned.apk luavmandroid-signed.apk
        cd -
        echo "## Execute Android signing APK - Done ##"
        echo ''
    fi
    
    
    #######################
    # Check and execute optional ios Workspace build for iphone
    if [ ${_target_ios_phone} == "true" ]
        then
        echo "## Execute Kony iOS Workspace creation - Start ##"
        cd ..
        echo "# unzipping workspace #"
        rm -rf VMAppWithKonylibiphone
        unzip $_ios_dummy_project_zip -d .
        mv VMAppWithKonylib VMAppWithKonylibiphone
        cd VMAppWithKonylibiphone
        cd gen
    
        echo "# filling workspace #"
        perl extract.pl ../../webapps/KonyTemplater/kbf/konyappiphone.KAR
        # back to ios Workspace
        cd ..
        echo "## Execute Kony iOS iPhone Workspace creation - Done ##"
    
        # dirty piece of code to create the scheme files... open xcode and close it again :)
        echo "# opening project to generate scheme"
        open VMAppWithKonylib.xcodeproj
        sleep ${_sleep_while_xcode_startup}
        echo "# close project"
        osascript -e 'quit app "Xcode"'
    
        echo "## Execute Kony iOS Archive - Start ##"
        # create signed archive
        xcodebuild -scheme KRelease -archivePath build/Archive.xcarchive archive PROVISIONING_PROFILE="${_ios_provisioning_profile_uuid}" CODE_SIGN_IDENTITY="${_ios_code_sign_identity}"
        echo "## Execute Kony iOS Archive - Done ##"
    
        echo "## Execute Kony iOS IPA Generation - Start ##"
        # create ipa
        xcodebuild -exportArchive -exportFormat IPA -archivePath build/Archive.xcarchive -exportPath build/KonyiOSApp.ipa -exportProvisioningProfile "${_ios_provisioning_profile_name}"
        echo "## Execute Kony iOS IPA Generation - Done ##"
        echo ''
    fi
    
    #######################
    # Check and execute optional ios Workspace build for ipad
    if [ ${_target_ios_tablet} == "true" ]
        then
        echo "## Execute Kony iOS Workspace creation - Start ##"
        cd ..
        echo "# unzipping workspace #"
        rm -rf VMAppWithKonylibipad
        unzip $_ios_dummy_project_zip -d .
        mv VMAppWithKonylib VMAppWithKonylibipad
        cd VMAppWithKonylibipad
        cd gen
    
        echo "# filling workspace #"
        perl extract.pl ../../webapps/KonyTemplater/kbf/konyappipad.KAR
        # back to ios Workspace
        cd ..
        echo "## Execute Kony iOS iPhone Workspace creation - Done ##"
    
        echo "# opening project to generate scheme"
        open VMAppWithKonylib.xcodeproj
        sleep ${_sleep_while_xcode_startup}
        echo "# close project"
        osascript -e 'quit app "Xcode"'
    
        echo "## Execute Kony iOS Archive - Start ##"
        # create signed archive
        xcodebuild -scheme KRelease -archivePath build/Archive.xcarchive archive PROVISIONING_PROFILE="${_ios_provisioning_profile_uuid}" CODE_SIGN_IDENTITY="${_ios_code_sign_identity}"
        echo "## Execute Kony iOS Archive - Done ##"
    
        echo "## Execute Kony iOS IPA Generation - Start ##"
        # create ipa
        xcodebuild -exportArchive -exportFormat IPA -archivePath build/Archive.xcarchive -exportPath build/KonyiOSApp.ipa -exportProvisioningProfile "${_ios_provisioning_profile_name}"
        echo "## Execute Kony iOS IPA Generation - Done ##"
        echo ''
    fi
    
    echo "## Copy Binaries to ./deploys/ ##"
    cd ..
    mkdir deploys
    cp VMAppWithKonylibipad/build/KonyiOSApp.ipa deploys/app-release-ipad.ipa
    cp VMAppWithKonylibiphone/build/KonyiOSApp.ipa deploys/app-release-iphone.ipa
    cp ${_project_name}/binaries/android/luavmandroid-signed.apk deploys/app-release-android.apk
    echo ''
    
    echo ''
    echo "## JENKINS BUILD SUCCESS ##"
    echo ''
    

    在 jenkins 配置中,我现在只通过执行 shell 脚本来调用第一个脚本:

    cd KonyTemplate
    sh ./jenkins_build.sh
    

    如果有人对改进这个小脚本有任何建议(而且肯定有很多),我相信我们都会很高兴听到这些建议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-06
      • 2018-01-22
      • 1970-01-01
      • 1970-01-01
      • 2017-01-20
      • 1970-01-01
      • 2019-11-25
      • 1970-01-01
      相关资源
      最近更新 更多