create our own frame work in iphone - iphone

There are lots of the frameworks available for different purposes, but I want to create framework library for my some of my classes -- in that all the .m files are loaded in single .a file and it's used with the list of header files.
Can any one tell me how to create a framework?

This webpage should give you the necessary information when creating your own framework.
http://accu.org/index.php/journals/1594
Hope this helps!

You can create a "Cocoa Touch Static Library" project in Xcode.

Related

Use Private FRamework in Xcode Celestial

I'm a Xcode beginner so I would really appreciates if the answers were as much detailed as possible (if image could be included it would be best)
I would like to use the celestial private framework, I do not care if it get rejected by the app store since it's a private project.
I would like to use the AVSystemController in the celestial framework.
If I go to the xcode directory, I find only an exec file in the framework.
I found the headers files at:
https://github.com/masbog/PrivateFrameworkHeader-iOS-iPhone-5.-
download:
https://github.com/masbog/PrivateFrameworkHeader-iOS-iPhone-5.-/archive/master.zip
The questions are:
1-Do I add the framework that's included in the xcode directory the one that has only on file (exec named Celestial)? or should I add a headers folder first and put all the downloaded headers in it?
2-IS Github a trusted site? btw I couldn't help but noticing that the downloaded zip file headers (at least the AVSystemContriller.h ) are different then the ones you directly open on the website
3-After adding the the celestial framework (in the linked Binary with librairy of the project ) to use it I should use #import but I get an error not found
The purpose of this project is to turn the iphone to silent profile by code.
Please Help, I've been reading threads all over the internet and I wasn't able to solve it.
P.S.: Like I said before I am a beginner so it would be appreciated to detail you answer as much as possible
Thank You
dumping private header is for helping you to find functional without documentation, to load private framework you just type on your code like this :
NSBundle *b = [NSBundle bundleWithPath:#"/System/Library/PrivateFrameworks/WhatEver.framework"];
that mean, you will load/use private framework at your iDevice :)

How to build a static library of an existing project in objective-c (.a file)?

I want to make .a file means static library of my project which I have made. How can I achieve this. Please provide me the the best solution, tutorial or any other links.
Thanks in advance
http://mobileorchard.com/sharing-compiled-code-building-static-libraries-in-xcode-for-the-iphone/ has a good tutorial.
Here are the basic steps:
Understand that XIB/NIB/Storyboard files have to be included separately from the library
Add a new target that is a static library
In the build settings for that library, include all of the .h and .m files that are relevant. For example, if your app uses a set of classes to access data and another set to view that data, you may want to just include the files relevant to accessing data.
Build. Use the script provided at Build fat static library (device + simulator) using Xcode and SDK 4+ so that you can use it for iPhone simulator + device.
Include your library + headers + any resources in relevant project.
With xcode4.2, easiest way is to new project, iOS/Framework & Library, CocoaTouch Static Library, and add all you files existed.
Here is the easiest tutorial with which i have built a static library in iphone. After building a static library you will import a .a library file and the header file .h in your new project and use them. Here is the tutorial link for making static library.

Converting Framework to a Library

I want to use the framework found at the link below within an iOS app. I have it working within the simulator but after some digging it looks like you are unable to use frameworks on devices and especially when distributing through the App Store. Please correct me if I am wrong.
https://github.com/mirek/YAML.framework/
How would I go about converting this framework to a library? I have looked at simply dragging the files from the framework to the app which doesn't work.
Thanks in advance.
It's super easy.
Give the general iOS static framework structure:
3rdPartyLib.framework
|---3rdPartyLib -> Versions/Current/3rdPartyLib
|---Headers
|---Resources
|---Info.plist
|---SomeBundle.bundle
|---Versions
|---A
|---Current -> ./A
You have to
1) Copy the static library file in a new folder
3rdPartyLib.framework/Versions/Current/3rdPartyLib
2) Rename is with .a extension and copy to a new folder
3rdPartyLib/
|---3rdPartyLib.a
3) Copy all the headers in the folder
3rdPartyLib.framework/Headers
in a new headers folder in the new folder
3rdPartyLib/
|---Headers/
At this point you should end up with
3rdPartyLib/
|---3rdPartyLib.a
|---Headers/
This is your static library that you can use within your app or within another iOS framework to be distributed to other apps.
Take a look at this: https://github.com/Ecarrion/YAML.IOS
Just grab the YAML.Framework folder
And you actually can use framework, you just can't use dynamic libraries.

Image in bundle not found using NSBundle

So here's the deal:
I have an image in the Resources folder of custom framework that I use as a default for classes in the framework. However, when I create these classes in projects that link against my framework they fail saying they can't find the image. I'm guessing the NSBundle's +mainBundle does not search the correct paths for my classes to find this image when linked in a different project. Is this correct? If so, where should I be looking for my image? I hope this makes sense (it's awfully late) and thanks for the help!
For an application, the +mainBundle will be the application bundle (e.g., Foo.app). Frameworks are their own bundle, which you can find using +bundleForClass: or +bundleWithIdentifier:.
It's likely your image isn't getting put in the main bundle. You may have to use NSBundle directly to construct the path to your image. What does the built .app file hierarchy look like in terms of the image?

Purpose of a static library

I want to create an application core that connects to a webservice, downloads the data, parses it and then returns it to a view controller. This core would ideally handle requests from multiple controllers and abstract away a lot of repetitive code. Also, I want to potentially use this core for a mac os x application. Would these tasks be a good idea for a static library? Also, how do I add a static library to my iPhone App? Once the static library is added, how do I reference it (i.e. import statements, etc..)?
I want to create an application core that connects to a webservice, downloads the data, parses it and then returns it to a view controller. This core would ideally handle requests from multiple controllers and abstract away a lot of repetitive code. Also, I want to potentially use this core for a mac os x application. Would these tasks be a good idea for a static library?
Yes.
Also, how do I add a static library to my iPhone App?
Add the static library's target to your project, then add its build product to your iPhone app's target. When you start work on your Mac OS X app, add the library build product to that target as well.
Once the static library is added, how do I reference it (i.e. import statements, etc..)?
#import is a preprocessor directive; you use it on a header file during the preprocessing stage of the compile-source-files phase.
Compiling the source files produces object files, which the linker will fuse (link) together in the next phase. This phase also includes the linker linking in any static libraries.
You must have the library build product (from the library target) added in the Link Binaries phase of the application target in order to have the linker link the library into your application.
There's no really good reason I can think of to create a static library unless you want to distribute it without distributing source. You have to re-compile for each platform, so you might as well just add the library .h and .m files from a common location (e.g. don't copy the file into the projects when adding them. The "Add Existing File..." selection will allow you to deselect the checkbox labeled "Copy items into destination group's folder (if needed)" when you add). Then, any changes you make to the library files will be updated in both projects. Building a static library just adds another layer of complexity (additional targets, etc.) that is unnecessary (IMHO, sorry to disagree Peter ;-) .
Best Regards.