I'm trying to create a static library in xcode 4, but i don't know how to generate the .a file. I added files to the library (.h .m) files, but when I run the the project the .a file is never generated. Do I have to do something special to generate this file? I'm following the steps in this
tutorial.
Thanks in advance.
The .a file was the product of the project file's target if memory serves.
It should show up under the "Products" group of the project navigator. If it is not red, you can control-click it and choose "Show in Finder".
Related
How can I export an MVC project from Xcode to a single file .framework.
The project is very big, around 1 GB and the company want to embed this big project into a single library.
Can you help me to do this ?
Because on internet I can’t find any solution for a big project, just for a single file.
Thanks !
Edit: Here is a screenshot with my structure:
Add new target CocoaTouch Static Library (File -> New -> Target -> Cocoa Touch Static Library)
Add the project files to the target
Select a file which you want to add in project navigator pane then in File Inspector (View -> Utilities -> Show File Inspector) in the section "targets" check a checkmark.
Build
I recently upgraded to XCode 4 and adjusting. I have a folder called "Unused" in which I keep some .h and .m files. They are basically code which are no longer associated with the project and I keep them because they serve as a reference. The compiler doesn't look what it sees in there so I change the .h and .m files to .h.txt and .m.txt. However, I get this warning:
warning: no rule to process file '$(PROJECT_DIR)/Classes/AddViewController.m.txt' of type text for architecture i386
Does anyone have any solution for this?
Thanks.
Select the target in XCode, then in the Build Phases tab, under Compile Sources, remove the unused files that you don't want. XCode will only compile the files listed.
If you don't want the files to link, you can select the relevant file on the left side project navigator, then go to your right side bar and select the File inspector (left most icon on top right bar), then scroll down to "Target Membership" and unclick the checkbox so the file is not associated with any of your targets.
I have a project (AQGridView) that compiles to a static library, but I can't seem to add it to my project.
Dragging in the project to my project creates a workspace, and if I try to link the libAQGridView.a file from the DerivedData directory it doesn't recognize it as a library. I'm not sure what I'm doing wrong.
This is the AQGridView project. Does anyone know specifically how to use it in an Xcode 4 project?
I do this as follows:
Drag in the static library project. If you have the static library project open in Xcode, close it now.
Select the main project in the project navigator (the project I'm adding the static library to) and in the editor, under the header TARGETS in the left-hand column, select my main project's target and navigate to the Build Phases tab.
Click the "+" for Target Dependencies and add the library icon target dependency from the added static library project.
Click the "+" for Link Binary with Libraries and add the library icon that is under the folder "Workspace".
It may also be necessary to enter a Header Search Path for the headers of the static library project if that is how the headers are linked in the static library project itself.
If you don't see the static library project as nested under the main project in the main project's project navigator, the most likely reason for that is that the static library's own Xcode project is still open. Quit Xcode and open up the main project that has the nested static library project in it without opening up the original static library project itself, and you should see it appearing as a nested project in your main project.
Xcode menu > View > Utilities > File Inspector
Select the static library file, and then set 'File Type' as 'Mach-O object code' in 'Identity and Type'.
Workspaces are supposed to make this easier, but I don't know that they do. The way I do it is create a workspace, add my main project, add my library project. Then go into the main project's build phases and add the library in the "Link binary with libraries" section and add the library. That should be all that is necessary, at least that's my reading, but it isn't. What I do is go into Xcode preferences, then to the Source Trees pane. Add a source tree that points to your static library's headers, then go back to the build settings for your project, then to the Header Search Paths key, and enter ${foo} there, where "foo" is whatever you called the source tree.
That's what works for me, though I don't know if that's the best or easiest way to do it.
Find your .a file in finder, and drag it into your project.
Select the 'copy items into destination group's folder (if needed)', and add your headers to your project.
Now, Xcode 4 should automatically link against that framework for you.
Here is what the library should look like in your project:
Follow Apple's documentation.
In brief:
Link your target against the library.
Add -ObjC to 'Other Linker Flags' (OTHER_LDFLAGS) under the target's build settings.
Also, I needed to add the library to the scheme of my main project since the library was not visible in the target's dependencies.
The Halle's answer works for me with one addition:
Check in Build Settings of the static library project the Private( or Public) Headers Folder Path value and copy it.
Add copied value to the client project Build Settings Header Search Path or User Header Search Path depending of the include directive you are using
If I include files in my Xcode project, how can I control or specify which files are included as a part of the application's bundle?
For example, all the PNG files I add to the project always wind up in the bundle. Conversely, the .m and .h files are not.
How can I control or specify which are or are not included?
If I through in something - like some random data file - how do I know if it gets built into the bundle or not?
Right click on the file (either class file or resource file) which you don't want to include, select Get Info. Go to "Targets" tab. Check/Uncheck the box near the target name, for include/exclude the file.
Notes:
1) header files are by default excluded from the target. Only source files (.m or .mm or .cpp, etc) & resource files (.png, .jpg & all others) are required to be include/exclude from target.
2) If you exclude any source file from target then by default it's header file will get excluded & that source file won't compile.
3) Similarly, if you exclude resource file, it won't be copied into the bundle & thus any reference in your code to that file, will result into the crash of the application.
You control what gets copied where during a build by controlling what's listed in the various Copy Files phases of the build target.
To control what is copied you can do the following:
Click the image you're concerned with
From the File menu select the Get Info option
Select the Targets tab
Select the targets you'd like to have the resource copied to, or deselect to not copy
In general, files (like .h & .m) are the exception. If Xcode doesn't know something special to do with them (e.g., compile), they're just included.
At some point, I thought Xcode would run a special rule on even PNGs (to optimize their size).
I have created one library with "Utility.h" file. I want to add that custom library to my another iPhone application. I have added the library to project "frameworks" and I have drag the library to "Library Search Path" it shows like "$(SRCROOT)/libUtility.a". I have imported the header file as #import "Utility.h". But I am getting below error message.
Utility.h No such file or directory.
Please any one help me to resolve this issues.
What is my mistake.
You have to drag the Utility.h file to your project as well along with your library.