Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Applescript to "Make new C++ Project"
to make_new_project(project_name)
tell application "Xcode" to activate
tell application "System Events"
tell process "Xcode"
click menu item "New Project…" of menu 1 of menu bar item "File" of menu bar 1
tell window "New Project"
-- row 8 is empty project, 4 is Cocoa App
select row 4 of outline 1 of scroll area 1 of splitter group 1 of group 1
click button "Cocoa Application" of radio group 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 1
click button "Choose…" of group 2
tell sheet 1
key code 5 using {command down, shift down} -- g key
tell sheet 1
set value of text field 1 to "/Users/sean/Documents/Reference/Mac Software Projects/"
click button "Go"
end tell
set value of text field 1 to project_name
click button "Save"
end tell
end tell
end tell
end tell
end make_new_project
to zoom_front_window()
tell application "Xcode"
set «event appSpzum» of window 1 to true
end tell
end zoom_front_window
to resize_list_and_doc_views()
tell application "Xcode"
set desired_height_of_list_view to 151
set base_view to «class view» 1 of «class view» 1 of «class view» 1 of «class view» 1 of «class view» 1 of window 1
set side_bar_view to «class view» 1 of base_view
set list_doc_split_view to «class view» 2 of base_view
set list_view to «class view» 2 of list_doc_split_view
set document_view to «class view» 1 of list_doc_split_view
set list_rect to (get bounds of list_view)
set doc_rect to (get bounds of document_view)
set height_to_work_with to ((item 4 of list_rect) - (item 2 of list_rect))
-- Make list smaller
set item 2 of list_rect to ((item 4 of list_rect) - desired_height_of_list_view)
set bounds of list_view to list_rect
-- Make doc view bigger
set item 4 of doc_rect to (height_to_work_with - desired_height_of_list_view + (item 4 of doc_rect))
set bounds of document_view to doc_rect
end tell
end resize_list_and_doc_views
to create_and_configure_bdd_target(active_proj, run_tests_cpp, target_name)
set bdd_target to active_proj's make_new_shell_tool_target(target_name)
bdd_target's add_source_file(run_tests_cpp)
bdd_target's set_header_search_paths_for_all_configurations("/usr/local/include/boost-1_38/")
-- Write the shell script to execute during our new run script phase
set my_script to "\"${TARGET_BUILD_DIR}/${EXECUTABLE_NAME}\""
-- Add new run script phase with our shell script
bdd_target's add_run_script_phase("Run " & target_name, my_script)
end create_and_configure_bdd_target
on run
set interaction_lib to load script alias "Macintosh HD:Users:sean:Library:Scripts:My Library:User Interaction.scpt"
set xcode_lib to load script alias "Macintosh HD:Users:sean:Library:Scripts:My Library:Xcode.scpt"
-- Make a new project
set project_name to interaction_lib's ask_user("What do you want to name this project?")
-- Get the window to look how we want --
-- Get the active project
set active_proj to xcode_lib's active_project()
-- Add the Test Group and files
set test_group to active_proj's add_group("Test Common")
test_group's add_file("/Developer/usr/include/sean/XcodeLogFormatter.h", "XcodeLogFormatter.h")
set run_tests_cpp to test_group's add_file("/Developer/usr/include/sean/run_tests.cpp", "run_tests.cpp")
-- Add the BDD Groups
active_proj's add_group("Features")
active_proj's add_group("Specifications")
-- Add the BDD Targets
create_and_configure_bdd_target(active_proj, run_tests_cpp, "Specifications")
create_and_configure_bdd_target(active_proj, run_tests_cpp, "Features")
-- #2 is only run tests if build successful
-- #4 set all targets to intel-64 and build active config only
-- #5 so app quits after testing, add to run script on test targets: osascript -e 'tell application "[app name]" to quit'
display dialog "Must link boost test library, #2 see comment, and add BOOST_TEST_DYN_LINK to GCC_PREPRO... target setting"
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.