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

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/>

Related

Not able to archive Swift app and upload to the app store without "Your app can't contain standalone executables or libraries" error

After trying to investigate this, I've seen this in a few other places, namely the Flurry Analytics framework, but their solutions don't seem to apply to my issue.
The error is referencing a file with my app's name and a .o extension
My build log shows it twice under two "CompileSwift normal arm64" sections:
"/Users/Admin/Library/Developer/Xcode/DerivedData/App_Name-fglhmhjmskcjuedbcbpinrnjxaey/Build/Intermediates.noindex/ArchiveIntermediates/App
Name/IntermediateBuildFilesPath/App Name.build/Release-iphoneos/App
Name.build/Objects-normal/arm64/AppNamePrefs.o" -o
Searching for anything .o in Xcode turns up nothing, but maybe I could navigate to what it shows in the build log, but I don't know how that would solve my issue, aside from attempting to delete it, but I'm not sure if it's the right approach because I have no idea what this file is for.

Error on a .exe that was running perfectly before being compiled

guys,
I just finished a particular code in MATLAB R2014a that reads and write into multiple text files and saves an image inside the same folder of the script. The script runs perfectly, but the compilation executable does not, so I believe that it has something to do with the PATH that the executable is trying to use to run, I don't really know.
The error was the folllowing:
That's the second read function in the code that tries to read a file and it's possible to see that the code was already successful doing a read/write operation, since a .txt is created.
Just to keep it simple, I didn't use any global paths to the files and tried to keep them inside of the script and executable folder.
I don't have a lot of experience compiling stuff, so I just used deploytool and hit run to test it, so I would love to hear some insights about the possible cause of the problem.
Thank you in advance for the help!
MATLAB doesn't include every file on your PATH when it compiles. It tries to detect additional files that may be accessed when running the code in your application's main file, and include those in the compilation, but it isn't always 100% successful (I'm not sure exactly what conditions it's unable to detect).
After you have run the deploytool once, the full list of files it has detected in this way will be listed under Files required for your application to run. You can add files to this list (whether or not your project has already been compiled) using the "+" icon in the corner of that section.

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

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.)

Minimizing the use of Xcode - how to quickly build and go from source code?

I realize I have to use Xcode to develop for the iphone, but I'm trying to build apps from raw source code generated outside of Xcode.
For example, I would like to "Build and Go" the apple demo "TheElements" (here). (I use this example because it has no .xib files - so Xcode is not needed for the UI).
It works to just unzip and open the .xcodeproj in there, but what if I had generated this code elsewhere and haven't yet used xcode? I.e., I have a directory of files (the contents of the .zip without the xcodeproj stuff):
./Default.png
./Images/*.png
./Classes/*.{h,m}
./Icon.png
./main.m
./Elements.plist
./Info.plist
./TheElements_Prefix.pch
Can I quickly (automatically?) get this built and running in the simulator?
I guess the question also relates to what information is really stored in the xcodeproj. Ideally, there would be some scriptable method for generating the project.pbxproj file, but sadly can't find this.
You might think of the Xcode project file as a glorified Makefile (if you're coming from the Unix world) or a VC solution file (if you're coming from Windows). It's a description of the dependencies between components and the steps required to build, link, and deploy those components. There is no more fundamental "Build and Go" than that.
On the iPhone, Xcode is required to build a viable application (technically, you could chain up the command line invocations used by Xcode—check the build log—but you'd be pretty crazy to bother). You can use a command line invocation (xcodebuild) instead of using the Xcode GUI app, but you still need a project file.

xcode build configurations search paths

my iphone app builds fine in debug configuration, but when i change it to release, i get hundreds of errors, starting with "CoreServices/CoreServices.h: No such file or directory" in AudioFileComponent.h - part of the AudioToolbox framework.
i can't find where in the project/build settings is responsible for this.. thanks for any help.
I would recommend the following:
Open up your debug target's build settings by right-clicking on the target, hitting "Get Info", and selecting the Build tab.
Select All (Command-A) so the entire contents of the Build setting panel is selected, then copy it to the clipboard.
Paste the contents of the clipboard to an empty text document
Repeat steps 1-3 for the release target of the same project
From there you can use a diff utility or some other method to compare the contents of the two files, which will show you the settings that differ between the two configurations. Some of them will make sense (e.g., optimization settings) whereas others will not. Most likely there is a setting that differs between the two that will resolve your problem.
Another thing you can do is build one of your source files in debug mode, and in the Build Results window copy the contents of the command line to a text editor. Repeat for release mode. Then, replace each space in the command line with a newline (\r). From there you should be able to do a rough side-by-side evaluation of the differences between the two compile instructions, and may be able to figure out what's missing from that.
In general this helps you get a better feel for exactly what XCode is doing under the hood to build your project, which is a good strategy to practice no matter what tool you are using for development.
i think the problem was because i had the audiotoolbox package in the wrong place, it wasnt in system/library/frameworks like it should have been. (this doesnt explain why it built ok in debug though)