Adding files to Xcode via script bridge.
Adding files to Xcode via script bridge.
- Subject: Adding files to Xcode via script bridge.
- From: Scott Andrew <email@hidden>
- Date: Mon, 17 Oct 2011 19:39:56 -0700
I am trying to add a file to XCode 4.2 via the scripting bridge but something seems broken. The code assumes that xcode has a project open..
XCodeApplication* xcode = [SBApplication applicationWithBundleIdentifier:@"com.apple.dt.Xcode"];
SBElementArray* projects = xcode.projects;
XCodeProject* project = [projects objectAtIndex:0]; NSMutableDictionary* properties = [NSMutableDictionary dictionary];
[properties setObject:@"slide.jpg" forKey:@"name"]; [properties setObject:@"absolute" forKey:@"path type"]; [properties setObject:@"/Users/scottaandrew/slide.jpg" forKey:@"full path"];
XCodeItemReference* xCodeFileRef = [[[xcode classForScriptingClass:@"file reference"] alloc] initWithProperties:properties]; XCodeGroup* group = [openedProject rootGroup]; [[group fileReferences] addObject:xCodeFileRef];
This doesn't assert but the object is not added to the project root. If you do the following:
XCodeFileReference* file = [[group fileReferences] objectWithName:@"slide.jpg"]; [file get];
The object is nil.
I am trying to replicate the following apple script which works:
tell application "Xcode" activate delay 1 -- making a new group works (as a test)... -- set foo to make new group with properties {name:"Foosa", path type:project relative, path:"afsa"} at beginning tell root group of front project -- this will crash Xcode 4, but if you "Continue" long enough it will create something, then if you go into the File Inspector and... -- ... set it's location to "Relative to Project", it works! But I can't get past the crash (yet) make new file reference with properties {name:"slide.jpg"", path type:absolute, full path:"/Users/scottaandrew/slide.jpg"} end tell end tell
I can create groups just fine.. But I can't seem to add a piece of source. Isn't adding a file reference supposed to create the new file? |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden