Application builded using Dynamic framework not submitted to app store - ios

I have created Dynamic Framework , While importing this dynamic framework into Application it needs to be add in Embedded Binaries.
it is working with Both Device and Simulator but when i archive and make .IPA file to submit , I got Below error while submitting app to app store.
1) ERROR ITMS-90087: "Unsupported Architectures. The executable for sample.app/Frameworks/customFramework.framework contains unsupported architectures '[x86_64, i386]'."
2) ERROR ITMS-90209: "Invalid Segment Alignment. The app binary at 'sample.app/Frameworks/customFramework.framework/CustomFramework' does not have proper segment alignment. Try rebuilding the app with the latest Xcode version.”
3) ERROR ITMS-90125: "The binary is invalid. The encryption info in the LC_ENCRYPTION_INFO load command is either missing or invalid, or the binary is already encrypted. This binary does not seem to have been built with Apple's linker.”
4) WARNING ITMS-90080: "The executable 'Payload/sample.app/Frameworks/customFramework.framework' is not a Position Independent Executable. Please ensure that your build settings are configured to create PIE executables. For more information refer to Technical Q&A QA1788 - Building a Position Independent Executable in the iOS Developer Library."
Any insights into this would be really helpful.

This is normal if you make fat dynamic framework, they don't let the simulator architecture to be submitted (but it work with static library), the easiest way to solve it is to borrow the solution from other framework, eg Realm, they provide a script to strip out the simulator architectures out of the framework, so that the app can be submitted to appstore, check out their installation for framework version to include and use the script for your framework

Related

Error upon app archive: Found an unexpected Mach-O header code: 0x72613c21

Im trying to archive our app to appstore. But when i do i'm receiving above error.
Platform: iOS
OS version: 14.4.2
Device manufacturer / model: iphone SE
React Native version (react-native -v): 0.64
xcode version: 12.4
I've been in touch with the guy behind the library react-native-background-fetch and asked him about the issue but i'm thinking there is another reason behind the problem.
This is the first time i'm getting this error so i'm not sure what to do.
IDEDistrubution.verbose.log
2021-04-22 14:55:50 +0000 Unable to determine platform from macho "/Users/joakimwennergren/Library/Developer/Xcode/Archives/2021-04-22/ActiveQuiz 2021-04-22, 16.54.xcarchive/Products/Applications/ActiveQuiz.app/ActiveQuiz-mobile-app/node_modules/react-native-background-fetch/ios/RNBackgroundFetch/TSBackgroundFetch.xcframework/ios-arm64_x86_64-maccatalyst/TSBackgroundFetch.framework". Failed with error: "Failed to discover platform for executable /Users/joakimwennergren/Library/Developer/Xcode/Archives/2021-04-22/ActiveQuiz 2021-04-22, 16.54.xcarchive/Products/Applications/ActiveQuiz.app/ActiveQuiz-mobile-app/node_modules/react-native-background-fetch/ios/RNBackgroundFetch/TSBackgroundFetch.xcframework/ios-arm64_x86_64-maccatalyst/TSBackgroundFetch.framework/TSBackgroundFetch"
TL;DR: I made a video to show how to fix the problem https://www.youtube.com/watch?v=Ah9aXs9lTD0 -- the following is a shorter version of the details that are shared in this article: https://christiantietze.de/posts/2021/07/mach-o-0x72613c21-static-library/
Code 0x72613c212 indicates that you are embedding a static library in your app bundle. That's not necessary, because static libraries already are merged with your app binary at build time by the linker.
Usually, .framework bundles are embedded into app bundles and then loaded when you run the app. These are dynamic libs; static libs are already 'in' the app binary, so they don't need to be shipped with the app bundle again. That's why Xcode complains.
How to Diagnose
An Apple Technical Note (TN2435) explains this:
This [Found an unexpected Mach-O header code: 0x72613c21] is caused by placing a static library in a bundle structure that looks like a framework; this packaging is sometimes referred to by third party framework developers as a static framework. Since the binary in these situations is a static library, apps cannot embed it in the app bundle.
From the Technical Note, here's how you can find out if a binary is a static library:
file <PathToAppFramework>/<FrameworkName>.framework/<FrameworkName>
The output could be like:
Mach-O universal binary with 2 architectures
<PathToLibrary> (for architecture armv7): current ar archive random library
<PathToLibrary> (for architecture arm64): current ar archive random library
For dynamic libraries that do need to be embedded in the app, the output instead says something like Mach-O 64-bit dynamically linked shared library x86_64
How to Fix
If your file output looks similar, the solution is to link but not embed:
This will include the static library in the build product right away.

