Sunday 7 December 2014

Creating a Static Framework Project in Xcode 6


Creating a Static Framework Project in Xcode 6
Open Xcode and create a new static framework project by clicking File\New\Project and selecting iOS\Framework and Library\Cocoa Touch framework.



You can provide your framework name. For this example, we can name it as FrameWorkName

Automatically umbrella header created for our control. In this header , you should import all the public headers of  our framework using the statements like #import <FrameworkName/PublicHeader.h>


A static framework project is made up of header files and implementation files, which are compiled to make the framework itself. You can create the class by using the Cocoa Touch class.


 
To set the target version
1.     In the project navigator, select the project and your target to display the project editor.
2.     Choose the 7.0 version in pop up menu, because framework support iOS 7.0 onwards.



Verifying Your Build Settings

Go to the Build Settings of your project Target and confirm or set the “Architectures” to “Standard Architectures.” These are arm64 and armv7, and are likely the default.  As well as, Also we need to set the few architectures in setting, because iOS apps need to run on many different architectures.
  • armv7: Used in the oldest iOS 7-supporting devices
  • armv7s: As used in iPhone 5 and 5C
  • arm64: For the 64-bit ARM processor in iPhone 5S
  • i386: For the 32-bit simulator
  • x86_64: Used in 64-bit simulator






This means that builds are as fast as they can be. When you archive an app or build in release mode, then Xcode will build for all ARM architectures, thus allowing the app to run on most devices.





Mach-O setting:

In default, the framework is generating dynamic library for new project. So we need to change the static library. Refer the below image.


 
Now build and run your framework. You will notice the usual Xcode “Run” button just performs a build; you can’t actually run your framework to see the results as there’s no app behind it!
Rather than a .app or a .ipa file, a static framework has the .framework extension. You can find the generated static framework in the Products folder in the project navigator. Right-click or control-click.FrameWorkName.framework and select Show in Finder in the contextual menu.





Xcode will open the folder in Finder, where you’ll see something like this:


For More information click this http://monkpal.com/creating-static-framework-project-ios-and-xcode-6

Refer the below link for combine the both device/simulator framework:
http://monkpal.com/create-combine-universal-framework-x-code-6-ios


2 comments:

  1. I do we need an iOS device to build framework or we can also build using iOS simulator
    .

    ReplyDelete
  2. yes, you need to build both device and simulator. After that you need to combine the both device and simulator framework in single framework. Refer the below link.
    http://iosxamarintutorials.blogspot.com/2014/12/create-combine-universal-framework-in.html
    This link step work for both device and simulator.

    ReplyDelete