Applescript and Xcode: how to add a framework to the link phase

Hi all,
I am new to Applescript and this is my first post here. I have search the web for a week now and could not find a solution.

I want to use an Applescript to modify a Xcode project. I want to add a framework to the “link binary with libraries phase” like I would do manually by pressing the + button.

Here is my code:


on run {}
	addFolder()
end run

on addFolder()
	tell application "Xcode"
		open "/Users/sdansereau/Desktop/xcode projects/TestApplescript"
		tell project "TestApplescript"
			set my_targets to targets
			set s_target to item 1 of my_targets
			set link_phase to get link binary with libraries phase of s_target
			tell link_phase
				set new_ref to make new item reference with properties {name:"AddressBook.framework", path type:current SDK relative, path:"System/Library/Frameworks/AddressBook.framework", full path:"/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AddressBook.framework"}
			end tell
			add new_ref to link_phase
		end tell
	end tell
end addFolder

I get the following error :

error “Xcode got an error: Can’t make or move that element into that container.” number -10024

Can someone help me please?

Simon

Hi,

actually the framework references are stored in the element build files of link binary with libraries, but in Xcode 4.2 I get an Event Handler failed error, which seems to be an incomplete implementation of the Xcode sdef file

I know it can be done because I found a run-only script that does it…

I would try (just a guess)


set new_ref to make new item reference with properties {name:"AddressBook.framework", path type:current SDK relative, path:"System/Library/Frameworks/AddressBook.framework", full path:"/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AddressBook.framework"}
make new build file at end of build files with properties {name:"AddressBook.framework", file reference:new_ref}

No luck:
error “Xcode got an error: AppleEvent handler failed.” number -10000

Thanks for your help. I really appreciate it.