Xcode 4 - Header file not found when including 3rd party static lib - ios

I am trying to check out Nocilla but I can't seem to get my test target to build when I include it. I cloned the Nocilla repo and built the static lib (targeting simulator) from source. I am linking the nocilla static lib to my test target.
I have all of Nocilla's public headers included in my project but for some reason Xcode complains that it cannot find headers which are located in the same relative location from which they are being referenced.
Trying to run my tests results in the following compilation error:
'LSHTTPRequest' file not found
Nocilla provides installation instructions which include using CocoaPods. I am not interested in using CocoaPods. Does anyone have any clues for me as to why my tests cannot find these header files? Am I missing a build step to ensure they are copied to the test execution location?
Thanks!!

You must set the User Header Search Paths for the project that wants to include the static library headers:
The exact location of the header files will vary on the relative location between the two projects of course.

Related

add module into ios framework, app get "module not found"

I have a swift framework project(let's call it Framework1), inside it use some 3rd party objective c files. I use module instead of umbrella file because of ambientlight's answer in this post
I create a subfolder(let's call it MiscModule), put module.modulemap under that folder, include all oc headers, and configure the Build Setting. The framework build fine, I can get framework build.
But after I put Framework1 in app project, build the app. It complain about "Module MisModule not found".
I saw the Framework1-swift.h file have an line of "#import MisModule". I had thought MisModule is build into binary in Framework1's bundle.
Do I miss something?
When you built it, those files that in modules did not be embedded into the framework, it would change the relative path to absolute path.
such as import YourModule change $SRCROOT/... to User/YourProject/
so, not use custom module in framework, it will change the import paths to
absolute path.
Your can build a framework for the oc files.
Sometimes cleaning Xcode, restarting both the simulator and xcode, and then trying to run again helps. If worst comes to worst, try heading into finder and doing a deep-clean. Delete ~/Library/Developer/Xcode/DerivedData/

How to make XCode add the linked project headers and implementaion files to the static library and framework

I have a static library project and in that project I linked a .xcodeproj to the source code so I can update easily actually and to not copy and paste files in the static library project for easy update.
The purpose thought it's to embed this .xcodeproj with my code into the result static library or .framework that I will build using a script.
Although I can see that there is nothing added in the compile sources or the copy header files which I added. If I try to add with drag and drop files from the linked project to my static library build phases copy header section it copies the file to my project again, but I don't want this.
And if I add a header file #import to one of my public headers and try to use the static library to the client project it complains that the header is not found!
So, in the end, what I want is the whole linked project files to be copied in the resulting static library or .framework with the scripts and target I have.
Is this possible to achieve, I think I miss some project setting that I'm not aware about that will see and copy all header and implementation files to my result static library or .framework?
Is my approach overall correct? I don't think that there is no option to use a linked project in a static library and embed it when the build is happening since I am using it in my project!
I could add the .framework of the third party component too and merge to my static library. I have created this question earlier today. Is it possible to include a .framework in a .framework and how?
Regards.
Not sure if your #import-not-found issue is a linker issue, but...
Make sure to use the -ObjC flag in "Other Linker Flags" in the library's Build Settings. This gets the linker to build everything in the library.
Mentioned here:
https://developer.apple.com/library/ios/technotes/iOSStaticLibraries/Articles/configuration.html
And also make sure you link in the library in the build settings for the project that needs it.

iOS static library depending on other static library

I have created a static iOS library using this tutorial.
The library itself depends on the SocketRocket library.
SocketRocket is included as #import <SocketRocket/SRWebSocket.h>.
When I build the library, everything works fine.
However, if I integrate my library into my sample project, the following error is thrown.
Lexical or Preprocessor Issue
'SocketRocket/SRWebSocket.h' file not found
How can the library build, but later fail to find the file in the sample project?
UPDATE
The Library has its Header Search Path set to "$(SRCROOT)/Vendor/SocketRocket/", the sample project has the Header Search Path set to "$(SRCROOT)/Vendor/MyLibrary/". If I set it to "$(SRCROOT)/Vendor/MyLibrary/**" it finds SRWebSocket.h and builds successfully. However, this includes all the SocketRocket Headers into the sample project as well and I don't want that.
UPDATE 2
I narrowed it down to the following
In the static library one .h file uses #import <SocketRocket/SRWebSocket.h> to import SocketRocket.
If I add the library to my sample project, the SRWebSocket.h file is not found.
How can I make the sample project recognise this file?
Have you made user that "Step 9: Final setup of app project" where you set your header search paths is actually pointing to the location of the header files?

Cordova 1.6.1 - Plugin not found, or is not a CDVPlugin

Sorry, my English is not very well.
I'm using cordova 1.6.1.
I created a new cordova-based project and I extended it to add a plugin.I build a static library with the plugin I created and try to run the projet including this library (the library can be found in the build settings of xcode), without the sources in the plugins folder
The following errors occur when I run my application :
[INFO] ClientChannel(1) initializing...
CDVPlugin class MNClientChannelPlugin (pluginName: MNClientChannelPlugin) does not exist.
ERROR: Plugin 'MNClientChannelPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist.
Some comments on these errors :
1) The first line is a log from The JavaScript code that I wrote, this indicates that the "initialize" function is launched. This function call a init function of a Plugin named MNClientChannelPlugin.
2) & 3) These logs come from the native iOS cordova sdk (Called from the getCommandInstance (2) and the execute (3) functions of CDVViewController.mm)
In the Codova.plist, I put MNClientChannelPlugin as a key and as a value. With this configuration, it works when I put MNClientChannelPlugin source (.mm & .h) in the Plugins folder but not when I created a static library with MNClientChannelPlugin.mm. (I included this library in my project and let the .h header in the Plugins folder).
Cordova seems to doesn't find the source in the library...
The Cordova plugins are in the Cordova.Framework and not in the
Plugins folder with .m and .h files so it seems possible to create
plugins, package them in a library and use them in a cordova-based
project but I it doesn't work for me...
I have looked at the archives and the commits but did not find any
solution. Does anyone know what could be the issue ?
Right, I've found a solution to this.
Here's the problem:
Your MNClientChannelPlugin is held in a static library
Your main project references the static library
The linker is clever enough to only link in classes that are actually used by your main project.
As far as the linker knows, MNClientChannelPlugin is NOT used by your project as it isn't referenced anywhere.
It's not referenced anywhere because the class is only loaded if your phonegap app happens to request a MNClientChannelPlugin instance.
Ergo the class is not linked into your final binary and you get the error above.
The solution is to force the linker to include the MNClientChannelPlugin object.
The easy was is to add -all_load to the 'other linker flags' for your main project. This will have the knock-on effect of linking every class in every static library in your project. It does work though.
The better was is to use -force_load with the name of your static library. Here's a post with help on this, though I haven't tried it myself:
xcode-project-target-settings-syntax-for-linker-flag-force-load-on-iphone
If you were using Pushwoosh (which I assume you were), the instructions clearly state that you should copy and paste this code:
<key>PushNotification</key>
<string>PushNotification</string>
to Plugins in “Cordova.plist. So if you have the above error which I once had it means that you did not copy and paste it to the Plugins. Moving the key and string values to the right location should annihilate the error.
Happy hacking!!!

