How to invoked methods of external .h files in iphone - iphone

to all
In my iphone game I want to add external .h and .a files. I am adding them by using add project option given in Xcode. It get added but I want to invoked the methods given in the header files. As per instruction given to us we have to call one method which is declared in external header file. We have to call that method inside AppDelegate's applicationDidFinishLaunching method . But at the time of compilation it gives one error that is referenced from: and symbol not found. I don't understand how to invoked this method and how to get referenced for the method.
I am sending one link please see that. The same problem with my application is coming.
http://forums.macrumors.com/showthread.php?t=443437
In that three screen shots are given by some toddburch on Jan 24, 2009, 07:37 AM
The same error for my methods are also coming but my code is in Cocoa with objective-c not in ruby.
If anyone know the solution please reply me As soon as possible.

The .h is not enough. You also need the implementation, either source code or compiled framework.

Do you have access to the source code itself? Try dragging the .h and .m/.c files from the framework directory directly into your project. It's a little messy, but I think it will solve your problem based on the error messages you are getting. You can put them all in a group so your project doesn't look so crowded after you drag them over if you like.

You currently have two files
A *.h header file which describes the classes and functions available in your third party library
A *.a static library file which holds the pre-compiled code for the functions described by the *.h file.
Assuming you've got to the stage where you can #include or #import "xyz.h" and compile your application, the bit which is missing is linking your executable with the *.a file.
The symbol not found error message is the linker telling you it knows some of your code is calling a particular function, but it can't currently find another code module that provides an implementation of that function.
One thing to check is that your *.a file is correctly configured within your project to be passed to the linker. One way to do this is to expand the "Targets" section of the main XCode window. If you drill down into the section representing your application you should see a subnode labeled "Link Binaries with Libraries". Your *.a file should be listed, if it isn't one way to add it is to simple drag and drop the file into this section.

Related

How to retrieve bridging headers that has been lost

I was trying to put a facebook login in my app. I'm also checking some of the tutorials that'll help me to do this. Then i have created a header file that i also delete since that i wasn't able to accomplished the tutorial that i'm watching. Then all of a sudden, i'm having an error that stating...
Briding Header 'Users/mac/Desktop/App
Files/myApp/myApp-Bridging-Header.h' does not exist
I don't know why is that happening. I try to delete my .swift file and replace it with the same name then it still having an error. I even try to make a .swift file with a different name but still having an error as well.
In build settings.. in “Swift Compiler -Code Generation”—> Objective-C Bridging Header — “reset the Path of Bridging header file”
How to create a Swift Bridging Header Manually
Add a new file to Xcode (File > New > File), then select “Source” and
click “Header File“.
Name your file “YourProjectName-Bridging-Header.h”. Example: In my
app Station, the file is named “Station-Bridging-Header”.
Create the file.
Navigate to your project build settings and find the “Swift Compiler
– Code Generation” section. You may find it faster to type in “Swift
Compiler” into the search box to narrow down the results. Note: If
you don’t have a “Swift Compiler – Code Generation” section, this
means you probably don’t have any Swift classes added to your project
yet. Add a Swift file, then try again.
Next to “Objective-C Bridging Header” you will need to add the
name/path of your header file. If your file resides in your project’s
root folder simply put the name of the header file there. Examples:
“ProjectName/ProjectName-Bridging-Header.h” or simply
“ProjectName-Bridging-Header.h”.
Open up your newly created bridging header and import your
Objective-C classes using #import statements. Any class listed in
this file will be able to be accessed from your swift classes.

including a header from a project into a static library