SKMaps - App Errors Uploading To iTunes Connect - Invalid Binary - Segment Alignment - Encryption

I am trying to upload my app with SKMaps.framework to the App Store. App runs perfect on simulator and device.
But I get the below errors uploading build to iTunes Connect.
Dear developer,
We have discovered one or more issues with your recent delivery for
"xxxx xxxx". To process your delivery, the following issues must be
corrected:
Invalid Binary Architecture - iOS 3.0 introduced support for multiple
binary architectures. If your binary is built for multiple
architectures, your Info.plist must have a MinimumOSVersion key with a
value of at least 3.0. Additionally, if your app is intended to
support earlier iPhone and iPod touch models, your app must contain at
least an armv6 binary; "thin" armv7-only binaries will not be accepted
unless the armv7 required device capability is also present in the
Info.plist UIRequiredDeviceCapabilities key or the MinimumOSVersion
key has a value of 4.3 or higher.
Specifically, we found the following unsupported architectures in your
binary:
x86_64 i386 For more information, see Technical Q&A QA1707 at:
http://developer.apple.com/iphone/library/qa/qa2010/qa1707.html.
Invalid Segment Alignment - The app binary at 'xxxx
xxxx.app/Frameworks/SKMaps.framework/SKMaps' does not have proper
segment alignment. Try rebuilding the app with the latest Xcode
version.
Invalid Encryption Info - The binary is invalid. The encryption info
in the LC_ENCRYPTION_INFO load command is either missing or invalid,
or the binary is already encrypted. This binary does not seem to have
been built with Apple's linker.
Though you are not required to fix the following issues, we wanted to
make you aware of them:
Non-PIE Binary - The executable 'Payload/xxxx
xxxx.app/Frameworks/SKMaps.framework' is not a Position Independent
Executable. Please ensure that your build settings are configured to
create PIE executables. For more information, refer to Technical Q&A
QA1788 - Building a Position Independent Executable
Once the required corrections have been made, you can then redeliver
the corrected binary.
Regards,
The App Store team
Without this framework, my app is totally useless. The framework version is 3.0.1.
Just use the build without the simulator slice, this should solve you problem. You can find the latest build here: http://forum.skobbler.com/showthread.php/14602-3-0-3-release-candidate-builds?p=32322

How to debug "Invalid Bundle" error which happens only after submitting to app store

