Quantcast
Channel: How to build a Kony iOS Project using commandline - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Oliver Metz for How to build a Kony iOS Project using commandline

$
0
0

EDIT START

As of Kony 7 there is a better way to do headless builds:

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

Basically use the HeadlessBuild.properties to configure your build and launch it with ant. It's a struggle in the beginning but we got a successful build of android and iOS via Jenkins.

Note: Building multiple projects at the same time does not seem to work (e.g. for multiple build types) and results in an error message. You'll have to build sequentially.

Comment if you're interested in the further build process and I'll consider writing a blog post about this :)

EDIT END

Finished a first version of a shell script to build a Kony Project for Android and iOS for Jenkins. Its far from elegant or perferct but it might be a good start for anyone who stumbles accross this post.

First I created a settings script which contains the configuration of my build (all values-to-be-entered are shown as <value> tags):

#!/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############################################################# Executesh ./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

I then have the actual script which does the build job as descripted at the top of the first script. Here we also do the Magic which Sam posted.

#!/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 functionsfunction 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 Settingsecho "##### Executing Jenkins Kony Build #####"echo "#     Android Phone = " $_target_android_phoneecho "#     Android Tablet = " $_target_android_tabletecho "#     iOS Phone = " $_target_ios_phoneecho "#     iOS Tablet = " $_target_ios_tabletecho "##### Executing Jenkins Kony Build #####"echo ''######################## Clean echo "# cleaning up"rm -rf binariesrm -rf jssrc######################## Inject properties echo "# injecting properties"change_line "^android=""android=$_target_android_phone" build.propertieschange_line "^androidtablet=""androidtablet=$_target_android_tablet" build.propertieschange_line "^iphone=""iphone=$_target_ios_phone" build.propertieschange_line "^ipad=""ipad=$_target_ios_tablet" build.propertieschange_line "^android.home=""android.home=$_android_home" global.propertieschange_line "^eclipse.equinox.path=""eclipse.equinox.path=$_eclipse_equinox" global.propertieschange_line "^httpport=""httpport=$_middleware_httpport" middleware.propertieschange_line "^httpsport=""httpsport=$_middleware_httpsport" middleware.propertieschange_line "^ipaddress=""ipaddress=$_middleware_ipaddress" middleware.properties######################## Execute Main Build - Antecho "## Execute Kony Ant Build - Start ##"export PATH=$PATH:${_ant_bin_dir}ant -file build.xmlecho "## Execute Kony Ant Build - Done ##"echo ''######################## Android app signingif [ ${_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 iphoneif [ ${_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 ipadif [ ${_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 ''fiecho "## Copy Binaries to ./deploys/ ##"cd ..mkdir deployscp VMAppWithKonylibipad/build/KonyiOSApp.ipa deploys/app-release-ipad.ipacp VMAppWithKonylibiphone/build/KonyiOSApp.ipa deploys/app-release-iphone.ipacp ${_project_name}/binaries/android/luavmandroid-signed.apk deploys/app-release-android.apkecho ''echo ''echo "## JENKINS BUILD SUCCESS ##"echo ''

In the jenkins configuration I now only call the first script by executing a shell script:

cd KonyTemplatesh ./jenkins_build.sh

If anyone has any suggestions to improve this little script (and there most definitely are plenty), I'm sure we'll all be happy to hear them.


Viewing all articles
Browse latest Browse all 3

Trending Articles