iOS Embedded Framework with Embedded Framework - ios

I'm working on a framework which embeds another framework (from CocoaPods) for error logging on iOS. This is working very well, and I can embed such a framework in an iOS application for testing, codesign everything, and debug on my own device easily. Unfortunately, when attempting to upload such an application to Apple for distribution, I get an error message as such:
Invalid Bundle. The bundle at '<myapp>.app/Frameworks/<myframework>.framework' contains disallowed file 'Frameworks'. With error code STATE_ERROR.VALIDATION_ERROR.90206 for id ***
I'm not sure if this message indicates that I'm not allowed to embed a framework in another framework or what. It seems the automatic codesigning Xcode is doing is not recursing to the deepest embedded framework upload (I have a script to manually sign everything on build). Does anyone have experience with an error like this or know where to look? It seems others have asked questions about embedding frameworks in other frameworks before, but most of these are how to get linking to work or how to properly reference these nested frameworks. My issue is specifically if I am allowed to upload such things to test flight/the app store, and how to do so if it is possible. Most people having this issue seem to have disabled swift support, but none of the projects I'm using have swift code.

Nested bundle cannot include a framework. You can check this apple document.
iOS and tvOS support frameworks and Swift system libraries at the topmost app level; a nested bundle, like an app extension, can’t include a framework.
And there is a warning block that worth being noticed:
If you put content in the wrong location, you may encounter hard-to-debug code signing and distribution problems. These problems aren’t always immediately obvious. For example, when building a Mac app, incorrectly placed code might work during day-to-day development, but might cause problems during notarization.
So that is the reason everything seems normal while running in debug mode but failed at distribution.

Related

XCode Project Invalid Bundle on App Store Upload

When submitting our app to the app store the validation process for the build keeps getting rejected with the following error.
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
Has anyone else had issues with this error? I feel like I've tried just about everything. I'd done the suggested otool -L on the main app as well as the watch app. The only library that it shows linked for is the Mixpanel library. The only other two libraries we are using is Fabric and Crashlytics. From my understanding those are not actual real frameworks? I've also tried to set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES as many posts online suggest. The project builds and runs fine so I'm completely lost as to how to resolve this issue.
This is a React Native iOS app if that has anything to do with it. I'm not the most experience when it comes to iOS stuff but I can find my way around xcode. Anyone have any suggestions? Maybe the best solution is to just create a new xcode project and set everything up again and copy/paste in the code from the previous project?

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.

iOS App Enterprise Deployment: Provisioning Profile for Libraries

We are currently trying to deploy a new version of an iOS Enterprise App via Mobile Device Management after some changes in architecture.
The same app has succesfully been deployed a couple of times in the past, but we recently added a library to the app (in order to reuse some of our code in different places).
The app runs fine when started from Debugger, but crashes immediatly after start when signed and deployed via Mobile Device Management. iOS Crashlog reveals that the library we added does exist but is not loaded.
The error message reads:
Dyld Error Message:
Library not loaded: #rpath/MYAPPLib.framework/MYAPPLib
Referenced from: /private/var/mobile/Containers/Bundle/Application/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/MYAPP_iOS.app/MYAPP_iOS
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/MYAPP_iOS.app/Frameworks/MYAPPLib.framework/MYAPPLib: mmap() error 1 at address=0xXXXXXXXX, size=0xXXXXXXXX segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/MYAPP_iOS.app/Frameworks/MYAPPLib.framework/MYAPPLib
(The bundle identifier and application name have been changed)
We suspect that this might be a signing issue. After archiving the product and exporting ("Save for Enterprise Deployment"), we noticed that no Provisioning Profile is selected for said library (see screenshot below)
Long story short, the question is:
Is it necessary for a library in an iOS App to have a Provisioning Profile? If so, how can I assign one?
All right, so we are still not sure what exactly the problem was. But we can say that the error was resolved by issuing a new developer certificate. So if you are facing the same problem, maybe you want to try this as well.
From the console seems that the app does not find the framework file.
Make sure in your Build Settings you set the Runpath Search Paths to #executable_path/Frameworks
Make sure in Build Phases to have your Framework under Embed Frameworks.
Add your framework under Link Binary With Libraries.
If your framework is developed under same project make sure you make sure you have it under Copy File under Build Phases.

Framework CFBundleIdentifier Collision

I've made a custom SDK using Cocoa Touch Framework (followed these instructions to make it https://kodmunki.wordpress.com/2015/03/04/cocoa-touch-frameworks-for-ios8-remix/) .
One app, that is using this SDK is already uploaded to app store and is reviewed by apple and all is well.
Now I'm trying to submit second app to App store. All is well on the xCode, it shows that upload was completed successfully, but few minutes after uploading I get a letter that says:
CFBundleIdentifier Collision - The Info.plist CFBundleIdentifier value
'com.company.MySDK' of 'myApp.app/Frameworks/MySDK.framework' is
already in use by another application.
I don’t understand why apple even checks the app framework's bundleidentifier. Looks like there are lot of similar issues with using different bundles, but I haven not found a fix that would work for this issue.
Would be really thankful for help, thanks!
For me it was caused by framework's .plist keyword CFBundlePackageType that was using the default value APPL but had to be changed to FMWK (https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-111321).
if you are using Nested frameworks use "Do Not Embed" in the general tab-> framework and libraries
for example:
your project uses framework A and
and framework A uses frameworks B, C, ... Do not Embed these frameworks

