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
Related
I have an iOS project-ProjectX (not created by me) which is able to access declaration from a .h file without using #include "someHeader.h".
In ProjectX, I could just create an empty File and refer to a declaration in "someHeader.h", which I find perplexing. Example:
#import <Foundation/Foundation.h>
#implementation Empty:NSObject
SOME_TYPE_FROM_SOME_HEADER_H x;
#end
and the compiler automatically knows where the definition is?!
I have since tried to create an identical project, duplicating all the project settings, adding static libraries/files, etc. but to no avail.
Any ideas on what I might have missed out or what do I need to configure in the project to achieve this?
As mentioned by Rishab, I was missing a precompiled header (.pch) file. In the project, a pch imported a static library which contained the header file. Therefore, I was able to call the definitions directly.
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!
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).
I am thinking about that it would be a great idea for examining that the class type. In example I would like to do the following in my application prefix.pch file.
#if isViewController
#import "DeviceCompatibility.h"
#import "UIViewController+Utilities.h"
#endif
How could I do this.
Thanks for the ideas and your time
This won't work. The point of a pch file is that it is a "Pre Compiled Header" file. It's compiled once and then that is used in every other file.
What you are asking for would require that it not be pre-compiled since it would need to be evaluated for each file. What you want is what regular, non-pch files are for.
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.