简体   繁体   中英

Format project.pbxproj

I created a new project and add a file AppConstans.h Then, git diff and i see next changes:

C856C0AC1C4F4B9900438444 /* AppConstans.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppConstans.h; sourceTree = "<group>"; };

That is OK. Remove this file.

Now I want to do this with a script. In run script add this:

echo "/* AppConstans */" > ${PROJECT_DIR}/AppConstans.h

The file is created, and be in a folder with the project. Now it is necessary to add to the project. I want change project.pbxproj file and add the following line manually :

C856C0AC1C4F4B9900438444 /* AppConstans.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppConstans.h; sourceTree = "<group>"; };

But I do not understand how to code this line here.

I have rootObject:

rootObject = C856C08A1C4F4B7E00438444 /* Project object */;

I have AppDelegate.h

C856C0981C4F4B7E00438444 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };

So it should look like file format

C856C0AC1C4F4B9900438444 /* AppConstans.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppConstans.h; sourceTree = "<group>"; };

Diff between AppDelegate.h and AppConstans.h and root object code C856C08A1C4F4B7E00438444

C856C 08A1 C4F4B 7E 00438444 (root object code)

C856C 0981 C4F4B 7E 00438444 (app delegate)

C856C 0AC1 C4F4B 99 00438444 (app constants)

I can not create here such code to create a file via a script. Any ideas ? Any help would be appreciated

Update:

I create new project. This is project three:

在此处输入图片说明

Step 2:

I add new script and run:

在此处输入图片说明

Step 3:

See project thee again. The file is not in project dir:

在此处输入图片说明

Step 4: Open project dir in finder: And I see AppConstans.h was created. But file not added in project. I must added him manually.

在此处输入图片说明

Step 5: I added file mutually, and I see changes in pbxproj 在此处输入图片说明

So, how i can convert name AppConstants.h to C8F3552E1C57A366003D3D39

You should try:

echo "/* AppConstans */" >> "${PROJECT_DIR}/AppConstans.h"

Notice the >> instead of the > (and the quotes around the path, to prevent expansion). This will cause your string to be appended to the end of the file instead of replacing the file.

A framework you can use for this is PBXproject . Open the .pbxproj file, create a new file reference, and save the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM