organizing xcode 4.0 copy bundle resources
Is there an easy way to organize the files within the Copy Bundle Resources in xcode 4.0? I have multiple targets for my project, and every time I add files, I need to, most of the time, add them to every project. It would help a great deal if I had an easy way to catch myself when I mistakenly forget to copy resources to every target (other than just looking at the count of files in the bundle, which will eventually diverge from being the same for each project).
It'd be a lot easier if I could make folders within the resources list, but it doesn't seem I can. At the very least it might help if I could automatically alphabetize them.
What you have to do is to parse .pbxproj file. All linked file and resources in .pbxproj are identified from their own UUID . So,
rootObject
's UUID rootObject
s Resource
, Source
and Framework
. And find the list of files UUID for all of the three resource types Some hints, The format of the project file is like this, the rootObject refer to other objects.
{
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objects = {
/* .... List of all objects are here .... */
}
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
}
From the rootObject we can follow the targets value.
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "MyProject" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
German,
de,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
projectRoot = "";
targets = (
1D6058900D05DD3D006BFB54 /* TargetDebug */,
C446CDCB12BA35A1001324C8 /* TargetAdHoc */,
C446CF2D12BA3DDC001324C8 /* TargetAppStore */,
);
};
/* End PBXProject section */
In the target section of the project file, buildPhases contains the link to the copied bundle resources list and link.
/* Begin PBXNativeTarget section */
1D6058900D05DD3D006BFB54 /* TargetAdHoc */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "TargetAdHoc" */;
buildPhases = (
1D60588D0D05DD3D006BFB54 /* Resources */,
1D60588E0D05DD3D006BFB54 /* Sources */,
1D60588F0D05DD3D006BFB54 /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = TargetAdHoc;
productName = MyProject;
productReference = 1D6058910D05DD3D006BFB54 /* MyProject.app */;
productType = "com.apple.product-type.application";
};
C446CDCC12BA35A1001324C8 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C446CDCD12BA35A1001324C8 /* MainWindow.xib in Resources */,
/* ....... list of all PNGs and XIB files..... */
81CDEBBF13B21B790067A088 /* AnImage.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
(on Xcode 3.2.x): You can alphabetize the files in a phase by selecting the phase, then Edit -> Sort -> By Name.
As far as breaking them up into "folders" -- nothing is stopping you from having multiple Copy phases! You can even give each one a descriptive name.
Don't know if it's helpful in this instance, but in Xcode, when you select a file and Get Info on it (command-I), one of the tabs is "Targets." From there, you can select all the targets you want a file to be a part of. I believe that for non-compiled files, it merely adds the file to the Copy Bundle Resources phase of the selected target(s).
链接地址: http://www.djcxy.com/p/49550.html