Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the path of current project opened in Xcode plugin

I'm trying to create an Xcode plugin that should read all files contained in the project opened in Xcode and do further work with files names(Extract images names). The question is how to get the directory/path of the main bundle of the project opened in Xcode.

Thank you.

like image 212
Ali Amin Avatar asked Jan 10 '14 21:01

Ali Amin


People also ask

Where is the root of my Xcode project?

In Xcode select the blue project file (top left) in the navigation bar. In the Identity and Type Inspector ⌥⌘1 on the right click on the little arrow after the Full Path below Location . Show activity on this post. Yes, this is your project folder.

How do I find files in Xcode?

Enter the files name in the bottom bar (search field) of the Project Navigator (on the left side), press enter => there it is ;-) Fantastic!

How do I open an existing Xcode project?

Importing into Xcode Select the file and click Open. Xcode will open the project. On the left side you will see the Project Navigator, with a folder representing your project by name. From here you can expand the folders and explore their contents.


1 Answers

Hi this way you can find the current project path from plugin

NSArray *workspaceWindowControllers = [NSClassFromString(@"IDEWorkspaceWindowController") valueForKey:@"workspaceWindowControllers"];

id workSpace;

for (id controller in workspaceWindowControllers) {
    if ([[controller valueForKey:@"window"] isEqual:[NSApp keyWindow]]) {
        workSpace = [controller valueForKey:@"_workspace"];
    }
}

NSString *workspacePath = [[workSpace valueForKey:@"representingFilePath"] valueForKey:@"_pathString"];
like image 179
SachinVsSachin Avatar answered Oct 05 '22 22:10

SachinVsSachin