Xcode Framework Header - xcode

When trying to make a Cocoa framework I ran into the old problem of the headers not copying, which I fixed by changing the visibility(?) of the headers to public. now I Would Like to organise the framework more logically. when the headers are copied there are are placed all in the same directory with no subfolders. I would like it to organise the framework by placing the headers in sub folders so that I can #import them like:
#import <Myframework/Math/MathFunction.h> // import some math related functions
however I notice that the system frameworks contain subframeworks. If I must I am willing to do that and also is there a fast way to convert all the
#import "someFile.h"
to
#import <Myframework/somefile.h>
in the release so the in other project I can #import them without confufing the compiler?

Related

Is it possible to compile complie seperate module that depend on only one library in SASS?

For example, a lot of the SASS I have been writing require and use the mixins from bootstrap. However, I would like everything to not be complied into one large file. So for example in a main.scss I could have:
#import 'bootstrap/assets/stylesheets/_bootstrap';
#import '_mypage'
#import '_mypage2'
but when you compile the file it would just end up as one file where I am trying to get it so I have bootstrap, mypage, and mypag2 as separate css file, while maintain the ability to use the bootstrap.
Is there a way to do this in sass? Or should I be looking at certain tools to achieve this goal?
IIRC, the _ in front of SCSS files is what tells the compiler not to make its own file. What you're telling the compiler with your #import lines is that you want all of those files to be added to the top of your main.scss.
If you make a mypage.scss, and put it in the same directory where the compiler is looking, it will compile to its own file. You can either import bootstrap at the top of that file as well, or just load earlier it in your HTML to be able to reference it.

Singularity.gs: helpers _box-sizing.scss and _clearfix.scss not included into _helpers.scss

I'm currently working with singularity.gs v1.7.0 and I noticed that the helper files _box-sizing.scss, and _clearfix.scss, are not included into the _helpers.scss file. I did had the same experience with singularity.gs v1.6.2.
Here is how I'm including singularity.gs into my SASS code and also how I'm going around this issue:
#import "_singularitygs.scss";
// for some reason the content bellow wasn't called from inside singularity
#import "singularitygs/helpers/_box-sizing.scss";
#import "singularitygs/helpers/_clearfix.scss";
// end of missing libraries
Can somebody confirm if this is a bug or not, and what would be the preferable procedure to including these two files?
Unfortunately I wasn't able to find a clear answer on the documentation.
Thank you

Best practices for adding compile sources to a Prefix.pch file

I'd like to put some categories I wrote for different projects into a central folder and put the header files together with some common macros into a mystuff.h which I'd like to add to the Prefix.pch like so:
Prefix.pch:
#import "myStuff.h"
myStuff.h
#import "/Users/foo/Documents/Xcode-Projects/my_stuff/NSNumber+someCategory.h"
#if DEBUG
// some macros
#endif
The goal is to add only the one line where I import myStuff.h to the Prefix.pch file of a new project and be done. The approach above so far compiles fine, but the runtime throws exceptions for all the category methods I use in the project, because the .m files of the categories don't get compiled.
So far I found two solutions:
a) I can add the .m files manually to "Build Phases => Compile Sources"
b) for every .h file that I import in myStuff.h I add the associated .m file, like so:
myStuff.h
#import "/Users/foo/Documents/Xcode-Projects/my_stuff/NSNumber+someCategory.h"
#import "/Users/foo/Documents/Xcode-Projects/my_stuff/NSNumber+someCategory.m"
(or merge the .h's into the .m's)
While approach a) seems to be clean, it does require additional work, whereas approach b) requires less work but I'm not sure whether that is best practice. Any ideas on how to solve this cleanly, or is approach b) acceptable?
One option might be to put your categories together into a library, and then refer to that library in your current project. See Ray Wenderlich's example at:
http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial
It sounds like what you really want is a library or framework. Here are the docs for creating a framework in Xcode. Or if you want to build a library for iOS this discussion may be useful.

PCH file selection

You're trying to use precompiled headers to "speed up compilation". Xcode has a file called YourProject_Prefix.pch. You can include any number of header files in there that you like.
My question is, how do you select what header files should make it into your PCH? Should you just throw all your header files into there, or will that actually not be optimal?
Just import your header files there like the ones below.
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "YourHeaderFile.h"
#endif
Pre-compiled headers, especially during building your app, can be very useful. The headers in the .pch file are only compiled the first time and then only if the headers change in the future. If your app imports many frameworks/headers that do not change; this could accelerate building (compiling) since the compiler will use the .pch versus compiling every imported framework/class every time you compile.
the pch file will be included in all your source files by default.
that means you should really only put header files in there that are more or less global or never change. I believe putting all your headers in there would slow down compilation because every time you changed one it would cause every other file in your project to have to recompile. (I did not test or research this)
here is a sample from one of my projects:
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#import "Errors.h"
#import "Localization.h"
#import "Logging.h"
#endif
Additionally, take the linked comments about C++ with a grain of salt. C++ uses templates and such that go in header files and make compilation take much longer than you are going to see in objective-c. in objective-c you are only likely to have types and interfaces, not implementation in a header.

Framework headers from PCH file not found when built as a subproject

I have the following project setup:
1) A main iOS project ('super project')... nothing special here, the project was built on top of one of the default iOS templates from Xcode.
2) A second project ('subproject'), which was created on top of the Static Library template. I added this project to the super project, and created references to it from the superproject in the 'Target Dependencies' and 'Link Binary with Libraries' build phases.
Inside the subproject, I have a C function declaration which looks like this:
ABAddressBookRef myABAddressBookCreateWithOptions(CFDictionaryRef options, CFErrorRef * error);
It's meant as a replacement/proxy of the similarily named function from the AddressBook framework and uses a type (ABAddressBookRef) from that framework. The declaration is stored in a header file, and the implementation exists in the corresponding .m file. To make this type available, I added the framework header to the .pch file of my subproject:
#ifdef __OBJC__
#import <AddressBook/AddressBook.h>
#import <Foundation/Foundation.h>
#endif
The following problem occurs:
If I build the superproject (release or debug config), the build fails with this error message:
.../ManagedCFunctions.h:24:1: Unknown type name 'ABAddressBookRef'
Things I've done to fix the issue, or at least get an idea of what's going on:
Building the subproject separately works (but a subsequent superproject build fails regardless)
Uncommenting the declaration gets rid of the error, but naturally raises an "Implicit Declaration of Function" warning at the calling location
Adding the import to the superproject's .pch file does not help
Adding the import to the header file of the function directly works, but is not an option in my scenario (parts of the code are autogenerated, and it would be hard to find out which file needs which frameworks)
I suspect that maybe the header file is not processed in Objective-C, but rather C mode, so the imports are ignored due to the #ifdef __OBJC__ macro around the import, but removing it hasn't helped either. I also tried to add #import <Foundation/Foundation.h> to the function's header file to 'suggest' Objective-C mode, and it actually enabled correct syntax highlighting in the file, but hasn't helped for building.
Any suggestions as to why the symbol is found in the .m, but not in the .h file? Or any workaround that does not require adding the import to a specific header file, but globally?
Today I found a isuue after I in project -> Info -> Configurations add a configuration file, then I run my project, it goes wrong in my pch file.
It shows that xxx.h not found, I search a lot of solutions, but I can not get the right answer. So I remember that step.
I deleted the configuration file, and my project become normal.
I hope this will be helpful for this kind issue.

Resources