How to compile Object(*.o) files added with iPhone app? - iphone

I have created a simple native iPhone app. This project contains with c,c++ source files for doing some operations. Its radio tuning app, thats work fine. I want to give a source code to some one, and want hide all of source code c,cpp file (Because strangers don't want to see my code). So what i did is , i have compiled iPhone app and collect all (.o) files from build path and added to my resource folder.
For example if my application have these two files
radio.c
radio.h
when i build radio.o present on build path directory. my build path is (/Users/Macuser/Projects/Radio//build/Radio.build/Release-iphoneos/HDRadio.build/Objects-normal/armv7/radio.o).
So i copied radio.o file and added to my source code directory, and i removed the radio.c and radio.h file. When i compile it gives a error, radio.h file not found.
What could be the problem here? please let me know. Thanks in advance..
Note:
When i add radio.h file to my project it compiles successfully. I don't want to see my radio.h and radio.m file. is this possible?

There must be some other file in your project that is importing or including radio.h. Your .o file is used for linking but import/include dependencies are resolved when compiling the source. (A .o file is not source.)
If you don't want to provide .h files, the way around that is to create a static library to contain all the .o files that depend on each other. (However, to call any functions inside your library, the person still needs a .h with the declaration of public functions.)

Related

How to change my project API class extension

I created a firebreath project with "OpenOnDesktopPlugin" name. I need to change the "OpenOnDesktopPluginAPI" extension from .cpp to .mm, because I need to add some objective c code.
I added the "Mac/[^.]*.mm" line to my ".cmake" files.
The problem is, when I change the extension to ".mm" to my "OpenOnDesktopPluginAPI.cpp" and I run the "prepmac" command, the file is not displayed in my firebreath project tree, but if I go to my finder, the file is there.
You need to edit your CMakeLists.txt file to tell it to include *.mm files from that directory as well.
"Mac/*.mm" won't work because your OpenOnDesktopPluginAPI.mm file isn't in the Mac/ directory.
Is this supposed to be a cross-platform project? if not, then you're okay; if so, then you will probably want to subclass your JSAPI file for mac and put that in a .mm file in your Mac/ directory; Mac/projectDef.cmake is the cmake commands specific to mac. CMakeLists.txt is the cmake commands that are cross platform (unless you don't care about anything but mac, in which case you can put it in both places.
Then of course (if you create a mac-specific subclass) you'll need to either subclass your plugincore class or use "#if FB_MACOSX" preprocessor macros to decide whether to return the mac specific version or not. There are lots of options for how you can do all of this, of course, but this is the way I'd do it.
Hope that helps.

Xcode 4 embedded resource prevention

In XCode4, is there a way to have a 'resource' (i.e. a CSV used to load a sqlite database) that is there for project purposes, but not have it compiled into my project? So my final app doesn't include it? I can't seem to see to to have this facility.
Thanks
Assuming you do not want the file get into your .app file, One solution i can think of is, do not include 'Target' when adding the file to the project. If you want to exclude your already added file then
Choose the target
Go to Build phases
Expand copy bundle resources
Select your resource file and remove it.

How do I add files to the Copy Bundle Resources build phase with an Xcode4 Project Template

I'm working on an Xcode 4 project template and I'm struggling with controlling the files that get added to the Copy Bundle Resources build phase--header files get added that I do not want to be copied into the project bundle and a file that I do want to be copied does not appear in this list (a custom .framework file that contains both the static library and image resources).
It seems like Xcode automatically builds contents of this build phase from the Nodes section in the project template; if it's a .framework, it automatically gets added to the linked libraries, if it's a .m, it automatically gets added to compiled sources, and everything else gets added to the Copy Bundle Resources.
I'd be grateful for any direction on this one!
Update:
To clarify, I'm attempting to create an Xcode project template that, when used, creates a new Xcode project that includes the specified files from the template in the Copy Bundle Resources build phase.
This should help. After the Class-Resources key-value pair, you can add files somehow. I couldn't figure that out but I'm sure you can find it somewhere.
EDIT: Actually, i think an easier way is to in the Definition part, after the Path key, add a TargetIndices key (an array). With some experimenting you should be able to find out what value to put on one item of that array to put it in the Copy Bundle Resources build phase.
Yes, Xcode tries to manage this for you. If after adding a file, it did not did what you want, then change it. It's guesses are "usually" correct "most" of the time. :)

iPhone: Cannot get simulator to generate .gcda profiling data files

I'm attempting to profile my code using the iPhone simulator. I've enabled Generate Test Coverage File and Instrument Program Flow and added -lgcov to the linker flags. According to everything I've read that should be all I need to do in terms of setup.
Update: Generate Test Coverage File triggers the -ftest-coverage flag and Instrument Program Flow triggers the -fprofile-arcs flag. I've checked the build logs and they are being set when compiling.
Executing the program I can see the .gcno files appearing along side the .o compiled code in the build/.build/Debug-iphonesimulator/.build/Objects-normal/i386 directory.
But when I run the app in the simulator I do not get any *.gcda files appearing.
My understanding is that these files contain the data from the instrumentation. But I cannot find them anywhere on the computer.
I know they can be produced and appear along side the *.gcno files because I have an old trashed buil directory which does have them. I just cannot figure out what I have to do to get them to appear and record the run.
Any help appreciated.
I hope this link would give you some idea. Exploring the link I found
The .gcno file is generated when the
source file is compiled with the GCC
-ftest-coverage option. It contains information to reconstruct the basic
block graphs and assign source line
numbers to blocks.
The .gcda file is generated when a
program containing object files built
with the GCC -fprofile-arcs option is
executed. A separate .gcda file is
created for each object file compiled
with this option. It contains arc
transition counts, and some summary
information.
So may be you are building with some wrong settings. The information is mentioned on http://gcc.gnu.org/onlinedocs/gcc/Gcov-Data-Files.html#Gcov-Data-Files
This link may have the answer, basically gcda files are not generated until your app exits properly. It gives two possible solutions:
completely quit the simulator
add this to your plist (but not for release builds):
<key>UIApplicationExitsOnSuspend</key>
<true/>

Xcode iPhone app package missing files

I'm struggling to figure out what exactly it is that decides which files go into the .app-package when compiling an application in Xcode. I've noticed that most image files go there automatically, while others like yaml-files or psd don't, and I cant find anywhere to set this. So, how do you do this?
Look at the build phases for your application target. You'll find that recognized image files were added to the Copy Bundle Resources phase. To copy files of a type that Xcode doesn't recognize, you can add a Copy Files build phase.
If all else fails, read the documentation.