Help using iOSPorts to connect to an LDAP server - iphone

I am building an iPhone application which connects to an LDAP server (no encryption). I am trying to use iOSPorts but I am having trouble following the documentation, I think it was written for Xcode 3, while I've only ever used Xcode 4.
All that is required is to do simple search queries of the server and returning the results.
Some of the trouble I am having:
For example in step 3 my iOSPorts/include folder is empty and only contains the .gitignore file.
For step 4 which files do I need to add just the ports folder containing database, devel, iOSPorts and security?
For step 6 the direct dependencies panel, is this the target dependencies of build phases , which libraries need to be selected?
I think step 7 is for Xcode 3 too,
Any help with this would be much appreciated!

I am building an iPhone application which connects to an LDAP server (no encryption). I am trying to use iOSPorts but I am having trouble following the documentation, I think it was written for Xcode 3, while I've only ever used Xcode 4.
The original instructions were created for Xcode 3 since Xcode 4 was still in early beta when I published the first release of iOS Ports. The instructions have been updated within the last month for use with Xcode 4. I try to use the name used by "Xcode 4 User Guide" when describing the steps, so I recommend reading the first few chapters of this document from Apple.
For example in step 3 my iOSPorts/include folder is empty and only contains the .gitignore file.
Initially the include directory will be empty. The individual ports will copy the header files to the include directory. This is to prevent the end developer from needing to add a path to OpenSSL, Cyrus SASL, and OpenLDAP in order to compile an app for OpenLDAP.
Any help with this would be much appreciated!
So here is a quick run down of how iOS Ports works.
Each port of an Open Source package has an Xcode project file. That Xcode project file lists other Xcode project files and Makefiles as dependencies. Here is the high level steps used by an iOS Ports Xcode project file to compile the port:
Execute the port's MakeFile
Makefile: Download the source archive from the Internet (fails if Internet is unavailable)
Makefile: Verifies the integrity of the source archive using md5sum.
Makefile: Unpacks the source archive.
Makefile: Applies any required patches to the source code.
Makefile: Copies headers to the iOS Ports include directory.
Build any libraries from other ports listed in the build settings' Target Dependencies (for instance, libldap.a in OpenLDAP requires libsasl2.a from Cyrus SASL).
Compiles requested library.
The README has more information on how to add the project files to your project and link against the libraries. There also a few example programs in the examples directory.
If you do continue to have problems, please let me know. I try my best to keep on top of requests for help regarding iOS Ports and my other projects.

I haven't gone through all the process, but I am pretty sure for step 3, you have to 'make' the project first. There is a Makefile in the top folder of the project.

Related

How to embed third party framework on ionic capacitor custom plugin?

I am developing an Ionic Capacitor plugin which imports 2 iOs .framework files and a .bundle that refers to one of this .framework files. The thing is that no matter how I link/embed and point/copy this files on the plugin project, xcode claims, on the app project, that it cant find the module in the swift file.
I already tried to add the files to the project, used the "Embedded binaries" option, linked libraries, allow non-modular includes (on build options menu), add the files to the headers (on build phases), and so on....
The line that xcode point the error is:
import OneFramework
And xcode claims:
No such module 'OneFramework'
I was expecting that when I add the plugin to my app project via npm, and later running a "$ rm -rf ios && ionic capacitor run ios" to run the app, xcode find all the modules of the plugin that I am trying to do.
I found the solution. To achieve this the first thing to know is that when you do npx #capacitor/cli plugin:generate what the CLI do for you is the generation of a cocoa pod. The root of this pod is the generated folder itself.
With that in mind, the next thing to do is to learn how to make pods, but i'll sumarize the principal aspects that led me to the success.
-First of all you open the *.xcworkspace. Followed by that, click on the "Add Files to Pod..." option and add your files. Please ensure that the "Copy files if needed" option is marked. Please refer to the picture below.
-Now its nice to create a folder for your .framework and another for the .bundle (if there are any) files. Do this by right clicking the Pods project and select the option "New group". Select a name like that is different from the pattern of xcode, it is nice to know that this folders are created by you.
-If you done this right, the frameworks you recently added to the project will appear on the pods project like this:
-Now, for your swift implementation find your files, drag your .frameworks that are on the pods project for the "Frameworks, Libraries and Embedded content" of the plugin project. The result will be something like this:
-Ok, files included and linked. Now we should let our cocoa pod know about this and declare this files. The file "YourAwesomePlugin.podspec" (located at the root of the plugin project) is the main entrance of the pod. In this file you will declare which files (.frameworks, .bundle, etc) belong to your pod and consequently will belong to your plugin when you npm install it. To declare this you'll need three directives:
s.vendored_frameworks = 'ios/Pods/YourFrameworkFolder/**'
s.resource = 'ios/Pods/YourResourceFolder/YourBundle.bundle'
s.xcconfig = {'ENABLE_BITCODE' => 'NO'} #This is mandatory on my case, but you need to evaluate if this options applies to your plugin.
-Now we hit play on the plugin project. To test on your app if the plugin is ok, you need to add the path of the root of the plugin project on the podfile of the pods project of the APP project. Like this:
-To install it you can go on Yourproject/ios/App and run pod install.
Please note that:
To declare the existence of your recently created plugin you you need to do some declarations as well, but this part is easy and already documented on capacitor/plugin docs.
The installation method via pod install that I suggested is for testing. It would be nice if you pack your plugin using npm and npm install it like all other plugins.
I dont have much knowledge on cocoapods like I wish, but this works and I think that is a clean solution. If not, please let me know.
If this answer is useful for you, please thumbs it up, it is a week of research and trying that I am sharing, along the time to write it all down.

