49

When I tried to create IPA file using Distribute APP option. It gave "IPA processing failed" error.

I have checked logs file: IDEDistribution.standard.log file.

2019-08-06 18:36:52 +0000 warning: Configuration issue: platform iPhoneSimulator.platform doesn't have any non-simulator SDKs; ignoring it Scanning IPA... 2019-08-06 18:36:52 +0000 Assertion failed: Expected 4 archs in otool output: /var/folders/4t/rpjk7pd55t16jfrd32y98gf0lb2t68/T/IDEDistributionOptionThinning.~~~a4cZJc/Payload/demo.app/Frameworks/AppAuth.framework/AppAuth: Mach header magic cputype cpusubtype caps filetype ncmds sizeofcmds flags MH_MAGIC_64 X86_64 ALL 0x00 DYLIB 23
3680 NOUNDEFS DYLDLINK TWOLEVEL NO_REEXPORTED_DYLIBS Load command 0

Emma
  • 27,428
  • 11
  • 44
  • 69
R.B Niranjan
  • 628
  • 1
  • 7
  • 12
  • 1
    I am able to fix this issue after updating AppAuth.framework. – R.B Niranjan Aug 06 '19 at 20:25
  • could u provide more info on how u did that process? – Catluc Aug 08 '19 at 11:08
  • This problem was because of APPAuth.framework was not compatible with xcode11. I updated the framework and not it is working fine. – R.B Niranjan Aug 08 '19 at 16:34
  • i am having a similar error with Alamofire5 beta 7 and earlier versions of the beta, tried ur way but didnt work out. Thanks anyway!! – Catluc Aug 08 '19 at 20:30
  • Can you please share the IPA failure log file or you can check where it is failing when you trying to create IPA. – R.B Niranjan Aug 08 '19 at 20:41
  • Assertion failed: Expected 4 archs in otool output: /var/folders/q9/mj2m25mn5b3cm43pgq1zch480000gn/T/IDEDistributionOptionThinning.~~~HN3opE/Payload/demoApp.app/PlugIns/notificationManager.appex/Alamofire.framework/Alamofire: Mach header magic cputype cpusubtype caps filetype ncmds sizeofcmds flags MH_MAGIC_64 X86_64 ALL 0x00 DYLIB 32 4920 NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK NO_REEXPORTED_DYLIBS APP_EXTENSION_SAFE – Catluc Aug 08 '19 at 20:54
  • I just fixed it, results it was because a dependent target was using a link to bad/corrupt of Alamofire framework. I fixed it by removing all the dependecies of Alamofire from that target in Build Phases and removing the framework from project too. And then I added the Framework again, this fixed my problem – Catluc Aug 08 '19 at 22:18
  • Just as @Tonny Xu mentioned. The solution is [here](https://stackoverflow.com/questions/42641806/check-and-remove-unsupported-architecture-x86-64-i386-in-ipa-archive). – Denny Oct 03 '19 at 09:12
  • Solution provided on following post worked for me https://stackoverflow.com/questions/42641806/check-and-remove-unsupported-architecture-x86-64-i386-in-ipa-archive – For Guru Feb 07 '20 at 07:54
  • 2
    Make sure your binary frameworks and pod framework paths are not included in `Build Phases -> Copy Bundle Resource` – Kuvonchbek Yakubov May 27 '20 at 11:58
  • Same problem with Xcode 12 on Mac with M1 chip. But I'm not sure if this counts for you, too: Switching from iOS Deployment target 10.0 to 13.0 solved the problem for me. (Also updating the project format to Xcode 12.0-compatible, but I have no idea if this is necessary or related). I found the answer here: https://stackoverflow.com/a/64932592/470964 – Sebastian Dec 04 '20 at 15:05

16 Answers16

58

I faced same issue.I have fix this issue used this script.
Please follow the same steps.

enter image description here

Build Phases -> plus button -> to create New Run Script Phase

 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"
echo $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH")

FRAMEWORK_TMP_PATH="$FRAMEWORK_EXECUTABLE_PATH-tmp"

case "${TARGET_BUILD_DIR}" in
*"iphonesimulator")
    echo "No need to remove archs"
    ;;
