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.
Related
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.)
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. :)
I successfully built boost for iPhone thanks to this:
http://gitorious.org/boostoniphone/boostoniphone
However, I'm having trouble linking to it in XCode 3.2.6. I get errors such as:
error: boost/unordered_map.hpp: No such file or directory
I have dragged the "build" folder containing the .a and .o files for arm6, arm7 and i386 into "frameworks", and added the "include" folder which contains the "boost" folder which contains all the headers, to User Paths in the build settings, all to no avail. I would be grateful for some precise, step-by-step directions how to link to this library (i.e. please presume I'm kind of stupid! Which may actually be the case!) Other postings I have found on this subject are rather vague in terms of concrete actions that need to be taken. Thanks in advance for any help.
OK so I worked it out. I will leave aside my feelings of intellectual inadequacy. For those who may have the same problem, here are step-by-step instructions.
First, you must have compiled boost on iPhone using the code and instructions from the boostoniphone project.
Navigate within the "boostoniphone" folder to the "framework" folder.
Click on the "boost.framework" folder in that location, and drag it into the main xcode window, in the left hand side column, into the "frameworks" group (along with all the other frameworks, i.e. Foundation.framework, UIKit.framework, etc.)
That's it.
If you added any build settings while trying to get this to work, remove them.
Note to self: next time, study the example project and copy its settings.
I am facing some compilation issues. In my iPhone app I am using some external library which I have placed in my Frameworks folder. But both these ".a" files and ".h" file comes in red color and they are not getting compiled. Any clue what I am doing wrong here.
It gives errors like not able to find classes of these external lib.
If they are red. Then those files are actually missing from your iPhone project. In order to fix this. Re-download the library (.a and .h) files, then add them into your project again.
I would recommend deleting the "RED" files first, and then re-add the files again.
If you're still having problems after following this. Drop a note.
Hope this helps...
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.