2

I am integrating a third party framework into my AppStore app using Xcode 6.4. The framework from the third party is a universal binary which has the following when I do the file command :

DeviceTester (for architecture i386):   Mach-O dynamically linked shared library i386
DeviceTester (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
DeviceTester (for architecture armv7):  Mach-O dynamically linked shared library arm
DeviceTester (for architecture arm64):  Mach-O 64-bit dynamically linked shared library

I have tried adding this framework as a Embedded Binary. This works fine it build fine however when I upload the "ipa" to the AppStore, it complains of the ipa having unsupported architecture which are the simulator pieces. when I inspect the ipa file I do see a "Frameworks" folder as is with the universal framework inside it. But I don't see this for any of the other frameworks I including eg. Crashlytics/Fabric etc. So there is something incorrect here.

I also tried adding it as a framework and then made sure it is in the copy phase, but running it gives the following error on the device :

dyld: Library not loaded: @rpath/DeviceTester.framework/DeviceTester
 Referenced from: /var/mobil....

Any pointers gladly appreciated, I have spent the whole day today trying to figure out what is happening with no luck.. Cheers.

user3570727
  • 10,163
  • 5
  • 18
  • 24

1 Answers1

1

From Xcode 6.1.1 & 6.2: iOS frameworks containing simulator slices can't be submitted to the App Store. You would need to remove the simulator slices from the fat framework to be able to submit to the AppStore.

Here's a script to do the magic. Add a Run Script step to your build steps, put it after your step to embed frameworks, set it to use /bin/sh and enter the following script:

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

 # This script loops through the frameworks embedded in the application and
 # removes unused architectures.
 find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
 do
     FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
     FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
     echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

    EXTRACTED_ARCHS=()

    for ARCH in $ARCHS
    do
        echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
        lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
        EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
    done

    echo "Merging extracted architectures: ${ARCHS}"
    lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
    rm "${EXTRACTED_ARCHS[@]}"

    echo "Replacing original executable with thinned version"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

This answer might explain what you are asking. https://stackoverflow.com/a/31270427/4160199

Community
  • 1
  • 1
quant24
  • 393
  • 6
  • 22