Monday, September 30, 2013

Read values of properties from plist through AppleScript !

#Read Bundle Version from info.plist through AppleScript !



set the plistfile_path to "/Users/................/AppName-Info.plist"

tell application "System Events"
set p_list to property list file (plistfile_path)
set releaseVersion to value of property list item "CFBundleVersion" of p_list
end tell

Get log file from latest folder through AppleScript !

#This AppleScript is for get latest log file generated during automatic build server.

set sourceFolder to "Users:....:.....:targetFolder"

property the_path : "/Users/..../.../targetFolder"
set theFolder to (POSIX file the_pathas alias

tell application "Finder"
set itemGroup to sort (get every folder of theFolderby creation date
set LatestFolder to (get first item of itemGroup)
set LatestFolderName to LatestFolder's name
end tell

set latestFilePath to "/Users/..../..../targetFolder/" & LatestFolderName & "/log"


#This AppleScript is for get latest folder and it's name.


set sourceFolder to "Users:....:.....:targetFolder"

property the_path : "/Users/..../.../targetFolder"
set theFolder to (POSIX file the_pathas alias

tell application "Finder"
set itemGroup to sort (get every folder of theFolderby creation date
set LatestFolder to (get first item of itemGroup)
set LatestFolderName to LatestFolder's name
end tell


Create ipa and plist file and upload files on server for Enterprise Application through Terminal !

cd "Applications path"

#Compile the build

xcodebuild -target AppTargetName -sdk iphoneos -configuration Release

#Archive the build

/usr/bin/xcrun -sdk iphoneos PackageApplication -v $applicationPath -o $ipaPath --sign Barclays --embed $mobileprovisionPath


#create the plist

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>$urlForIpa</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>$bundleIdentifier</string>
<key>bundle-version</key>
<string>$bundleVersion</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>AppName</string>
</dict>
</dict>
</array>
</dict>
</plist>" > "projectName.plist"

                

#upload files on server

Below values depends on your server inputs values !

curl --form ipa=@$ipaPath --form plist=@$plistPath --form os=$os --form branch=$branch --form type=$type --form version=$bundleVersion --form file_size=22MB --form info=$bundleVersion --form releasenotes=@$releasenotes --form smartphones=$smartphones --form tablets=$tablets $urlToUploadfiles