"Unknown type name" despite included framework - iphone

I'm trying (failing) to setup RestKit, which requires one Xcode project to be referenced inside of another. The RestKit framework file creates an NSRegularExpression and appropriately does a #import <Foundation/Foundation.h>. When I build, Xcode spits out "Unknown type name 'NSRegularExpression'".
I'm thinking there might be a circular reference to Core Foundation because I include it in my project and RestKit includes it in theirs? (Remember, the RestKit project is referenced inside of mine, as per their install instructions.)
Also worth noting: In my project build settings, I have the Header and Library search paths set to inside the RestKit/Build path, again, as per their instructions.

I assume you are building your project for iOS. If you included the RestKit.framework in your project, remove it. The .framework is meant to be used in Mac OS projects, add 'libRestKit.a' instead.

I realized I was making the build settings on the project instead of the target. Making sure I was changing paths and libraries on the target instead of the project alleviated all my woes!

Related

Suddenly headers in headers not found <module-includes>:1:9: note: in file included from <module-includes>:1: Xcode

I have been working for a while on a project that implements a custom framework that uses a C library. The framework is written in Swift and I created a module to expose the C headers to swift. The framework was started in a different project, the framework project was then copied to the root of my app project and it was added to my app project as embedded binary. By doing that I aimed to develop the framework, which it is a git submodule of my app project, while I was coding the app.
The framework, as I said, uses a C library and I have the .a files for both debug and release and it provides with a headers include folder. So in my framework project I have the following structure:
and for the static libs
The static libraries where imported as framework and the "library search path" modified for using debug or release. The header search header path was also modified by adding the root folder where all the includes are located.
The Module is located in a folder inside the product folder and defined as:
So that has worked until today. Maybe it was wrong but it never complained.
So the headers are found but the headers inside the headers can't be found.
What am I doing wrong?
I have tried to include as many information as I could. I hope it will be enough.
Thank you.
Well, I think what caused the problem. If I am wrong please let me know.
I have figured out that in "Swift Compiler -> Import Paths", which where I declared my OHNet Module path, you also need to declare the root folder for the "imported headers" so:
Clean and Build and the error is gone.

How to build ZBar SDK with the project instead of using the static library?

I am building an iOS, code scanner project using ZBar SDK. I am trying to build my project directly from the source of ZBar, rather than including the libzbar.a static library.
I have downloaded the ZBar source which includes the XCode project to build libzbar.a. I tried copying all source files from the project but it didn't work. I keep on getting undefined symbol errors.
What source files should be included, considering that I need to support only iOS?
Should the folder structure be strictly followed to build the project?
Would there be any need of build settings if I direcly include the source files?
EDIT:
I followed the same folder structure and build settings used in the XCode project of libzbar. I have managed to build the library but it's still failing while linking. I get the error: ld: duplicate symbol _OBJC_METACLASS for all the source files. I have double checked, there are no references to the original libzbar.a static library in the project or more than one occurrence of these source files. If I remove the references for them, the project builds fine, but then fails whenever any symbol from the library is referenced. I think I am still missing something!!
I have solved this problem finally. Here are the steps that I did:
1) Copied the source files of the project to my project.
2) Removed the dependency of libzbar.a from my project.
3) Added the path to the folder containing the source and headers to the Header Search Paths build setting of the project.
4)Added the following user defined build setting to the project:
EXCLUDE_SOURCE_FILE_NAMES
GCC_MODEL_TUNING
PREBINDING and
USE_HEADERMAP
You should create the static library your self from the source code then add the output static library to your project, or link the projects together and force a build of the static library before your project is build.
After downloading the zip file from the default Mercurial repository and opening the file in xCode, click on the "EmbedReader" part of the target selection drop down box and switch to "zBarSDK"
Once you switch to the zBarSDK, just build from the product menu and you should have your static library file....
I used ZXing lib before and it integrated well. It was included as a project and main project has target dependency to build it before main project. I edited it's sources for my needs and have no problems working with it.
I used this tutorial. It can be helpful for your needs too.

