Sunday 7 December 2014

Create a combine universal framework in xcode 6


Create a combine universal framework in x code 6

For More information refer this link ;
http://monkpal.com/create-combine-universal-framework-x-code-6-ios


An Aggregate Target in Xcode will build multiple targets at once, including command-line scripts. Navigate to File/New/Target in the Xcode menu. Choose iOS/Other and click on Aggregate, like so:


Call the target UniversalFramework, and make sure FrameworkName is the selected project, as shown below:




Click on the FrameworkName project in the project navigator, then select the Agg target. Switch to the Build Phases tab; this is where you will set up the actions that will run when the target is built.
Click on the Add Build Phase button, and select Add Run Script in the menu that pops up, as shown below:

Now you have a script item to set up. Expand the Run Script module, and paste in the following text under the Shell line:

FRAMEWORK_NAME="${PROJECT_NAME}"


SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"

DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"

UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"

FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"

xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -arch i386 -arch x86_64 -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator | echo

xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphoneos -arch arm64 -arch armv7 -arch armv7s -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos | echo


rm -rf "${UNIVERSAL_LIBRARY_DIR}"

mkdir "${UNIVERSAL_LIBRARY_DIR}"

mkdir "${FRAMEWORK}"


cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"


lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}""${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output"${FRAMEWORK}/${FRAMEWORK_NAME}" | echo

Now you’re ready to build the universal version of the static framework Select the aggregate target UniversalFramework in the Scheme Selection drop down, as so (unlike on the screenshot below instead of “iOS Device” you might see your device’s name):


 
Press the Run button to build the target for the aggregate scheme.

To see the result, use the Show in Finder option on the FrameworkName.framework product again. Switch to Finder’s column view to see the folders in the hierarchy and you’ll see a new folder called Debug-Universal (or Release-Universal if you built the Release version), which contains the Universal version of the framework.





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