[ios] Error in trying to upload Archive build to App Store when Sentry framework included


#1

I’ve just integrated the Sentry framework into my iOS application, and it seems to work fine. We do not use Carthage or Cocopods, so I added the framework directly into my project (which I have done before with other libraries).

As I said, it runs fine - on both device and simulator. However after I Archive and then try to upload a build to the App Store for distribution, I get an error that it could not code-sign the Sentry framework:

If I click on the logs and look through them a bit, I cannot find an error related to Sentry and code signing. From researching the error it seems like this can be caused by having the library linked twice, but I do not think that is the case (the other framework my app includes, Nami, has been in my app for a while now in the same way without issue and also been distributed to the App Store successfully).

Does anyone have any ideas what could cause this? As I said, I drug the Sentry framework into my Xcode project, and made sure it’s embedding the framework and linking the libraries properly. From the General project tab I can also see it is embedding and linking the framework (would post screen shots but new users can only post one image).

Thanks for any help!


#2

Update: I’ve fixed the problem by instead adding the Sentry iOS repository as a submodule to my project, then dragging in the Xcode project file into my project, and adding the frameworks via the general tab of the project management page for my app. Note that for some reason I also had to explicitly add in linking of the framework instead of just embedding - if you do the same make sure you can run on simulator and device before you try to archive and submit a build.

Sentry should look into whatever is wrong with the framework they distribute though - or possibly it’s an Xcode 10 bug, either way they should research what is going on before too many more people are impacted.


#3

I am not 100% sure that this was the problem but our Framework we distribute is built with Carthage, which means it includes all possible architectures.
If you are using Carthage and not directly drag in the Framework, it provides a script for you which strips all unnecessary architectures from your build.

The script looks something like this, if you add this to your build phase this may fix the issue.

# SENTRY_FRAMEWORK_PATCH
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
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