5

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

dandan78
  • 13,328
  • 13
  • 64
  • 78
Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90

2 Answers2

15

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.

Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90
  • 1
    This worked great for me. The only change I made was removing the -arch x86_64. This was causing the problem of not being able to run on i386 simulators (anything before 5s). -sdk iphonesimucator gives the compiler enough info to build for both i386, and x86_64. If you explicitly specify one, it excludes the other. Thanks! – Chad Jan 23 '15 at 01:02
  • 2
    @Chad How did u remove -arch x86_64. Because When I removed from run script, it is still not running for Simulator. – Ansari Awais Jun 24 '15 at 06:50
  • @Chad : You need to try step 8. Then only you will get universal framework which supports for both device & simulator. – Rajesh Loganathan Jun 24 '15 at 07:15
  • 2
    @Chad it's also not running in Simulator for me. – Tapas Pal Feb 09 '16 at 09:12
  • @AnsariAwais can you please let me setting the deployment target means? What you did? – Tapas Pal Feb 09 '16 at 09:12
  • Works in the device but in the simulator not found the references of the framework – jose920405 May 05 '16 at 21:40
  • @jose920405 :Right click framework from products in Xcode & click show in finder. Check "Debug-universal” folder & get universal framework which works in both device & simulator. – Rajesh Loganathan May 06 '16 at 04:17
  • Yes man, i found the universal folder, but when drag to the proyect only works in the device.. I doing that in Xcode 7.3 – jose920405 May 06 '16 at 12:41
  • This is working only in device but not on simulator, could you please help. – Kashif Jilani Jan 27 '18 at 09:53
  • @Kashif Check "Debug-universal” folder & get universal framework. Universal framework only works with device and simulator. – Rajesh Loganathan Jan 29 '18 at 12:25
0

replace

xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

with

xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

clean build

JimHawkins
  • 4,843
  • 8
  • 35
  • 55