I have a lot of frameworks in my app. App works fine in adhoc/enterprise release. Only if I submit to the app store for testflight testing I get this error email from apple:
Dear developer,
We have discovered one or more issues with your recent delivery for "My app's name here". To process your delivery, the following
issues must be corrected:
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
Once these issues have been corrected, you can then redeliver the corrected binary.
Regards,
The App Store team
there is no specific information here. How can I debug it?
Got an answer from Apple Developer Technical Support which says it is a bug on Apple's side. this is the suggested workaround below which did not work for me:
To diagnose this issue, you should export the IPA you are sending to
the App Store from Xcode. Since IPAs are zip files, you can
decompress it by right clicking and saying Open With > Archive
Utility. You should find your main executable inside the unzipped
folder structure and run otool at the command line to see the library
list: otool -L
The list of paths you get should match what you find inside of your
IPA. All of your libraries should start with #rpath. A simple
comparison of everything in this list with the unzipped IPA folders
should reveal what is missing.
Once you know what is missing, go to your Xcode build phases setup.
There should be a build phase for either Copy Files or Embed
Frameworks that includes the missing library — you should just add the
library to the list. If you don’t see either of these build phases,
you can recreate it by adding a new Copy Files build phase, setting
the Destination to Frameworks, and adding the library to the list,
ensuring that Code Sign On Copy is checked.
If you don’t find anything missing in your main binary, make sure to
do the same search on any other binaries you may have, like for a
watchOS app or an iOS app extension.
If you find that all of the frameworks are in this build phase, please
take a look at the Embedded Binaries section of your app target’s
General page, and let me know if you see multiple levels of ../ next
to the binary that you found is missing.
Please let me know if it works for you!
I have encountered the same issue when uploading an app with watch support to the app store.
I was able to solve it with the hint from the first answer, using otool -L to analyze the binary from the ipa or xcarchive.
However, the problem was not with my frameworks (at #rpath) but with a swift lib. I noticed that libswiftWatchKit.dylib was missing in the frameworks folder.
The solution that worked for me was as simple as to set EMBEDDED_CONTENT_CONTAINS_SWIFT=YES in the build settings of the watch app (or the watch app extension, but not both). After that, all necessary swift libraries were correctly copied to the watch app path in the archive and upload to app store was working correctly.
Apparently, the watch app works and upload passes if you provide the necessary swift libraries only in the main app's folder.
After adding the custom Swift framework to my project I got this email after uploading the app to iTunes connect.
I got this email from iTunes store,
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
The fix is simple for this issue,
Step 1: Make sure your Custom framework is added to Embedded Binaries in General tab of your target.
Step 2: Under build settings,
Set Always Embed Swift Standard Libraries = Yes for your main project target.
And Set Always Embed Swift Standard Libraries = No for your custom framework target.
This solved my problem and I was able to upload binary to iTunes connect.
Ref
Tried all the above solutions and did not work for me.
I was experiencing this issue in Xcode 10.1 recently and all my frameworks were referenced correctly (did otool -L and everything lined up).
Seems there were some changes in the apple validation process, may be a bug, may not be on Apple's end, but all my prior builds uploaded and validated fine -- and I did not add any new frameworks since.
Upon uploading the binary to iTunesConnect, I'd see the following error:
Invalid Bundle - One or more dynamic libraries that are referenced by
your app are not present in the dylib search path.
Invalid Bundle - The app uses Swift, but one of the binaries could not
link to it because it wasn't found. Check that the app bundles
correctly embed Swift standard libraries using the "Always Embed Swift
Standard Libraries" build setting, and that each binary which uses
Swift has correct search paths to the embedded Swift standard
libraries using the "Runpath Search Paths" build setting.
MY SOLUTION:
After days of debugging, what worked for me was to disable 'Include bitcode for iOS content' upon uploading the archive from Xcode organizer. Seems that this option modifies the binary which caused the validator to fail.
Or you can disable bitcode in your Build Settings
My Problem:
I had the same error with embedded frameworks.
The App project has Custom Framework project
Inside the Custom Framework project is another Custom Framework project
The app built to the simulator and to devices with no problem but failed the Apple test, returning "Invalid Bundle".
I inspected the package just like Taha had been told to by Tech Support and everything was present and correct!
My Solution:
I restructured the project so that the two custom frameworks sit side by side and one is no longer embedded within the other.
This looks to be an Apple validation problem since everything works fine on devices and the simulator but the work around was straight forward.
In my case, in the build settings, this was fixed when I added the following to the build settings for the library:
DYLIB_INSTALL_NAME_BASE = #rpath
The clue was a linker warning: 'YourLibrary has an install name beginning with “/”, but it is not from the specified SDK'
Had same issue. This happened to me because one of my Framework target was added to main target in "Link Binary With Libraries" but was not added to "Target Dependencies" and "Embedded Binaries"
I also received a similar mail from Apple:
Dear Developer,
We identified one or more issues with a recent delivery for your app,
"********. Please correct the following issues, then
upload again.
ITMS-90562: Invalid Bundle - One or more dynamic libraries that are
referenced by your app are not present in the dylib search path.
Best regards,
The App Store Team
I used my own framework for my watch app. I solved this issue by changing the framework option to "Embed Without Signing" in the Extension Target. The default option was "Do Not Embed".
I had the same problem, it was due to one framework not being present in the Frameworks subfolder in the app bundle.
I fixed it by adding a Copy Fields build phase, and adding the missing .framework file there.
This error message is also addressed in Apple Technical Note TN2435
Embedding Frameworks In An App: https://developer.apple.com/library/archive/technotes/tn2435/_index.html
You can find the error message under the heading "Missing Framework Bundle" with troubleshooting steps.
We had the same problem, and even after going through all the steps (see "Missing Framework Bundle"), the only thing that worked was disabling Bitcode.
So I struggled on this for two days. What it turned out to be was I had UITests checked in Archive for the Build for the Scheme I was archiving.
After unchecking it from Archive, re-archiving it, validating it (although validating it before always passed), and "Upload to AppStore" I did not get the e-mail from Apple informing me of Invalid Swift Support. Instead I got the e-mail that it'd been processed and is good to go!
In my case, I've had to add a framework from Notification App Extension to the main target (embed & sign in the main target, do not embed in the extension) - even though there was no mention about it in otool -L output.
Funny thing that Iterable official doc says that the framework should be embedded & signed in the extension - which would lead to another upload problem because of nested bundles.

Sudden Error when Uploading to iTunesConnect: ITMS-90635 Invalid Mach-O Format / ENABLE_BITCODE

Last week i was able to upload my ipa to iTunesConnect just fine. But as of today I am getting the following error when uploading via Application Loader:
ERROR ITMS-90635: "Invalid Mach-O Format. The Mach-O in bundle "Application.app/Frameworks/PSPDFKit.framework" isn’t consistent with the Mach-O in the main bundle. The main bundle Mach-O contains armv7(machine code) and arm64(machine code), while the nested bundle Mach-O contains armv7(bitcode and machine code) and arm64(bitcode and machine code). Verify that all of the targets for a platform have a consistent value for the ENABLE_BITCODE build setting."
I am aware of the solutions proposed here: Xcode - Error ITMS-90635 - Invalid Mach-O in bundle - submitting to App store and in many others.
I have however no idea how to apply any of the proposed solutions to a Xamarin iOS project. I am not using any pods, instead I am using a Binding library for PSPDFKit, which I have created as described in the official documentation https://pspdfkit.com/guides/ios/current/other-languages/xamarin/.
As far as I can see there are two ways for me to go, either to enable bitcode in my project (which I have no idea how to do) OR to disable bitcode in the binding project for PSPDFKit (which I have also no Idea how to do).
I am grateful for any help or propositions.
I finally was able to do it, with one of the solutions from this post https://stackoverflow.com/a/37624641/2702513
What I had do do, was stripping the Bitcode from my library, which can be done with this command:
$ xcrun bitcode_strip -r {PATH_TO_LIBRARY} -o tmp.dylib
The command extracts the machine code from the library into the tmp.dylib file which then can be used instead of the library itself. In case of PSPDFKit the library is inside the framework.

Can I use swift sdk in app which runs on iOS 7?

I'm trying to develop a swift SDK that will work in apps running on iOS 7,
I don't care if my SDK will work only when the app is running on iOS 8 but I don't want to force the target app to run only on iOS.
when I tried to change my Deployment Target to 7.0 and upload the app to appstore I'm getting the following errors:
Archive submission failed with errors:
! ERROR 'TMS-90362: "Invalid Info.plist value. The value for the key
•MinimumOSVersion• in bundle MiniAppDemo.app/Frameworks/
MiniAppFramework.framework is invalid. The minimum value is 8.0"
ERROR IT MS-90362: "Invalid Info.plist value. The value for the key
'MinimumOSVersion' in bundle
MiniAppDemo.app/Frameworks/MiniAppFramework.framework is invalid. The
minimum value is 8.0"
ERROR ITMS-9020g: "Invalid Segment Alignment. The app binary at
'MiniAppDemo.app/Frameworks/MiniAppFramework.frameworW
MiniAppFrameworkl does not have proper segment alignment. Try
rebuilding the app with the latest Xcode version." ERROR IT MS-90209:
•Invalid Segment Alignment. The app binary at
'MiniAppDemo.app/FrameworksWiniAppFramework.frameworWMiniAppFramework'
does not have proper segment alignment. Try rebuilding the app with
the latest Xcode version."
ERROR 'TMS-90125: "The binary is invalid.
The encryption info in the LC ENCRYPTION INFO load command is either
missing or invalid, or the binary is already encrypted. This binary
does not seem to have been built with Apple's linker." ERROR
ITMS-g012S: •The binary is invalid. The encryption info in the load
command is either missing or invalid, or the binary is already
encrypted. This binary does not seem to have been built with Apple's
linker. • WARNING ITMS-900BO•. "The executable
'Payload/MiniAppDemo.app/Frameworks/MiniAppFramework.framework' is not
a Position Independent Executable. Please ensure that your build
settings are configured to create PIE executables. For more
information refer to Technical Q&A QA178B - Building a Position
Independent Executable in the iOS Developer Library." WARNING IT
MS-90080: 'The executable
'Payload/MiniAppDemo.app/Frameworks/MiniAppFramework.framevvork' is
not a Position Independent Executable. Please ensure that your build
settings are configured to create PIE executables. For more
information refer to Technical Q&A QAI 788 - Building a Position
Independent Executable in the iOS Developer Done Library. "
Check Alamofire for the same issue :
"Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks.
To use Alamofire with a project targeting iOS 7, you must include all Swift files located inside the Source directory directly in your project. See the 'Source File' section for additional instructions."

Resources