Get the path to the current project open in the Xcode plugin

I am trying to create an Xcode plugin that should read all the files contained in a project that opens in Xcode and continue working with the file names (Extract image names). The question is how to get the directory / path of the main project package open in Xcode.

Thanks.

+7
plugins path xcode project
source share
2 answers

Hi, you can find the current project path from the 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"]; 
+11
source share

See Apple Sandboxing Guide: https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxDesignGuide.pdf

If you want to get the bundle directory:

 NSString* bundle = [[NSBundle mainBundle] bundlePath]; 
-one
source share

All Articles