I have a subproject (static library) inside my project.
As this static library may be used by a bunch of app, I have this config.h file on my project that contains the app configuration. The static library must read it.
The problem is that adding
#import "config.h"
on the static library fails, because the file cannot be found.
I could add an absolute path to my project root on the search headers, but I want to make this not hard coded because this static library will be used by other projects. Another problem is that I cannot use relative links like ../.., for example, because the static library is on another volume.
Including $(SRCROOT) on the search paths of the static library will give me the root for that library not for the project using it, that is what I want.
How do I solve that?
Just pay attention to my question. I am inside a static library that is used by a project. Config.h is out there in the project. I want to import that config.h on my static library.
If there is an easy way to do that, please tell me.
I have uploaded a sample project to here and here, so you can see my pain.
thanks
One way, somewhat of a hack, is to add a Run Script to each App's Build Phase, as the first item, and have it copy Config.h to some known place - /tmp/Config.h, and your included library will look for it there. Since the file is copied on every build, it will always be proper.
EDIT1: So not pretty, but you can add a Run Build Script to just under the Dependencies in the library. Just add one and leave the checkbox set to show environmental variables. You can see this one set:
FILE_LIST=/Volumes/Data/Users/dhoerl/Library/Developer/Xcode/DerivedData/MyProject-fdzaatzqtmrnzubseakedvxmsgul/Build/Intermediates/MyStaticLibrary.build/Debug-iphoneos/MyStaticLibrary.build/Objects/LinkFileList
What you can see is that several of these have as the prefix the current project folder:
/Volumes/Data/Users/dhoerl/Library/Developer/Xcode/DerivedData/MyProject-
You can write some script there to get the prefix, then append the local Config.h file path, and now you have a fully qualified path to the Config.h header, which you can then copy to a known location in the library. I'm going to post on the xcode forum as there may be a better solution - there use to be in Xcode 3. I'll update this if I get anything substantive back.
EDIT2: Try This:
1) Click on the library, click on Build Phases, add a Run Script Build phase by tapping bottom right '+' button
2) Drag it so its the second item in the list (below Target Dependencies)
3) Change the Shell to "/bin/ksh"
4) Paste this in, after editing it to have the proper files/paths:
# Get the Project Name (assumes upper/lower/numbers only in name)
PROJ=$(echo $BUILD_DIR | sed -En -e 's/(\/.*\/)([A-Za-z0-9]+)-([a-z]+\/Build\/Products)/\2/p')
# Use this variable to construct a full path
FULL_PATH="/Volumes/Data/Users/dhoerl/Downloads/nightmare/"$PROJ"/"$PROJ"/HelloWorldLayer.h"
echo FULL_PATH equals $FULL_PATH
# Make Sure MyStaticLibrary is correct
echo PROJ_DIR equals "$PROJECT_DIR/MyStaticLibrary"
cp -f "$FULL_PATH" "$PROJECT_DIR/MyStaticLibrary"
5) This assumes that you put the library anywhere you want, but each App project has to havethe same parent folder (not much of a restriction - what I did in the past).
PS: When I do this kind of thing, I usually don't include an actual file of the app, but create a header for a class that is not instantiated in the library. Lets call this Foo. So in your library, you have Foo.h, and it has lots of methods that return info - the number of widgets, the location of some special folder, plists, arrays, dictionaries, whatever. The idea is the library knows how to get whatever it needs through this interface (class singleton, or just a class with class methods. YMMV.
PSS: anyone else reading this, it pays to create demo projects.
I'd go a different route. Make this config.h file part of the static library using compiler symbols in it to switch features. Then in your projects define those symbols depending on what features you need.

Static Library path nightmare from hell