*)
    if $(lipo "$FRAMEWORK_EXECUTABLE_PATH" -verify_arch "i386") ; then
    lipo -output "$FRAMEWORK_TMP_PATH" -remove "i386" "$FRAMEWORK_EXECUTABLE_PATH"
    echo "i386 architecture removed"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_TMP_PATH" "$FRAMEWORK_EXECUTABLE_PATH"
    fi
    if $(lipo "$FRAMEWORK_EXECUTABLE_PATH" -verify_arch "x86_64") ; then
    lipo -output "$FRAMEWORK_TMP_PATH" -remove "x86_64" "$FRAMEWORK_EXECUTABLE_PATH"
    echo "x86_64 architecture removed"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_TMP_PATH" "$FRAMEWORK_EXECUTABLE_PATH"
    fi
    ;;
esac

echo "Completed for executable $FRAMEWORK_EXECUTABLE_PATH"
echo $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH")

done
Dilip Mishra
  • 1,422
  • 13
  • 17
  • I have done the same as explained. Build is created successfully. But when i installed it on my real device, app has been installed but the app icon is disabled. I didn't get any error. And unable to open the application – Aman Gupta Jun 08 '20 at 13:33
  • The most important thing to keep in mind is to add this Run script at the very end of BuildPhases. Specifically after 'Embed Frameworks' so that it makes sure that the unwanted architectures are stripped from all frameworks. – atulkhatri Jul 28 '20 at 14:11
49

1.uncheck "Rebuild from bitcode", 2.click next fast fast fast. (speed is also important.)

enter image description here

if not , it will show IPA processing failed. enter image description here

Zgpeace
  • 3,927
  • 33
  • 31
  • Thnx, man, I have react native frameworks in my app, they don't work with bitcode – Booharin Mar 18 '20 at 07:11
  • I have done the same as explained. Build is created successfully. But when i installed it on my real device, app has been installed but the app icon is disabled. I didn't get any error. And unable to open the application. – Aman Gupta Jun 08 '20 at 13:33
  • Hi @AmanGupta, I think you can debug you app in real device firstly with develop certificate. – Zgpeace Jun 09 '20 at 02:40
  • @Zgpeace can you let me know how to change it and run in the real device? – Aman Gupta Jun 09 '20 at 03:10
  • @AmanGupta Could you let me know whether you can debug your app in real device with develop certificate? I suggest that you can debug your app to find more logging in real device. – Zgpeace Jun 09 '20 at 03:26
  • @Zgpeace I have debug the app in debug mode and it is working fine but when i changed it to release mode. I am getting a error `Unable to open `. Any help how to get rid of this? – Aman Gupta Jun 09 '20 at 03:48
  • @AmanGupta, could you try to archive you app with debug mode? Click Edit Schema > Archive > Build Configuration change to Debug > close. – Zgpeace Jun 09 '20 at 04:09
  • @Zgpeace I am using One Signal Push Notification. I have set my one signal id same as my bundle id and then the push will work and the app will also work in debug mode. when i am trying to create a release build. The build created successfully but unable to open in real device. Also when i change my one signal bundle id then one signal throw an error `Bundle Mismatch error` – Aman Gupta Jun 09 '20 at 04:44
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/215561/discussion-between-zgpeace-and-aman-gupta). – Zgpeace Jun 09 '20 at 06:52
  • Yes, that actually works — I was able to do it once. But my iMac is so fast I can't click fast enough. Is there any other way to get that checkbox off? — “Edit Schema” – just for users who don't edit schemas on a daily basis: Where was that hidden again? – Martin Mar 03 '21 at 13:15
  • 1
    Not able to Uncheck. Before uncheck itself ipa processing fail screen comes. – Mihir Oza Jun 10 '21 at 13:58
  • This is one of the funniest answers I've ever seen ahha, cause it actually worked – Jalil Jun 28 '21 at 19:54
17

You should check the Embed Frameworks under Xcode > build phases.

If your framework is introduced here, you can't use i386\x86_64 in your framework. Because the Embed Frameworks are copied to the application. To control the size of the application, the frameworks in the Embed Frameworks are required to be the most streamlined.

You can use Link Binary With Libraries to introduce your framework, as described here: https://github.com/Carthage/Carthage/issues/1046

Note that you need to add a new Run Script and add your framework to it, or it will crash.enter image description here

nullLululi
  • 194
  • 1
  • 7
14

To solve similar problem on my end I used the following:

  • In app's target I went to the Build Phases
  • After the Embed Frameworks and Embed App Extensions sections I've added Run script with 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