Xcode - deleted openFrameworks libraries, now can't compile and having trouble re-adding

I was 'cleaning up' a project and deleted some of the references to libs used with openFrameworks. Certain things weren't being used, or so I mistakenly thought... Panic in my project!
All sorts of errors, of course. But, XCode won't let me undo that sort of action. I've re-added the libs but the errors persist. Can someone explain to me what basic conceptual thing I'm missing?
Errors go like this [edited]:
/Developer/openFrameworks-iPhone/libs/openFrameworks/app/ofAppGlutWindow.cpp:61: error: 'glutInit' was not declared in this scope
/Developer/openFrameworks-iPhone/libs/openFrameworks/app/ofAppGlutWindow.cpp:62: error: 'GLUT_RGB' was not declared in this scope
/Developer/openFrameworks-iPhone/libs/openFrameworks/app/ofAppGlutWindow.cpp:62: error: 'GLUT_DOUBLE' was not declared in this scope
[UPDATE]. Two things to check: (1) Having a valid build of the oF library itself. Open library project, make sure it builds.
(2) Is the oF library (and all the other, dependent libraries such as Poco) being added in the Build Phases > Link Binary With Libraries section? Sometimes when you delete and then re-add a library, it doesn't get included on this list. Re-drag the library files here. That's what ultimately solved this for me.
Have you tried clean build? I got this error once when adding static libraries.
Found it: Had to manually add the appropriate libraries to be included under "Build Phases". Built the clean download of openFrameworks that way; afterward I could add that to projects referencing the library and build them!

Reconfiguring a dynamic library

I'm working with an open source library that's made available as a git repository (XML-RPC) and I'd like to use it in an iPad application. As I understand it, iOS applications should use static libraries for their linking.
Since this comes as a dynamic library, how can I convert it to something I can link with my app and use?
Maybe naive answer but why not just add all the relevent files in the repository to your app and just build it?
Put the files in a seperate folder obviously so you can update them to a newer version if you need to etc. Lots of projects I've done have an 'external' folder that just contains codethat I use from 3rd party sources. I've usually got the source so just compile it into my app and don't bother with making it a library.
Or are there tricky conditions that need to be met to compile this code?
I ended up doing this in several steps:
First, I opened the library project in Xcode and created a new target for the static library. I then made a directory in the project folder called "XMLRPC" and moved all the header files to it. I deleted the now-red invalid references to the header files, and re-added them (but kept the box for copying them to the current folder unchecked).
I added this Xcode project to my main project with a relative reference. I opened my main app's target and added the library project as a direct dependency, and checked the "Always search user paths" option on my main app's target settings.
Lastly, I modified the general Xcode preferences to use a shared build directory. I haven't tried it without that since it was something I wanted anyways; it might not be necessary.
My revision control has two folders in it: one's my project, and the other's the library. The library is still under git control within mercurial; I'm hoping this doesn't cause any issues.

Libxml in a library for ios

I have created a cocoa touch static library that contains functionality that I want to include in several apps. This library is linked to libxml and I have the header search path /usr/include/libxml2. The library builds correctly.
I include this library in another xcode project as a reference (by dragging the library xcodeproj file into my app xcode project. I also setup the target to have the library as a direct dependency, setup the header search path to include /usr/include/libxml2, and add libxml2.dylib in the frameworks.
The problem is, when I try to build the project is has a build error:
Libxml/tree.h: No such file or directory.
I initially had this problem trying to build the library and solved it by adding the header search path and framework into the project for libxml2.
Incidentally, i have another app that uses the library but does not use libxml, it builds and runs correctly.
So the problem seems to be using libxml in both the app and a linked library.
Anybody any ideas?
Yours hopefully,
Neil.
You probably need to add the include path /usr/include/libxml2 to both the target and the project.
To add it to the target, right click on the target and select Get Info.
To add it to the project, go to the Project menu > Edit Project Settings.
In both cases, make sure you've selected Configuration: "All Configurations".