Cant seem to import files using rails and less - ruby-on-rails

I cannot seem to figure out why my import statements aren't working.
i have a file located at /assets/stylesheets/config/load.css.less
and a file located at /assets/stylesheets/config/global.css.less
inside of the config file i simply use #import "global.css.less";
the code is so simple that its baffling me why it's not working. nobody else seems to be having this problem, so it must be something really simple. Any ideas?
the error i get is
Less::ParseError: 'global_vars.css.less' wasn't found.
anybody who can help it would be much appreciated!

Less looks at the root of your assets directory for doing the #import, try changing:
#import "global.css.less"
to
#import "config/global.css.less"
and see if that works.

Related

Xcode template to import file by file path

I have a Xcode template file like so:
#import "___FILEBASENAME___.h"
#implementation ___FILEBASENAMEASIDENTIFIER___
#end
This will create an example file like so:
#import "ExampleFile.h"
#implementation ExampleFile
#end
However due to some complexity in our build system, I need to import files by their file path.
For example, if I was creating ExampleFile.m inside of Path/To/ folder. Then my desired output would be:
// Desired template output
#import "Path/To/ExampleFile.h"
I tried looking through some Apple example templates, but didn't seem to find a way to make it work.
I also stumpled upon ___DIRECTORY___ referenced here, but it doesn't seem to work for me when I attempted to use it.
Does anyone know if there is a way to accomplish this?
Try enabling "Use custom working directory" option, it will let you choose the base directory.
How to enable this is answered in the following question.
Xcode: How to set current working directory to a relative path for an executable?
Hope this helps

How to keep the header path if using cocoapods?

I don't know how to describe this question clearly,I can't speak English very well.
I'm creating a CocoaPods Spec, I got these folders and files in my project:
MySDK/*.(h,m)
MySDK/AdvertisementSDKS/Millennial/*.(h,m)
MySDK/AdvertisementSDKS/Millennial/SDK/MillennialMedia.framework
and Podspec's source_files looks like
s.source_files = "*.{h,m}", "AdvertisementSDKS/**/*.{h,m}"
also include framework
s.vendored_frameworks = 'AdvertisementSDKS/Millennial/SDK/MillennialMedia.framework
in Millennial folder there is a .m file that imports:
#import <MillennialMedia/MMInterstitial.h>
When I try compile, Error occurs, Because compiler cant find the path of MillennialMedia/MMInterstitial.h
The correct import way is
#import <MMInterstitial.h>
Are there any settings I missed, that I can set to keep the original #include path?
Because there are lots of other same issue, I have to modify it one by one...
Thank you!
OK, I'll answer my own question:
I missed some settings of Podspec, Just simply add
spec.header_dir = './'
(The directory path depends on your project)
To your podspec, Then, It'll keep the original path works
Don't need to modify the header path! Woohoo!

Expected identifier for every occurance of "(Class)class" in LARSAdController

I'm currently trying to add LARSAdController to my iOS project with no success.
As soon as i import the files via #import "LARSAdController.h" in my AppDelegate.h the build process fails and on every occurance of (Class)class in LARSAdController.h i get the cryptic error "Expected identifier". BTW I'm using cocoapods.
Example:
- (void)registerAdClass:(Class)class;
which seems fine to me...
If i create a blank project and import the files they compile, so the problem must be in some relation to my code. Anyone got an idea what may cause this?
Thanks for any help in advance!
class is a reserved word in C++, so I would imagine that some of your project uses Objective-C++.
To solve this, use #import LARSAdController.h in Objective-C implementation files only, and remove its use from header files. You can use #class to forward-declare any occurrences of whatever classes are defined in LARSAdController.h in header files (this is best-practise anyway).
If you need to use LARSAdController from an Objective-C++ class then this is more complicated and you will need to use an Objective-C proxy object or modify their header files (which isn't ideal).

Sass variable undefined during Rails asset precompile

I have several dozen sub directories in my stylesheets folder, many of which refer to each other with variables defined in the file _settings.sass. In my application.sass file, I importing settings first:
#import "settings"
#import "folder-one/some-sass-file"
#import "folder-two/some-other-sass-file"
This works well in development, but when I try to precompile, I get an error about $namespace being undefined in "folder-one/some-sass-file"--even though it's defined right there at the top in _settings.sass.
This seems to be happening because the compiler is trying to compile everything in sequential order, rather than looking at application.sass. Am I understanding this right? And if so, what can I do to remedy the problem?
You just need to add #import "settings" into your some-sass-file. Asset pipeline will minify it for you so there is no problem.

Rails 3.2 & LESS: A few in application.css.less #imported LESS files do not trigger recompile

I really don't know how to debug this, maybe somebody has an idea.
I have many LESS files which I import in application.css.less. We use Bootstrap, and we want to use the variables that are defined in it within our own styles, so we can't require the LESS files in the manifest (as required files don't seem to make their variables public to other required files).
Everything works nicely, except a few of the LESS files - when edited - don't trigger a recompile of the CSS! It seems to be quite random which do and which don't, and it's only 6 of them which don't (compared to about 25 in sum). When I require one of them in the manifest, it successfully leads to a recompile - if I #import it, it doesn't.
Any idea on how to debug this? If I rename one of them (e.g. from time_records.less to time_records2.less), it successfully trigger recompile after changes... So it has do do something with the names of these 6 specific files:
calendars.less
contacts.less
folders.less
handout.css.less
print.css.less
time_records.css.less
Any help is greatly appreciated. Thank you.
The latest edition of less-rails implements Import Hooks that should solve your problem. I realize this is a late answer and it may have not existed at the time.
Import Hooks
Any #import to a .less file will automatically declare that file as a sprockets dependency to the file importing it. This means that you can edit imported framework files and see changes reflected in the parent during development. So this:
#import "frameworks/bootstrap/mixins";
#leftnav { .border-radius(5px); }
Will end up acting as if you had done this below:
/*
*= depend_on "frameworks/bootstrap/mixins.less"
*/
#import "frameworks/bootstrap/mixins";
#leftnav { .border-radius(5px); }
The depend_on Directive
depend_on path declares a dependency on the given path without including it in the bundle. This is useful when you need to expire an asset's cache in response to a change in another file.

Resources