The script I took from here: https://medium.com/@maximbilan/ios-submission-unsupported-architectures-issues-733917a98cc3, credits goes to Daniel Kennet!

Also, be aware that this script could also cause compilation errors. In such case, here's the solution: Errors building Xcode Project after adding in Run Script fatal error: lipo: input file

On my end I also noticed that I have to turn off this script when compiling app locally (on development devices/simulator)

Hope that helps!

wkukielczak
  • 429
  • 4
  • 8
8

It seems that a dynamic library with i386 or x86_64 architecture is not allowed when archive in Xcode 11. And I fixed it by removing those architectures from the mentioned frameworks

chenfeng
  • 93
  • 7
6

I had to uncheck "Rebuild from bitcode"

MobileMon
  • 8,341
  • 5
  • 56
  • 75
  • This immediately worked for me – thanks! I've no idea what the underlying reasons are (and it could well be to do with other architectures), but this seems worth a try. – Benjohn Nov 21 '19 at 10:14
  • Is there a way to do this without having to click? My computer fails much to fast. – Martin Feb 24 '21 at 11:45
  • Yes that works. But of a fast machine the error comes faster the you can click the checkbox. You need to try dozen's of times. There must be a better way. – Martin Mar 03 '21 at 13:22
  • If Bitcode disabled , Firebase Crashlytics will not work – mhammad alkhalaf Aug 21 '21 at 18:08
4

For those who try with M1 Chip (Silicon)

Quit Xcode completely (Close and Quit From the Menu Bar) and remove existing archived one.

Go to finder -> Applications

Right Click on Xcode and select "Get Info"

Check Rosetta

enter image description here

Try again opening Xcode

Muzahid
  • 5,072
  • 2
  • 24
  • 42
3

We've solved this problem by setting Always Embed Swift Standard Libraries to NO in all frameworks, that are being used in our app.

  • Thank you. Setting it to default 'NO' made it work and exported ipa file successfully. I guess swift libraries embedded in framework might cause app fail to enable bitcode for whole application. – DragonCherry Jan 15 '20 at 06:00
3

I had to select "Do not embed" in Frameworks to solve this

Josef Vancura
  • 1,053
  • 10
  • 18
2

Having Bitcode enabled caused the issue in my case. Go to

Build Settings -> Enable Bitcode and set it to NO.

Try archiving again and it should work.

Bijoy Thangaraj
  • 5,434
  • 4
  • 43
  • 70
1

In my case, app thinning was failing and the reason was my internal framework was depending Alamofire and it's binary was embedding and signing. Changing it's Embed option from Embed & Sign -> Do Not Embed solved my issue immediately.

In my opinion, all logic behind this issue is keep app bundle size lower as much as Apple can but embedding your frameworks increase this size. I think that's all App Thinning complains about. So, the general solution to this issue, check every external frameworks that can increase your app bundle. Especially, if you're using Carthage.

miletliyusuf
  • 982
  • 1
  • 10
  • 12
0

I found issue with SDWebImageMapKit framework available with SDWebImage. I just removed it and got success.

MD.
  • 1,157
  • 11
  • 18
0

My issue was that I had a single embedded binary framework.

I removed it from the project to update it. Which caused Xcode to delete the embed frameworks build phase (because there were no more frameworks to embed).

After adding the new version of our framework, the embed binaries phase was at the bottom of the build phase order. Which ended up being the reason it was failing.

I had to re-order embed frameworks before my run script to fix the problem.

Xaxxus
  • 1,083
  • 12
  • 19
0

I haven't updated my cocoapods for a while, fixed it by updating and re-installing the pods.

sudo gem install cocoapods
pod update
pod deintegrate
pod install
Kyle L
  • 681
  • 6
  • 9
-1

My solution was to set all frameworks dependencies to "Do Not Embed"

enter image description here

Husam
  • 8,149
  • 3
  • 38
  • 45
-2
  1. Open Terminal


  2. Open your project drag path of respective framework to Terminal 
For example.

     cd /Users/xxxxx/Desktop/MyProject/ABC.framework


  3. Set your Framework name in below command and run

    
lipo -remove i386 ABC -o ABC && lipo -remove x86_64 ABC -o ABC

  • 2
    Welcome to StackOverflow. When answering a question, please also provide an explanation that explains why the problem exists and how your solution solves it, so that people can actually understand rather than just making the problem go away. – Alan Apr 02 '20 at 06:18