Build a static library for iOS - specifically spatialite

First, please forgive and point out if I am to use some other protocol for referencing another thread/post.
There was a previous thread how to compile spatialite for iOS where the top answer partly described building spatialite as a static library for iOS. The answer included the text:
"Once you've drag n drop the .a (both are required to work in the simulator AND on the real hardware), you can initialize spatialite by just invoking spatialite_init(1)."
I am guessing this is translated to some version of the following?
Xcode 4
File->New->New Target->iOS->Framework & Library->Cocoa Touch Static Library
Name the library - libSpatialite_TedS
Drag the header files to libSpatialite_TedS -> Copy Headers (question here ... there is a spatialite.h file in the 'headers' directory of the 'spatialite2.3.1.zip' download. Then in the subdirectory 'spatialite' there is another spatialite.h that is not an identical file and is obviously needed. Do we just drag the header files from 'headers' directory, then drag the directory 'spatialite' as a directory into 'Copy Headers' area of our Xcode static library 'myNewLibrary'?)
Drag the '.a files' libSPATIALITE2.3.1_arm.a & libSPATIALITE2.3.1_x86.a
Shouldn't we have some '.m' files to go with these headers in the 'Compile Sources' field?
Now, without referencing the libSpatialite_TedS in my project, when I 'Command-B' to build, the project build succeeds. However, when I look for the compiled product in
/Users/Admin/Library/Developer/Xcode/DerivedData/MyProject-gutnkbwqqonzgxbcmfzzzkadqhid/Build/Products/Release-iphonesimulator
I see build's products, but they do not include libSpatialite_TedS.
Is this because the compiler is 'smart' and recognizes that none of the header/.a files are referenced in the project so it does not bother compiling them?
And, is this the correct way to go about achieving the objective of the original poster how to compile spatialite for iOS?
Many thanks,
Ted S
I was running into linker errors with the original poster too, but solved it by including libsqlite3.dylib, libstc++.dylib, and libiconv.dylib in the target.
Hope this helps!
Ted, I believe that the .a (static library) files and headers are meant to be used in a project right away, rather than in another static library as you've described. They are the result of a project's output. I think you can find the project that built them, here:
http://lionel.gueganton.free.fr/spatialite/
And a little more on static library files:
What is a .a (as libcrypto.a) file?
EDITED
Here's another link that you might find helpful. It s a summary of the Static Library build process in iOS:
http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/

Resources