Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create universal framework in xcode6

I know how to create a framework in Xcode 5. But in Xcode 6 how to combine both a simulator framework & a device framework? When I try to combine I get a code signing error. When I use lipo to combine both framework, I also get an error.

Error: Command /bin/sh failed with exit code 65

like image 745
Rajesh Loganathan Avatar asked Nov 13 '14 10:11

Rajesh Loganathan


People also ask

What is universal framework?

A universal framework can be defined as a framework that contains a binary which has been built for a number of architectures (armv6, armv7, i386) and can be statically[1] linked against.

How do I create a custom framework in Swift?

In the app, select the project from the project navigator, select the Stocktance target, and scroll to Frameworks, Libraries, and Embedded Content. Click on the plus button, click Add Other… and select Add Files… Navigate to the SettingsKit folder and select it. We've added the framework to the project.


1 Answers

My solution to create universal framework in xcode6.

Try these steps:

Step 1:

File—> 
    New —> 
       Project —> 
           Framework & Library —> 
               Next —> 
                      Product Name

Step 2: Create custom class files

Step 3:

Target -> 
       Build phase -> 
           Headers, 

Makes all header files into public. Now build in simulator & device.

Step 4:

File ->
    New ->
           Target ->
               iOS ->
                      Other -> 
                          Aggrigate ->somename eg: framework

Step 5:

From Targets —> 
    Custom aggregate target(Eg: Framework)—> 
           Build Phase—> 
               Add Run script

Step 6: Add following shell code in run script

///

UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal

# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"

# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

# Step 2. Copy the framework structure to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"

# Step 3. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"

Step 7:

Goto active scheme —> 
    Custom aggregate —> 
           Build

Step 8: Now right click framework from products in Xcode & click show in finder.

Check "Debug-universal” folder & get universal framework.

like image 179
Rajesh Loganathan Avatar answered Oct 24 '22 00:10

Rajesh Loganathan