How to add file to AppCode/XCode project?

Hi,

I'm writing small plugin for AppCode which generates some file from template and puts it into proper directory. I created a file using `createFile` method on `PsiDirectory` object, it is visible in my file structure in Finder, but it is not added to project file (I don't see it neither in pbxproj file nor tree view in AppCode). Is there any way to do add that file to the project using IntelliJ's API?

 

Thanks,

Karol

0

Hi Karol,

There is no public API for this, but you can try using PBXProjectFileManipulator. To do that first you need to obtain from XcodeMetaData a PBXProject you want to modify from, then do getManipulator().addFile(). You will also need to provide an array of PBXTargets you want to add the file to (may be empty), and a PBXGroup to put the file into. Take a look at available PBXProject methods to get an idea how you might obtain them.

0

请先登录再写评论。