Add source code as a library in Xcode4 - objective-c

I've got some source code (.h and .m files) that being developed by someone else.
I need to add it to my project as a (static) library Or even to add it as a source files that to be used by my own source files..
When I copy and past the folder containing the .m and .h files into my project I got a link error.
How to do that?

Maybe this tutorial will help you:
Using static libraries with Xcode

Related

Xcode cannot find header files when files added in folder reference mode

I am trying to add many Objective-C files to my Swift project with folder reference mode that means when I drag and drop my files into project I am selecting "Create Folder Reference".
This is because all of my obj-c files use #include "/folder/folder/folder/" for example. These files are generated with j2objc project.
Now my problem is when I want to #import or #include some .h of these files in myproject-Bridging-Header.h Xcode can't find the header files.
I use #import "/folder/folder/folder/" like generated files but no chance.
I add $(PROJECT_DIR)/ in build settings - search header paths but it does need to write path completely like $(PROJECT_DIR)/folder/folder/folder/.
Is there any way to set main folder and Xcode find subfolders ? Or do I need to write every path separately ?
I found the answer after many days by myself!
When I drag and drop my files to my project in Xcode in mode "Create Folder Reference", just a reference to the files is added to Xcode and the files were in their folder where in my Mac.
I resolve this problem by add files to project's folder manually and then drag and drop from that location to Xcode. After that, I could access my file by its address in myproject-Bridging-Header.h like #import "/folder/folder/folder/file.h"

Can Swift.h file be imported in pch file?

I'm trying to use swift in an Objective-C based project. It seems that ProjectName-Swift.h needs to be imported in every .m file which doesn't sound good. Can it be imported in the ProjectName-Prefix.pch like UIKit/UIKit.h so that I only need to type once in the project?
I've tried this way, but .pch cannot find the header file. Is there an alternative attempt?

Bridging File Not Found

The bridging file is added, but keeps showing the error.
My Bridging Header File is correctly setup because the other imports are successful.
I would advise you to use CocoaPods to handle external frameworks. Here is SlackTextViewController. If you still want to use copied version, make sure you add the files to your project. Try copying the files to your project folder using Finder and then use Xcode File -> Add files to "YOUR_PROJECT"

How to link third party libraries properly in iOS

I'm new in iOS development, and met this library linking problem in last few days.
I was trying to use GMGridView in a project, but cannot make it working.
This project is shipped as static library, so I just drag the xcodeproj file in my project. Then I added libGMGridView.a in Link Binary With Libraries, GMGridView in Target Dependencies. I also added the path in Header Search Paths.
However, Xcode still report .h file not found error when I tried to import GMGridView.h.
Could anyone give me a hand on this? Thanks in advance!
Had the same issue!!! Made it work!!!!
soooooooo:
copy GMGridView folder from https://github.com/gmoledina/GMGridView to your project dir
in xcode right click on any file group and choose add files
find GMGridView folder in your folder dir and choose GMGridView.xcodeproj - (dont copy, create groups not folders, add targets)
go to your project targets - search - HEADER_SEARCH_PATHS add- GMGridView/**
select Building phases in settings - choose target dependencies and add GMGridView
select Building phases in settings - link binary libraries and add libGMGridView.a
import should be:
#import "GMGridView.h"
#import <QuartzCore/QuartzCore.h>

objective-c, header file not found

I want to use InAppSettings in my iOS project. So I copied the InAppSettings folder into my project folder.
When I type
#import "InAppSettings.h"
xcode auto completes the import correctly. But after that it shows me that the file was not found. I copied the InAppSettings folder into the root folder of my project.
The file structure:
I want to import it in FirstViewController.m
Any idea how to fix this?
Last time the problem was that i imported the classes into eachother which makes XCode give that error. Could that be it?