Skip to main content

How to export “fat” Cocoa Touch Framework (for Simulator and Device both)? , Make framework which works for both simulator and Device

- Make framework which works for both simulator and Device
- How to export “fat” Cocoa Touch Framework (for Simulator and Device both)?
- Undefined symbols for architecture x86_64
- ld: symbol(s) not found for architecture x86_64

Steps 1: First build your frameworks with Simulator target

Steps 2: After success of simulator building process, now build for your framework with device target selection or Generic iOS Device selection

Step 3: Now select your framework target and for that Under "Build Phases" select "Add Run Script" and copy the contents of this file as below: (Note: i have modified slightly in this link script code)

[Note: We must have both compatible framework ready before final step4 (simulator architecture and device architecture compatible, if not please follow above steps correctly)

Step4: Now finally, build again and your framework is ready for both simulator and device compatibility.  Hurrey!!!!

See the reference image:




 

Put below code into shell area and build again:

#!/bin/sh

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 ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

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

# Step 3. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi

# Step 4. 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 5. Convenience step to copy the framework to the project's directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"

# Step 6. Convenience step to open the project's directory in Finder
open "${BUILD_DIR}/${CONFIGURATION}-universal"

Comments

Popular posts from this blog

KHODIYAR CHALISA LYRICS

Custom callout : Button is not clickable issue : Quick Fix

Steps To Fix the Issue:

1. Create "MyAnnotationView" custom class extended by "MKAnnotationView" class

2. Add two methods into MyAnnotationView.m class, methods are as below:

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent*)event

Done!





>>>      Reference code as below for further understanding    <<<
=================================================
Custom Pin and  Custom Callout Code:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    if([annotation isKindOfClass:[MKUserLocation class]]) {
        return nil;
    }
    static NSString *identifier = @"MyAnnotation";
    MyAnnotationView * annotationView = (MyAnnotationView *)[mapViewGroupList dequeueReusableAnnotationViewWithIdentifier:identifier];

    if (!annotationView)
    {
        annotationView = [[MyAnnotationView alloc] initWithAnnotation:annotation reuseIden…