Can' get with libxml2.h,file not found, XMPP framework

For the last three days I am trying to import XMPP framework and constantly getting this error:"<libxml/tree.h> file not found" in DDXMLNode.h. I copied suggested files to project, created groups, imported necessary libraries,add a flag -lxml2(I tried to add it to project or to target or to them both-nothing helps).I also tried to specify $(SDKROOT)/usr/include/libxml2 in header search path,library search path,users search paths of target,project or in them both - again nothing. I looked at sample project, it works. But they don't specify other linker flags at all. They do header search paths of project and target(and everything is fine). So nothing helps, while sample project with same settings works. Any suggestions?
Additional info: I use xcode 6,target is iOS8, in target's build settings I use -all_load flag for some other sdk's(just in case this matters)
I had same problem. This link helped me out. If you follow instructions step by step, I think it will solve the problem.
Steps can be summarised as:Step 1. Make sure you link CFNetwork framework and Security framework
Step 2. Goto Projects -> Build Settings and add “/usr/include/libxml2” to Header search path
Step 3. Also add “-lxml2” to Other linker flags
Step 4. Add following folders from XMPPFramework to your project:
Authentication, Core, Categories, Utilities, Vendor

Convert regular xcode application project to iOSOpenDev

I'm new to jailbroken dev. I have a regular xcode application project. Now I need to convert it, or create a new application project using iOSOpenDev for jailbroken dev. I found the same question:
xcode project conversion to iOSOpenDev
But I have no idea what to do with the first step. Do I need to add some settings or change some values of existed settings? Pleas give some more details.
thanks!
About the first step, I did some tryings and it worked out. The following steps is just the same as kokoabim said:
1.change the install path to /Applications; add iOSOpenDev's include,lib,framework folder path to Framework Search Paths,delete iphonesimulator from Supported Platforms in Build Settings, Header Search Paths, Library Search Paths(I'm not sure if it's necessary);
Add a run script build phase (must be last in order) to existing target that executes /opt/iOSOpenDev/bin/iosod --xcbp.
3.Create the Debian package control file under the existing target's folder as (target's directory)/Package/DEBIAN/control.
4.Perform a Build For Profiling (Cmd-Shift-I).

dyld: Library not loaded - When app run from the command line

