imports of *.pch files are ignored for new classes - why? - xcode4.3

I have a project created with Xcode 3 and now want to update it using Xcode 4.3.
I used a *.pch file which works great - however on all the new classes I create now in Xcode4.3 this pch is ignored and I need to write the imports manually for these classes.
Is this a bug or a feature :-) ?
Is there anything special I need to do to get the pch file working for the new classes files?
Many thanks

Related

Swift modules are not using localizables from L10N

I'm working on a project which's been built by different modules. Most of the modules are in Objective-C, but some of them are written in Swift.
I added localizables (using L10N) in four different languages and I can see the language changes in the whole app, excepting the Swift modules.
In my project I have the localizable.strings files so they've been created correctly, but for some reason when I run the app, it shows my default language only.
Any idea about how this can be solved?
EDITED:
here is a screenshot of how localizable files are set in my project:
Thanks in advance
You will need NSLocalizedStringFromTableInBundle to refer strings from modules.
To get bundle you can use +[NSBundle bundleFromClass:]

Adding GLM to project in Xcode 4

I am trying to add GLM to a project in Xcode 4, but I cannot get it to compile. I have added the glm files to my project through the add files dialog.
I get a lexical/preprocessor issue and Xcode cannot find the file <cmath>.
I am not sure what I need to tweak to get this to build.
I have seen How do I add OpenGL Mathematics (GLM) to Xcode 4? already.
All you need to do is add the files to the project and #import "glm.hpp" (for Objective-C++; for simple C++ it should just be #include "glm.hpp").
A couple things to be careful of:
The OpenGL Mathematics library, when you download it, comes with a bunch of stuff you don't need (test code, extraneous utilities). Adding these to your project will result in compile errors which I could not get rid of. The only directory you need is the glm/ directory; you can delete the test/, util/, doc/, and bench/ directories. If you were trying to follow "How do I add OpenGL Mathematics (GLM) to Xcode 4?" and were still having problems, this may be the thing which was tripping you up.
The OpenGL Mathematics documentation tells you to include the or files. In Xcode 4, you should include them like "glm.hpp" or "*.hpp". Xcode will find the files no matter where in the project they are. Supposedly you can add a user-defined build setting "USE_HEADERMAP" and set it to "NO" to disable this, but I didn't have any luck with that.
And, just in case, note that your code files using the OpenGL Mathematics library must be Objective C++ files (ending in ".mm"), not the default/plain Objective C files (ending in ".m"). It is very much a C++ library after all... :-)
I hope that help. I was just working through this myself, and I haven't had the chance to really push this (e.g. I've basically just added a mat4 object or two and made sure things still compiled), but it seems to be working.
I ran into the same problem and I solved it remaning my ViewController.m to ViewController.mm. Change the extension to .mm tells XCode that the file may contain C++ code inside. The article Write Object-C Code explains this in the Classes and Objects section.

How do I use static libraries in Objective-C (OS X)?

I'm a beginner programmer using Xcode, and I'm trying to make a static library so that I don't have to copy files over every time I write a new program. Problem is, I could not find a satisfactory explanation of how to do this -- I've tried a few tutorials and I'm sure I've skipped some steps. So:
I have an Xcode project with my class files. It's got a class to deal with large numbers called Large -- Large.h and Large.m. I chose to make it a static library, and I built it.
Then, I made a new project and followed this. I tried to #import "Large.h", but Xcode still wouldn't recognize the class Large as it does in my projects that have a copy of the source files themselves. I'm probably doing a ton of things wrong... What do I do? Thanks a lot!
I wrote a tutorial some times ago... Hope this will help you:
http://www.eosgarden.com/en/articles/xcode-static-libraries/

Not possible to create a framework with no executable code?

Just stumbled into something strange with Xcode 4 and Cocoa frameworks. I've a meta-framework that is essentially a .h file with constants needed by a number of other frameworks I've created. I'm capable of creating and building the framework but every time I try to include it in a project Xcode would throw a hissy fit during the build phase, saying it couldn't find the framework, even though the .framework folder was there and the .h file was set to be publicly visible.
After many a hours of running in circles I decided to throw in a .m and corresponding .h files, just so I could have something binary in there and now Xcode is happy as Larry.
Can someone explain this behaviour to me? Why do I need a useless executable to make Xcode see my framework?
The hissy fit is presumably coming from the linker. (Always post your error messages! Guessing isn’t that much fun.) As far as the linker is concerned, the binary is the framework. If you just want the header, you can include the framework in your search paths and #include the header without linking to the framework.

Best practices when importing class files in xcode

I'm working with xcode and I have classes associated with other projects that I want to be included in new projects. I realize that the #import will do the job technically (although what should i do if it's out of the project root folder). But what do I do if I want to include the class "properly" --basically so i can double click and edit out of the main project window where you can see all your files and such.
I guess I'm just looking for the best and/or proper way to include/import (into the project) .h and .m files that I've already created outside of the current project I'm working on. Taking into consideration that I may want to modify the class from the original without subclassing. Hopefully this makes sense.
Thanks,
Nick
Xcode project file organization doesn't reflect the data files on disk. Files can be added to a project from anywhere in the file system. When you add the files, choosing not to copy the files to the current project's directory means that the original files are used. Selecting one of these files in Xcode for editing will alter the original file in that other project. When returning to that other project, Xcode will use the edited files in any further work.
This type of use can be quite handy while working on multiple projects with some shared code. Yet, it can also cause headaches for a versioning system.
Might be worth thinking about how to make the classes into a private framework - then you can import that as another dependency each time. Alternatively you could use a separate version control system location to store the shared classes and just check that out into the project folder.