0

I am trying to create objective C Network framework using Xcode 15 with minimum supported iOS version 14.0.

Here are the steps I am following:

  1. I created New> Project> framework> Objective C> storyboard> Create.

  2. Made NetworkManager.h file created by project to public.

  3. Added two files MyNetworkRequest.h and MyNetworkRequest.m.

  4. Made MyNetworkRequest.h > Public from inspector.

  5. Added #import < NetworkManager/MyNetworkRequest.h> in the NetworkManager.h

  6. From Project > Target > Build Setting > set SKIP_INSTALL = NO and Build Libraries for distribution = YES

  7. Added script for making framework : select target from top bar> Edit scheme> Archive> Post action> Add run script> copy pasted following script:

    UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-Universal
    
    # Build Device and Simulator versions
    xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk 
    
    iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}"    BUILD_ROOT="${BUILD_ROOT}" clean build
        xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration     ${CONFIGURATION} -sdk iphoneos  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"     clean build
        # Copy the framework structure (from iphoneos build) to the universal folder
        cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework"     "${UNIVERSAL_OUTPUTFOLDER}/"
    
    # iOS - Copy the framework structure to the universal folder (clean it first)
    rm -rf "${UNIVERSAL_OUTPUTFOLDER}"
    # Make sure the output directory exists
    mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
    
    # Copy Swift modules from iphonesimulator build (if it exists) to the copied     framework directory
    BUILD_PRODUCTS="${SYMROOT}/../../../../Products"
    cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework"         "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"
    
    # 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_PRODUCTS}/Debug-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}"     "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
    
    # Copy the framework to the project directory
    cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
    
    # Open the project directory in Finder
    #open "${PROJECT_DIR}"
    fi
    
  8. build and make archive.

  9. Open the archive by right clicking and show file content> does not contain framework in any enclosing folder.

3
  • I suggest to use SPM for framework creation, even if it's written in Objective-C
    – Cy-4AH
    Commented Jul 30 at 14:01
  • Thank you for your suggestion but the client needs framework directly. Hence I am stuck. I am able to build other framework using Xcode 12.3 on different machine. but not with the described specification. Commented Aug 5 at 15:58
  • Still you can build framework with SPM and use it directly
    – Cy-4AH
    Commented Aug 12 at 8:57

0