I apologize in advance if this has been addressed, but I have not found a specific answer as of yet.
First, I am trying to use a C library in an iPhone/Cocoa touch app. It compiles fine as a plain C project and as a plain Foundation project (using X-code). My problems is this: The library uses a dictionary file which is called directly using fopen(). My question is how can that file be accessed on an iPhone from a C library which does not or cannot use Objective-C/SDK routines. I'm assuming that there is a way...somehow.
Thanks!
I think fopen is ok. But XCode put all resource files into the root directory. So maybe you should rewrite the library to open the file from the root.
Other solution is to create "folder reference" with "Add to project" menu. This way I think the whole folder will be copied to the app bundle.
Related
I have a reqular objective C project. I import 10 C++ files into my project. All this files take "are communicating" with each other. If I have a look at File1.h, this file can manage all the operations in other class.
So, the question is How to include reference to File1.h and to call functions from it.
For example: [File1Class getAudioData];
If I include it by #include "File1.h", I will get a error "Class is unknown element"
P.S. I want to import aurioTouch2 sample code to my project and to call functions from theire C++ code.
You Can simply open both the projects in Xcode and drag and drop the files you need from the aurioTouch2 application. Make sure the files are actually copied by selecting the check mark that you get after you drop the files in your xcode project. After this, you will be able to use those files/classes. Consider using ".mm" as the extension of the implementation file in which you want to use the c++ files/classes. You may also use ".mm" as extension for your appdelegate implementation file in case you get c++ related errors.
I'm adding Zxing 1.7(Qr scanner) to my projects.
I upgraded Mac OS X to Lion and xcode4.2, iOS5.0.
Problem is that when I run the project, I always saw "iostream file not found".
I run the scanTest(Qr scanner test sample code prvided from Zxing team) ,but it works well.
So, I compare my projects and scanTest, but I can't find any difference.
What can I do to solve this problem?
You can only include iostream in C++ or ObjectiveC++ files. If your case is the latter, the file suffix needs to be .mm. So, for example, if your controller class imports QRCodeReader.h and is named MyController.m, it should be renamed MyController.m → MyController.mm.
Yes Right. This post helps me in understanding this concept a lot.
We make error when we are importing QRCodeReader.h into .m file of the project. Instead of this change the extension of the file to .mm file.
it will include iostream file in the counted.h file of your project.
thanks guys.
I am researching on Abode's RMSDK for iOS. I ve the SDK with all the library files. There is a sample project given in that SDK which works fine. But If I include the lib file in my own sample app its is throwing a linker error. Can any one help me out in this. Is there any sample code that i can refer regarding this SDK.
Thanks in advance
You can try to add reference to a rmservice project insteed of using lib file.
Then, you must verify all paths described in project settings is correct. I've had to placed my project in same folder of rmservice so that I don't have to change any setting.
If you still want to use it as a lib, you should perform two actions:
1) Add the lib in the build phases, on the Link Binary with libraries area. Be sure to select your target on the left side, not the project.
2) In your build settings on the Library Search Paths you should write down the path where the library resides.
For iOS, if you are doing RMSDK11, then follow the book2png in samples folder, this will allow you build you own application.
If you are doing RMSDK10, then you probably will run into 32/64 bit support problem.
I have found an existing open source library that I would like to include in my iPhone project (the unrar source code found here: http://www.rarlab.com/rar_add.htm ).
I have compiled this source as a linked library on my Mac with "make lib" which creates the libunrar.so file just fine.
These are the makefile settings for that target:
lib: WHAT=RARDLL
lib: $(OBJECTS) $(LIB_OBJ)
#rm -f libunrar.so
$(LINK) -shared -o libunrar.so $(LDFLAGS) $(OBJECTS) $(LIB_OBJ)
Obviously I can't use this on iPhone but I imagine I should be able to compile with different options to make a static library that I can use.
Do I:
Compile it on the Mac with different make options then drag the resulting library (some kind of .a ?) into my xcode project?
or
Drag all of the source code into my xcode project and create special targets of some kind to create it?
or
Something else entirely different?
I've been working on solving my unrar problem for a couple of weeks now and I believe using this library will give me the best results but I just don't know the final steps to make use of it.
Thanks for all advice.
I think that you'll probably want to do the easiest thing first, create an empty iPhone project and bring all of the code into it, just to see if it will compile.
If so, you may want to use the empty project to aid in the development of an Objective-C wrapper, once that is complete you can bring the code into your existing project for integration and testing.
If it looks like this is code that you would like to use with other projects, or you are feeling giving and would like to provide an iPhone port of the code, go ahead and pull this together into a library.
Here is a site that documents the process.
I realise that the view/controller stuff will be different between Mac and IPhone apps but the model code may well be similar/the same. So whats the best way to organise a project(s) so that the model code is/can be shared?
Copy/paste - just duplicate it and manually keep it in sync
Have 2 xcode projects point at the same workarea - one for Mac and one for IPhone and share the code.
Common library - presumably you can't do this (or can you)
Thanks for any tips.
There are a few ways to do this. The first thing you can do is is create a project that builds as a framework on Mac OS X. Since you cannot use frameworks on iPhone, you can make static library target that contains the same code files. That basically works, but the header paths will be different. If you want the header paths to be the the same (i.e. <Myframework/MyFramework.h>) you will need to modify the the install path of the static library headers so that they are copied into "$SDK_ROOT/usr/local/include/MyFramework", and make sure /usr/local/include is an included header search path. You will then need to install the library and headers into each SDK_ROOT.
I started out doing the above, but I found it to be a royal pain. So I ended up doing something that is a variant of #2. Basically, I get the header paths to be equivalent by making a directory named "Externals" in my iPhone project root, then a directory named with the appropriate name ("MyFramework") in the externals folder. That is the folder I copy I drag the framework files into.Findally I add the Externals folder as a system header path (which is admittedly sort of a gross hack). You need to manually add new files to the iPhone project, but I have found that to be less of a pain the installing static libs into my build root.
I'm not sure if the suggestion from the previous answer would work. If you look at my previous question, you'll see that I've failed to load a custom framework on the iPhone even though the framework works fine on Mac.
I would go with method 2.
You could develop your application in JavaScript, CSS, and HTML. You would use the WebView and UIWebView objects on the Mac and the iPhone respectively. You can do pretty much anything you want in the WebView objects, even make calls down to Objective-C.
The QuickConnectiPhone installer, found here https://sourceforge.net/projects/quickconnect/, installs QuickConnectMac and QuickConnectiPhone templates into Xcode.
This way you can quickly create an application in one environment and then migrate the view to the other. In fact the QuickConnect framework is highly modular.
If you don't want to develop in JavaScript the same modular framework is found on the Objective-C side of the templates installed.
It should make it much easier for you to do what you are attempting.