Invalid Signature - Code object is not signed at all

Im able to submit my app through Xcode 6.3.2 perfectly fine. Validation and analyzing pass perfectly. Once it successfully submits to the app store though I get an email from Apple:
"Dear developer,
We have discovered one or more issues with your recent delivery for "App". To process your delivery, the following issues must be corrected:
Invalid Signature - Code object is not signed at all. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. Verify that the code signing settings in Xcode are correct at the target level (which override any values at the project level). Additionally, make sure the bundle you are uploading was built using a Release target in Xcode, not a Simulator target. If you are certain your code signing settings are correct, choose "Clean All" in Xcode, delete the "build" directory in the Finder, and rebuild your release target. For more information, please consult https://developer.apple.com/library/ios/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html
Once these issues have been corrected, you can then redeliver the corrected binary."
I have tried redownloading the distribution cert, regenerating the distribution provisioning profile, added "--deep" to the code signing "Other Code Signing Flags." I even checked the bundle name etc, everthing is alpha numeric. I was able to submit fine on May 22nd, now on June 3rd everything breaks.
Doesnt make any sense, any help would be appreciated!
UPDATE & SOLUTION:
While I don't have a good explanation of why this suddenly has happened within the last week, I finally found a solution this morning.
I started with a new project and submitted to the app store with nothing but the identifier and correct version and build numbers, which processed fine. After that I started piecing in any assets that wasnt my own code until I got the "Invalid Binary" email. I narrowed it down to the Hockey App SDK (embedded framework) which was causing the issue and not even being used anymore so I removed it from the project (problem solved). The disturbing part is that nothing fails on my end during validation or submission and according to github this directory and content hasn't changed in a year, which leads me to believe something changed server side at Apple.
I did see a lot of posts via google saying that frameworks needed signed etc and when using Xcode 6 and iOS 8 it seems to be the standard which is why I assumed it might be something along these lines.
Im not sure how helpful this is as I was building for iOS and this article is in reference to Mac, but HockeyApp explains in order to distribute to the app store you need to sign the framework with your own identity here:
http://support.hockeyapp.net/kb/client-integration-ios-mac-os-x/hockeyapp-for-mac-os-x
If anyone has anymore technical notes on this or why this suddenly changed Id love to understand this better.
I've checked a variety of places and there seem to be several things that are now being rejected by iTunes Connect. The solution is typically to remove the offending resource from the Target -> Build Phases -> Copy Bundle Resources (as #azizus mentions). Unfortunately Apple doesn't tell you what file causes this issue with your builds so you have to go hunt for yourself. Here are some items that I've found that will do it:
Shell scripts (Look for .sh files, though they could have a different
extension)
Also, look out for files that are listed as executable, when they
shouldn't be. Those might be a good place to look for shell scripts
that you might have missed.
Frameworks (Framework bundles, even .a or .o files - you
don't need them as they will get compiled into the executable binary)
DocSets (I don't know why, but I found that the HockeyApp SDK
includes a DocSet bundle which was the cause in my experience)
Sometimes this might also happen due to some weird entitlements
issue. The entitlements you have may not match up with the App in the
provisioning portal.
Look out for invalid characters in your app name or file names (like
wildcard characters)
This is a pretty broad list, something I did to help in the search is build an archive and then show the contents of the .app in the archive using finder, sorting by file type. The strange thing is that these files actually exist in the _CodeSignature/CodeResources file.
My own theory on why this is happening is that Apple made some changes (or is making some changes) because of Extensions and WatchKit apps. Essentially, you are including a couple of binaries in the packaged IPA (phone app, extension, watch app). They probably want to make sure you're not including something else that could potentially be executed. Unfortunately, the error message is too vague (really it's incorrect) for most.
This took me 3 days to debug.
In the end it was due to an external framework I created (lets call it X) that I was importing via carthage. X had its own dependencies that it was importing via carthage as well. In order to link these frameworks it had a path in the build settings called Framework Search Paths set to the location of the frameworks. For some reason it was this flag in this framework that was causing the problem specified in the questions. I eventually imported X's dependencies with Git submodules so that I didn't have to set the Framework Search Paths flag. I the exported the framework and manually added it to my project I was submitting to the AppStore. Then it worked.
I can reproduce this when I 'create folder references' for my resources folder as opposed to 'create groups' when adding in.
I contacted HockeyApp and they suggested not to add the SDK to app bundle. So I navigated to Target -> Build Phases -> Copy Bundle Resources and removed HockeySDKResources.bundle from there. iTunes Connect accepted my binary.
In my case it was a info.plist duplicated that was not used. (it wasn't easy find out the problem). I removed almost all the files of my project until remove this one and.. it worked
Clearing the value for Code Sign Resource Rules Path in each target resolved the issue.

Resources