PBXBuildFile vs PBXFileReference section - xcode

What is the difference between PBXBuildFile and PBXFileReference in project.pbxproj? Does it matter if a file is listed in both of the sections? What is the policy what file in which section should get?
/* Begin PBXBuildFile section */
3D081B83146ACE36000CC86B /* B767.png in Resources */ = {isa = PBXBuildFile; fileRef = 3D081B82146ACE36000CC86B /* B767.png */; };
/* Begin PBXFileReference section */
3D081B82146ACE36000CC86B /* B767.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = B767.png; sourceTree = "<group>"; };

You should normally never have to worry about this, but it can come up in certain merge conflicts in the project.pbxproj file.
A PBXFileReference is a reference to the actual file. It's the object that backs up the files that appear in the left-hand project view.
A PBXBuildFile is a file in a target. It wraps a PBXFileReference and adds certain attributes like per-file compiler flags. If a file is added to a target, it will be listed in both sections. If a file is in more than one target, it will have more than one PBXBuildFile in the build files section.

Related

Cannot view StoryBoard or Project Targets in Xcode 13.1

I have just upgraded to Xcode 13.1 and both the Target and Storyboard displays XML only.
This is my project Target file view.
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objects = {
/* Begin PBXBuildFile section */
FE02B2A625CB5E7D00C2B123 /* SectorTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE02B2A525CB5E7D00C2B123 /* SectorTime.swift */; };
FE0340BC2169997900803E4C /* TransactionNumberGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE0340BB2169997900803E4C /* TransactionNumberGenerator.swift */; };
FE036EF7245D116000C9D3A1 /* ArchiveImport.swift in Sources */ = {isa = PBXBuildFile;
The "Open As" options are missing from the menu when I right click on the storyboard file in the project navigator:
Anyone have any ideas? I have done a clean build and I restarted both Xcode and my Mac.
Thanks, I did find the problem. The editor remained in "Code Review" mode after the automatic upgrade to Xcode 13.1. By pressing "Disable Code Review" in the top right-hand corner, I fixed everything.
It was not an obvious fix because the Code Review mode remained on across different files I selected. Also, because my source code was up to date, there were no differences in my Swift code files, so they all looked original, whereas Storyboard and Targets seemed quite different.

How to change libwebsockets color scheme

I am using libwebsockets library. This exposes certain methods for writing into a log file.
lwsl_warn(...), lwsl_err(...) and lwsl_err(...)
to name the most common.
The output is color coded using ANSI sequences.
Is there a way to set the default color scheme (other than recompiling the library)?
Thanks.
I poked around in the libwebsockets source and found my answer:
The colors are hard coded - so the answer to my original question is "no".
However, the color scheme is not hard to find and edit. It resides in two source files - one of these is compiled depending on options:
libwebsockets/lib/core/logs.c
and
libwebsockets/lib/plat/optee/lws-plat-optee.c
All it takes is to edit the self-explanatory table:
static const char * const colours[] = {
"[31;1m", /* LLL_ERR */
"[36;1m", /* LLL_WARN */
"[35;1m", /* LLL_NOTICE */
"[32;1m", /* LLL_INFO */
"[34;1m", /* LLL_DEBUG */
"[33;1m", /* LLL_PARSER */
"[33m", /* LLL_HEADER */
"[33m", /* LLL_EXT */
"[33m", /* LLL_CLIENT */
"[33;1m", /* LLL_LATENCY */
"[0;1m", /* LLL_USER */
"[31m", /* LLL_THREAD */
};
Then build as before. Once in the libwebsockets/build directory do the following:
make clean
make && sudo make install
sudo ldconfig
... and enjoy!

Explain fst_posmode, difference between F_PEOFPOSMODE and F_VOLPOSMODE?

Header file:
/* Position Modes (fst_posmode) for F_PREALLOCATE */
#define F_PEOFPOSMODE 3 /* Make it past all of the SEEK pos modes so that */
/* we can keep them in sync should we desire */
#define F_VOLPOSMODE 4 /* specify volume starting postion */
Man page:
The position modes (fst_posmode) for the F_PREALLOCATE command indicate how to use the offset field.
The modes are as follows:
F_PEOFPOSMODE Allocate from the physical end of file.
F_VOLPOSMODE Allocate from the volume offset.
The doc is hard to understand.

How to change variable in <head> on variation page in Optimizely

I'm trying to load a new design template into optimizely.
The CMS stores the new templates in alternate URLs. The files are loaded in the section of the page.
The original templates are loaded as follows:
var name1 = /url1/
var name2 = /url2/
And we need to change the urls that go with the variables to:
var name1 = /url3/
var name2 = /url4/
I'm guessing we might have to use the append function, similar to this (this is for adding a new CSS stylesheet to a page):
$("head").append("");
But I can't seem to make it work in optmizely.
You can set variables on the window and then reference them like so:
/* _optimizely_evaluate=force */
window.foo = 'bar'; // in optimizely
/* _optimizely_evaluate=safe */
// later in your code
var name = window.foo || 'baz';
Remember though anything not matching the $(selector).action() template will wait till domReady unless you also use the force comments.

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,
Get the rootObject's UUID
Get list of targets UUID from rootObjects
For each target get the list of UUID for Resource, Source and Framework. And
find the list of files UUID for all of the three resource types
Compare the list of resources for each of the targets.
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).
You can have folders in your Resources group. Just drag a real finder folder into xcode and choose 'Create folder references for added folders', and choose all the targets that you want to use.
This will create a dynamic folder reference that will add all files within that folder automatically without you having to add the files individually everytime.

Resources