This is the point. I have a subproject (static library) created. The library compiles well. No errors. When I include this library inside a project and imports a header from that library on the project the library fails to compile because it cannot find a path that belongs to itself.
After following a bunch of tutorials on the web on how to create a static library and embed that in a project, I don't know which one is the correct one, because I have tried all and all failed and some differ.
This is how the library is set:
STATIC LIBRARY
BUILD SETTINGS:
Public header folder path = $(BUILT_PRODUCTS_DIR)
Header search path = $(SRCROOT) (recursive)
BUILD PHASES
COPY FILES = 1 file, myLibrary.h that is basically empty (created by xcode when I used the static library template to start the library.
no ADD COPY HEADERS phase
MAIN PROJECT
BUILD SETTINGS
Header search path = empty
User header search path = $(BUILT_PRODUCTS_DIR) (recursive)
Always search user paths = YES
BUILD PHASES
Yes, myLibrary.a is on target dependencies
What amazes me is that the library compiles fine alone but when put inside a project, is unable to find a header that belongs to the own library.
NOTE: I have also tried to create a copy headers phase on the library making public all .h on that library, but it failed too.
This is an example of one error:
/Users/mike/Library/Developer/Xcode/DerivedData/MyApp-dnaimaovscreasadhmvgttwjnabc/Build/Products/Debug-iphoneos/include/myLibrary/ccTypes.h:39:9:
fatal error: 'Platforms/CCGL.h' file not found
#import "Platforms/CCGL.h"
I have lost two days trying to solve this nightmare.
any thoughts?
I have uploaded a sample project to here and here
After downloading your sample project, I had it working in a few minutes by making the following changes.
First, you need to add an entry for the MyProject target's Build Settings under Header Search Paths, so that the files such as HelloWorldLayer.h, which #import "cocos2d.h", know where to find that file.
Under the Header Search Paths, I entered ../MyStaticLibrary/MyStaticLibrary/libs/** like shown in the image below:
That solved the problem of the inability of the preprocessor to find the necessary source files from the MyStaticLibrary, for the MyProject project, but after compiling, I got an error about missing symbols. I needed to add the built libMyStaticLibrary.a to the Link Binary With Libraries step like shown in the image below:
After that, the project compiles fine.
(Not enough rep to post comment...)
Did you try specifically including the Platforms directory in the header search path? Presumably, Platforms is in the source directory, not in $(BUILT_PRODUCTS_DIR) so may not be searched in your current setting.
Regarding script to show you env variables, here's how I do it (open images at the new tab for better scaling):
Added dummy shell script
Observed its output at Log Navigator
As you can see, BUILT_PRODUCTS_DIR doesn't have any headers copied from the library. Either put headers there manually (strongly not recommended) or add search path to the location that you know the headers must be at:
Now as there were two headers cocos2d.h and MyStaticLibrary.h, cocos2d.h was successfully imported although it will have additional dependency.
The path ../MyStaticLibrary/build/$(BUILD_STYLE)-$(PLATFORM_NAME) will also (recursively) have public headers of the library.
After almost 5 days of a nightmare trying to solve that, I finally found this tutorial: http://www.youtube.com/watch?v=XUhLETxgcoE
This is the only solution that worked for me. The simplest and the best.
Thanks for every one trying to solve this.
Please try this…
step1: right click on the 'projectName.xcodeproj'(static library).Choose 'Get info' and copy the full path from(General->where)
step2: Paste full path to 'Header search paths' for your main project(Both Targets and Project )

Gsoap undefined references

I'm trying to use and web service with gsoap. I've already generated all *.h and *.cpp using wsdl2h and soapcpp2, included all libraries, at least I think so, but when I build the project it gives me the message of undefined references to a lot of methods. The thing is all methods are declared in soapH.h (the prototype) and in soapC.cpp (the implementation).
Any help will be appreciated.
It seems that you included some generated header files in your build, which should not. (e.g. the .h file generated from wsdl) There are descriptions in the comment section in each generated files, and you'd better read them to get familiar how to use them.
Also, if you use openssl, the library should also be included during linking process(-lssl)
Solved, All I need was the original header file, I was getting one from the wsdl.
In case anyone encounteres this problem: you do not have to include all the .cpp files in your makefile - some of them are included by the other. What you need also depends on whether you are building a client or a server.
Consult the documentation here to see which files are needed and for what.

problem sending mail from backend file not found iphone

i'm trying to use the skpsmtpmessage to send emails from backend. In the README.txt it says:
To use this in your app include the following files in your project:
SKPSMTPMessage.*
NSStream+SKPSMTPExtensions.*
That should mean that i have to include the .h .m files in my project. Now, after i've done that i get an error NSData+Base64Additions.h not found, so i imported the missing classes for this 'skpsmtpmessage' project but i get tons of errors like:
Undefined symbols for architecture armv6:
"_kCFStreamSSLLevel", referenced from:
-[SKPSMTPMessage parseBuffer] in SKPSMTPMessage.o
i get the same errors if i even remove the import lines. I cleaned the project but it doesn't help at all.
Has anyone used this library before? Have you experienced this errors before? I need some guide.
Thanks in advance!
Have a look at the header files for the project you've downloaded. You'll see this:
#import <CFNetwork/CFNetwork.h>
This means that the class uses the CFNetwork framework. You will need to add it to your project in Xcode and make sure that your target links against the framework.