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
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 have a problem.
I have a XML and a project (XCode 4.1).
I must build my app with a XML file into this.
Now, where i put a XML file in my project?
In the XCode 3 there is a resource folder but now i haven't this.
Thanks
There should be a Supporting Files folder in your project. You might organize any extra files in this space.
You can put the XML file anywhere you like, so long as you subsequently make Xcode aware of its whereabouts. However, the most straightforward way is probably as follows:
Either:
Make a new group by going to File->New->New Group or
Use the existing Supporting Files group.
Drag the XML file into the group. Xcode will then present an add file sheet. Make sure that "Copy items into destination group's folder (if needed)" option is selected and your target is checked in the "Add to targets" list. Click "Finish".
That's it. Xcode should automatically add the file to the project and include it in your app's bundle.
Should you need to add the file "manually", you can select your project in the Project section of the Navigator pane (press Cmd-1 and select your project at the top left), select your target in the list (just to the right), select "Build Phases" from the tabs at the top and add the file to the "Copy Bundle Resources" build phase.
Just put it in Supporting files group.
I think this should help you.
I don't think I'm including the FMOD library correctly. I'm getting the following XCode error:
expected specifier-qualifier-list before FMOD
I'm using XCode 4 and the latest version of the FMOD library. I went into the "Link Binaries With Libraries" section in XCode and added libfmodex_iphonesimulator.a.
Any ideas on what I could be doing wrong?
Thanks!
Here is a step-by-step process for getting FMOD running in an iOS application:
File -> New Project
iOS -> Application -> Window based application
Choose name and location (I used 'test' and the FMOD examples directory as the location)
Assuming you named the app 'test', rename 'testAppDelegate.m' to have the extension '.mm' to allow C++ code.
Edit 'testAppDelegate.mm' to have #import "fmod.hpp" at the top.
Project -> Edit project settings (ensure Configuration at the top is set to All configurations)
Go to "Other linker flags" and type in -lfmodex_$PLATFORM_NAME
Go to "Header search paths" and type in ../../api/inc
Go to "Library search paths" and type in ../../api/lib (now close settings).
Right click on the "Frameworks" group on the left, choose Add -> Existing Frameworks, then choose 'CoreAudio.framework'
Repeat step 10 but choose 'AudioToolbox.framework'
Add FMOD code to 'testAppDelegate.mm' as needed, see playSound example for reference code.
After you link the appropriate library make sure you drag the 'inc' folder with all of the .h files into your project somewhere, that was my issue. Also, make sure you include AudioToolbox and CoreAudio if you did not already, and make sure to include fmod.hpp and fmod_errors.h in your view controllers header.
When I run the Application then warning display below,
Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'UserDefinedLocalization-Info.plist'.
I had this issue after I rearranged the underlying file structure of my project. Xcode4 has moved things around though and most online help to this problem is Xcode 3 specific, so this is how you solve this in Xcode 4:
Click the project icon in the Project Navigator (the blue root icon)
In your main pane menu you should be able to choose between your project or targets, select the target
Select "Build Phases" in the top menu
Open the "Copy bundle resources" item
Remove your plist file from there (your plist file should not be copied as a part of the bundle)
In xcode, right click the UserDefinedLocalization-Info.plist file, select Get Info. Go to the Targets tab and remove the checkmark in front of your target.
The info.plist is a special file and must be treated in a special way. It's not allowed to add it to the app in the normal way.
Lets say I have a bunch of PSD's and other large files that arent being used in my xCode project... Do those get added to the app when I compile? Do I need to store those somewhere else?
I think you can remove them from your target's "Copy Bundle Resources" if you don't want them in your .app file.
By default, they will be included. If you don't want that, then do the following:
In the Xcode project window, select all the resources you don't want included.
Hit the big blue i button on the toolbar.
Go to the Targets tab.
Uncheck your app's target.
Incidentally, this also works if you have a code file you don't want compiled in.
If you want to make sure, go to your build directory and open the .app package and see if the files are in there. Right-click on it in the Finder and choose "Show Package Contents"