I face some difficulties when adding a framework to my project when i run an iPhone app from the command line.
My final goal is to run applications tests from an automated build process.
When i run my app from xCode :
I add a "Copy File" build phase to my target and everything goes fine.
The copy is set to $(BUILT_PRODUCTS_DIR) as "Absolute path"
When i run my app from the terminal (using iphonesim project) i get this error :
dyld: Library not loaded: #rpath/OCMock.framework/Versions/A/OCMock
UIKitApplication:indemnisation[0xb894][26380] Referenced from: /Users/Admin/Library/Application Support/iPhone Simulator/User/Applications/CD5729B5-A674-49B2-91F6-AD398094B6F8/indemINT.app/indemINT
What i dont understand is that the copy build phase just copies the framework files in the same directory as the app.
When i run the app from the command line the framework files are already in the same directory. Does anyone knows why it doesn't work ?
I've also tried to add the OCMock.framework in the following directories (without success) :
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library
/Library/Frameworks
/Users/Admin/Library/Application Support/iPhone Simulator/User/Applications/CD5729B5-A674-49B2-91F6-AD398094B6F8
Thanks in advance,
Vincent.
I just had this same exact error in Xcode 4.2 (4D199) on Lion. I dragged/dropped the OCMock.framework folder into my project and selected the "copy files" checkbox. I saw the above answers and realized I neglected to add a "Copy Files" build phase to move the framework into place. I added one and dragged it right after the compile files build phase and tried to run my tests again. I couldn't get it to work until I had changed the destination in the "Copy Files" phase to the "Products Directory". Using "Frameworks" or "Shared Frameworks" did not work.
The iPhone does not support traditional Mac OS X frameworks. While the iPhone does use folders that end in ".framework", these folders are structured differently than typical Mac OS X frameworks. Most notably, iPhone frameworks are only permitted to use static libraries, while typical Mac OS X frameworks are dynamically loaded. That the message comes from dyld indicates that you are using a shared libary; however, applications targetting the iPhone may only be statically linked.
OCMock is distributed as a framework, and the iPhone does not allow you build your own arbitrary frameworks (there are good reasons to do this on a device with only 128MB of RAM and no swap).
The solution I see in a lot of places around the web is to put OCMock.framework in /Library/Frameworks or anywhere else in the standard framework search paths. This isn’t a very good solution: your build system is now dependent upon the state of your particular machine. Not good.
Another option would be to add the source for OCMock to your unit test target. This would work but is unnecessary, as your tests will never run on the iPhone,2 so why bother building them for ARM? Executables built for the iPhone simulator, being Mac OS X binaries, can link against dynamic libraries just fine. We can use this to our advantage.
What follows is what I believe is the best way to get OCMock working with iPhone projects:
First, add OCMock.framework to your project. Make sure that it’s being added to your Unit Tests target, not your application.
Next, add a Copy Files phase to your Unit Tests target. Set it up like so:
Destination :Absolute Path
Full Path :$(BUILT_PRODUCTS_DIR)
Now, drag OCMock.framework onto your new Copy Files phase to add it to the list of files to be copied.
Finally, drag the Copy Files phase, which I renamed it to “Copy OCMock”, between the Compile Sources and Link Binary With Libraries phases.
That’s it! Run (and by run I mean build) your tests and everything should work correctly.

Adding a static library to an iPhone project

The motivation for this question is me trying to get LDAP functions to work with an iPhone application which is a project I'm attempting for part of my dissertation.
When I was developing the application I used the ldap.framework framework that is part of Mac OS X. This works fine in the simulator, but when I try to now get the app on a device it tells me that I'm not allowed to use this framework.
After some research I found that I could build openldap using the arm architecture and add the static library to my application destined for my device.
I eventually managed to compile configure and build openldap by setting variables as mentioned here and using the following commands...
Ade$ ./configure CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.0.1 \
LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin --with-yielding_select=yes
Ade$ make depend
Ade$ make
I was told that the file I'm looking for will have an extension of '.a' so I searched for a '.a' file that mentions ldap...
Ade$ sudo find / -name *ldap*.a
Password:
/Users/Ade/Desktop/openldap-2.4.16/libraries/libldap/.libs/libldap.a
/Users/Ade/Desktop/openldap-2.4.16/libraries/libldap_r/.libs/libldap_r.a
So I assume these are the files I need?
My question is what do I do next? I know I need to add the library to the Xcode project and probably add a load of '.h' files too?
If anyone can give me a pointer to documentation or shed any light on the next stage I would be really grateful.
Many thanks,
Ade
ps. I have also talked about this process on my blog at www.greenpasta.com.
I've done this same thing to build an LDAP client for the iPhoneOS 2.2. You just to drag the .a into the "link with libraries" build stage. I recommend using the regular (non _r) version of the library, unless you specifically need reentrancy on your ldap stuff (which I don't recommend). You can also add the .h's to your project, which is generally the easiest way to access them.
Simply drag the .a files into the Xcode project and choose "copy files into project". I'm not familiar with OpenLDAP but I think the _r version is just a threadsafe version. I would recommend using that and not copying the other. You should probably not copy both files into Xcode or you will get link errors.
Then do the same for the .h files that define the client APIs of OpenLDAP - again I'm not sure which these are but I'm sure you can find out easily.
I would advise organising the .a and .h files together in a Xcode group under resources.
Include the header files in your source and you should be good to go.
You may also need to add -lldap to your linker command (in the build settings pane).