Including a constants.h file in Prefix.pch breaks code completion, syntax highlighting - xcode4

My application has many constants (kvo keys, enums, etc.) that are used by almost every class. I have a constants.h file with all of them. I want include this file in the Prefix.pch file as follows:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "AppConstants.h"
#endif
However, when I include the file in this manner, Xcode 4's syntax highlighting and code completion stops working. If I manually include the constants file in the header file for every class that uses them, and remove the include from the pch file, syntax highlighting and code completion returns.
Is this expected behavior? How can I include a constants file in every file without using the pch file? Is the problem that the "AppConstants.h" file is being included in itself because of the pch file?

Have a look at this question. I was having the exact same issue as you. If the first answer doesn't fix it for you, further down the page they mention setting the Precompile Prefix Header option to NO, which is what fixed it for me.
Hope that helps.

Related

Applying a macro to all files under a folder

I am using gvim 7.4 on Windows.
I have a macro recorded that I want to apply on specific files (for example, *.sql) under a parent directory. If I open the file and press #q, the macro works perfectly fine.
Is there a way I can recursively search for all .sql files and apply the macro? I can do this manually by opening the individual files but I wanted to see if I could use a "search and apply macro" method.
Thanks!
there are bufdo and argdo commands. At least you can trigger your macro in normal command.
something like:
:bufdo exe 'norm! #q' |w
give it a try.
Note, this will save the file after the macro is played.

Can a LESS file refer to a LESS variables file without using #import?

I'm new to LESS, and I ask because I'm looking at a Weebly theme with a main.less file plus variables files for two color variations of the theme - variables_gold.less and variables_black.less.
Each variables file contains the same variables but with different values.
There are no #import lines in any of these files and no references to the variables files in any output code for the site that I can find. All information I've been able to find about referring to separate variables files involves #import, so I haven't yet been able to find an answer with general web searches. So does LESS just automatically look for other LESS files in the same directory for any undefined variables in a particular .less file, or must I conclude that the associations between these files are created through some other aspect of the theme's coding that I haven't found? (There don't appear to be any references to any of the above-mentioned .less files or any equivalently named .css files in the theme's HTML files or its output HTML that I can find, either, so I don't see it as just a case of different theme color versions having different HTML pages with different details in their link rel="stylesheet" lines.)
Thanks in advance for your thoughts on this.
Since this is a specialized application for Weebly, there's a chance that the site is using a build process to concatenate a variable file before the style definitions, depending on your color theme settings. In this case, it would appear that the variable linking has nothing to do with LESS, but rather with an unseen build-process.
See this article for a more detailed description of what I'm referring to.
As far as I know you must use #import (usually at main less file). Otherwise it would be useless to have #import directive if it still looks at other .less files
I've been informed as follows:
The variables files are not imported into main.less.
These files are defined in the manifest.json file, like the following example for variables_black.less:
"variations": [
{
"value" : "dark",
"sample": "#111111 ",
"is-dark": false
},
{
"value" : "white",
"sample": "#dfdfdf ",
"is-dark": false
},
{
"value" : "brown",
"sample": "#53382f ",
"is-dark": false
}
],

How to concatenate (and not compile) several less files into one using grunt

I'm having trouble finding a solution to this problem. I have a less file app.less that only consists of #import statements. Now I want to generate a single less file that includes all imported less files, because I want to send it to the client to compile it there (yes, I have my reasons to do that).
So the less file should not be compiled in the grunt build step, but only concatenated, so that the client doesn't have to load several less files. I feel that this is a usecase that should have appeared for others as well when compiling less on the client, but I couldn't find a single solution. I don't care if the concatenation happens with grunt-contrib-less or any other tool.
LESS docs says:
Use #import (inline) to include external files, but not process them.
See: Import At-Rules and #import (inline)
You could create new file, for example concatenate.less and import .less files with inline keyword. Then if you process it, it will work exactly like concatenation, no CSS is processed out of it.
concatenate.less
#import (inline) "file1.less"
#import (inline) "file2.less"
#import (inline) "file3.less"
And use your Grunt task like you used to, just rename output file extension to .less for clarity. Tested it, should give you exactly what you wanted.
Nested imports
As #seven-phases-max pointed out, that nested imports would be problem in this case.
Solution would be grunt-includes.
Use grunt-includes with includeRegexp option to create files listed in concatenate.less with already imported LESS files to some other folder.
Change concatenate.less files paths to that folder.
Run your LESS compiling Grunt task normally.
in case someone is working with gulp,
you can just create concatenate.less as #Rene Korss sugested, and use the same command as for compiling less.
Less outputs concatenate.css filename, which is misleading in our case,
so I'm using gulp-rename to have filename named as I want.
var src = 'path-to-concatenate-less-file';
var destination = 'path-to-destination';
gulp.task('concatenate-styles', function () {
var compile= gulp.src(src)
.pipe(less())
.pipe(rename('concatenate-all.less'))
.pipe(gulp.dest(destination))
.pipe(notify("Saved file: <%= file.relative %>!"));
compile.on('error', console.error.bind(console));
return compile;
});
Example of concatenate.less:
#import (inline) "general.less";
#import (inline) "typography.less";

How to let less2css compile all files once one of the less file is saved?

I have style.less which import "page.less". When something is changed in page.less, I have to turn to file style.less and save to let less2css compile so that the changes will take effect otherwise it doesn't because page.less is imported! So is there a way to let less2css compile all files when one of them is changed?
Assuming you're already using the LESS-build you can use SublimOnSaveBuild. This would also work in other scopes.
Alternatively, there's a LESS-only package for Sublime Text as well.

R: Possible to include some "header" files?

I'm new to R and have a basic question. I want to save in a file some variables etc. which I use in several programs. Instead of pasting all the code in each program I want to include always the same file in each program. So if I change something in the Header file, the change takes place in all programs which use this header. How can I do something like this in R?
In my header I only want to define some variables used in all programs.
Just make a R source file, e.g. my_header.R and use the function source to include all variables defined in this file in all your scripts. You can just include the file with source('my_header.R'). Does this help?

Resources