How to add library in Xcode - xcode

I want to add library to my iOS application in Xcode 8.3.
I've read a tutorial and so, I created a target 'DEST', after add this item in Target Dependencies and libDEST.a in Link Binary With Libraries. Also, I moved all forked library in project. Now, I'm trying to use this library as in example from git, but code doesn't work. What am I doing wrong?

Related

Linking libz.dylib and libsqlite3.dylib in Xamarin iOS Project

I created a Xamarin iOS binding project that requires the following frameworks:
SystemConfiguration.framework
CoreTelephony.framework
libz.dylib
libsqlite3.dylib
I added the following line in my iOS binding project to the linkwith.cs file:
Frameworks = "SystemConfiguration CoreTelephony"
This seems to work correctly and tells that project to include these frameworks when binding. From what I have read, it sounds like the remaining 2 libraries need to be added as linker flags in the project referring to the DLL generated from my iOS binding project. So I created a test app, imported the DLL, and now need to add the linker flags but my project cannot find the right libraries.
My linker flags in Xamarin Studio are as follows:
-gcc_flags "-lz -lsqlite3.0"
When I build my Xamarin test app I get a few errors regarding the frameworks that cannot be found. Are there additional flags that need to be linked or do I need to do some additional configuration in my iOS binding project?
I found a great resource: http://ipixels.net/blog/specify-extra-gcc-flags-for-native-library-binding-in-xamarin-ios/
I needed to add LinkerFlags = "-lz -lsqlite3.0" to my .linkwith.cs file. I then rebuilt the library to generate a new DLL and added this to my test app. The test app builds correctly then.
If you are creating your bindings for a cocoapod using sharpie:
sharpie pod init ios nameOfCocoaPod
sharpie pod bind
you get a nameOfCocoaPod.framework file and .cs-binding files.
The nameOfCocoaPod.framework file should be added to your binding project under Native References. To change e.g. Frameworks or LinkerFlags, right-click and open properties.

Including OSXFUSE framework in XCode project

I have build a App based on OS X FUSE (ie I have my own file system based on OS X FUSE).
When OSXFUSE is installed I can of course include the OSXFUSE.framework from /Library/Frameworks.
However when I distribute the App I cannot expect the user to already have it installed, so I tried to include the framework with the bundle as follows:
dragged the framework from /Library/Frameworks to my project
created a new Copy Files build phase (with target Frameworks)
added the framework to that copy build phase
However when I run that on a system without FUSE installed I get an error:
dyld: Library not loaded: /Library/Frameworks/OSXFUSE.framework/Versions/A/OSXFUSE
Referenced from: /Users/me/Library/Developer/Xcode/DerivedData/
Shouldn't the copy build phase prevent this? What am I missing here?
I finally found out that I can tell XCode explicitly to weakly link a framework by changing the required flag to optional.
This can be done in Project Overview > Target > Linked Frameworks and Libraries. Next to each framework is a dropdown-menu where you can select optional.
So my question is actually a duplicate of this How do I weak link frameworks on Xcode 4?
I believe that the OSXFuse framework needs a corresponding kernel module to work. This has to be installed separately so you would have to put together an installer package that first installs the kernel module and the preferences pane, and then installs your application.
Alternatively, you could notify the user that the module needs to be installed separately and provide a download link or something to that effect.

Build static library

I am trying to build a .a static library for my iPhone project.
So, I have created a new project, and I used the template Cocoa Touch Static Library.
Then, in XCode 4.0, I add my .m and .h files.
i have successfully build the project, but no .a file is created In XCode, I see .a file in Products category but displayed in red; so it doesn't exist.
I don't understand why my build button don't create .a file, any help?
I see that you accepted the answer, but I thought I'd leave a note for future library developers. After upgrading an Xcode 3.x based static library project to 4.x, the library will not always upgrade and begin doing universal library builds. When this happens, the project build will be successful and apps linked against the target dependency will run fine, but you'll get red static library files showing in the projects you pull in. This is very annoying and the only fix I have found is to recreate the project files -- I tried auditing the build settings but was unable to figure out the confounding factors.
Hope this helps save somebody the 2 hours I just lost :-P

Project that builds both framework for OS X and static library for iOS

I am trying to build a library of code that can be built into a .framework for OS X as well as a shared library for iOS. I'm not sure this is possible, there seems to be some strange behavior on XCode 3.2.5's part.
I want one project that holds all my shared code. Keeping the #if and #else definitions out of the equation here, I'd like this code to be able to be built with the 10.6 SDK as well as the iOS 4.2 SDK. I'd like to have 2 separate targets in my project, one building the .framework, and the other building the shared library lib*.a. They would each only get to compile the code that is relevant to them, but this single project would hold all of it.
My first steps seemed ok - created a fresh new project for building .frameworks, then I added a target to build an iOS shared library. As soon as I flip back to the .framework target, I get an error trying to build:
"target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform"
I didn't change the "product type" in the framework target (not even sure how), but it now seems to think that it's supposed to build everything for iphonesimulator, and that product doesn't support frameworks (which indeed it doesn't).
Has anyone else gotten this to work? Is this possible with XCode 3.2.5? Will this be possible in XCode 4?

Share an Xcode project as a static library for other people to use in emulator. How do you use an AppDelegate from a .a static library file in Xcode?

I want to share my Xcode project as a static library for other people to use in the xcode emulator (giving them as little raw source code as possible). How do you use an AppDelegate from a .a library file in Xcode or UIBuilder?
I copied the main Window.xib file to a new project and included all of the other source files in a static .a library that I thought I would be able to invoke somehow. What do I have to do to launch my main product that is compiled into the .a library from a brand new Xcode project that is including that library?
You'll have to link to the static library. Include it in your new Xcode project, and then in the target for the application, go to the General tab and set the library as linked. You'll probably want to copy it into your new project's bundle (in the Frameworks directory), using a Copy Files build phase. You'll also need to reference the header files for the static library for avoid warnings.
This is a much better solution found in someone else's question:
iOS Question. Can I distribute the Xcode simulator versions of my app?

Resources