Whenever a release of KosmicTask is built agvtool is used to increment the bundle versions of all the various components. The bundle version is significant for the user because when the app is upgraded a change in the KosmicTaskServer component bundle version is what triggers that component to update all the application tasks.
Before running agvtool it is necessary to quit Xcode first.
This KosmicTask powered script will quit and save the current project, run agvtool and then relaunch Xcode to build a release.
Scripting Xcode is merely an alternative approach to running xcodebuild.
--
-- Created by Jonathan on Friday, 16 April 2010 09:16:57 Ireland Time
--
-- Credits:
--
-- Notes: see http://lists.apple.com/archives/Xcode-users/2008/Feb/msg00497.html
--
property p_projectPath : "/Users/Jonathan/Documents/Computing/KosmicTask/KosmicTask/trunk"
property p_projectFile : "/KosmicTask.xcodeproj"
property p_target : "KosmicTask"
property p_buildConfig : "Release"
on kosmicTask(_bumpIt, _cleanIt)
try
set theResult to {}
set myPath to p_projectPath
--
-- quit xcode while we update the project with agvtool
--
tell application "Xcode"
--
-- quit and save
-- note that quit returns immediately
--
quit saving yes
--
-- if we try and retarget Xcode without a short delay we get an error
-- of : Connection invalid -609
--
repeat while running
delay 0.1
end repeat
end tell
--
-- bump the project version if required
--
if _bumpIt = "yes" then
set bumpScript to "cd " & myPath & " ; agvtool bump -all"
set aResult to do shell script bumpScript
set end of theResult to {|agvtool bump|:{bumpScript, aResult}}
end if
--
-- get project file
--
set myProjectPath to myPath & p_projectFile
set myFile to POSIX file myProjectPath
tell application "Xcode"
--
-- we want to observe the build process
--
activate
--
-- open the project document and get the project object
--
set myProjectDocument to open alias myFile
set myProject to project of myProjectDocument
tell myProject
--
-- get the release build config
--
set buildConfig to missing value
set buildConfig to get build configuration type 1 whose name is p_buildConfig
if buildConfig = missing value then
error "Cannot find build configuration"
end if
--
-- set the active build config to be used by clean and build
--
set active build configuration type to buildConfig
--
-- set the target
--
set theTarget to missing value
set theTarget to target p_target
if theTarget = missing value then
error "Cannot find target"
end if
set active target to theTarget
--
-- clean if required
--
if _cleanIt = "yes" then
set aResult to clean with removing precompiled headers and transcript
set end of theResult to {|clean|:aResult}
end if
--
-- build without waiting for reply as we are likely to time out
--
ignoring application responses
build
set end of theResult to {|build|:"RUNNING"}
end ignoring
end tell
end tell
return {kosmicData:theResult}
on error errorMessage number errorNumber
activate
return {kosmicError:errorMessage & " : number = " & errorNumber as string}
end try
end kosmicTask
-- Created by Jonathan on Friday, 16 April 2010 09:16:57 Ireland Time
--
-- Credits:
--
-- Notes: see http://lists.apple.com/archives/Xcode-users/2008/Feb/msg00497.html
--
property p_projectPath : "/Users/Jonathan/Documents/Computing/KosmicTask/KosmicTask/trunk"
property p_projectFile : "/KosmicTask.xcodeproj"
property p_target : "KosmicTask"
property p_buildConfig : "Release"
on kosmicTask(_bumpIt, _cleanIt)
try
set theResult to {}
set myPath to p_projectPath
--
-- quit xcode while we update the project with agvtool
--
tell application "Xcode"
--
-- quit and save
-- note that quit returns immediately
--
quit saving yes
--
-- if we try and retarget Xcode without a short delay we get an error
-- of : Connection invalid -609
--
repeat while running
delay 0.1
end repeat
end tell
--
-- bump the project version if required
--
if _bumpIt = "yes" then
set bumpScript to "cd " & myPath & " ; agvtool bump -all"
set aResult to do shell script bumpScript
set end of theResult to {|agvtool bump|:{bumpScript, aResult}}
end if
--
-- get project file
--
set myProjectPath to myPath & p_projectFile
set myFile to POSIX file myProjectPath
tell application "Xcode"
--
-- we want to observe the build process
--
activate
--
-- open the project document and get the project object
--
set myProjectDocument to open alias myFile
set myProject to project of myProjectDocument
tell myProject
--
-- get the release build config
--
set buildConfig to missing value
set buildConfig to get build configuration type 1 whose name is p_buildConfig
if buildConfig = missing value then
error "Cannot find build configuration"
end if
--
-- set the active build config to be used by clean and build
--
set active build configuration type to buildConfig
--
-- set the target
--
set theTarget to missing value
set theTarget to target p_target
if theTarget = missing value then
error "Cannot find target"
end if
set active target to theTarget
--
-- clean if required
--
if _cleanIt = "yes" then
set aResult to clean with removing precompiled headers and transcript
set end of theResult to {|clean|:aResult}
end if
--
-- build without waiting for reply as we are likely to time out
--
ignoring application responses
build
set end of theResult to {|build|:"RUNNING"}
end ignoring
end tell
end tell
return {kosmicData:theResult}
on error errorMessage number errorNumber
activate
return {kosmicError:errorMessage & " : number = " & errorNumber as string}
end try
end kosmicTask
Post new comment