iMessage app, "disallowed nested bundles" error trying to archive/upload with binary framework - ios

I have an iMessage app (not an app with an iMessage extension) in which I have successfully added a binary framework (the project runs just fine on device and simulator)
However, I cannot successfully upload the project to App Store Connect - upload from the archive build returns the following errors:
The relevant text of the error is:
The bundle ... contains disallowed nested bundles. Refer to https://developer.apple.com/go/id=framework-imessage
That link (if you follow the instructions for using an newer Xcode version) leads you back to the link below I used to add the framework to begin with... to run you will need Xcode 11 as I am using an XCFramework.
I added the framework to the iMessage app as instructed by Apple here:
https://developer.apple.com/library/archive/technotes/tn2435/_index.html
(see Embedding a Framework in an iMessage App section)
What do I need to change to the settings for the project or extension in order for the archive/upload process to succeed, while actually including the framework I need? I have searched on StackOverflow, and found a variety of posts related to cocoapods, or around various build settings of "Always Embed Swift Standard Libraries" that do not help.
I have reduced the problem down to a simple sample app you can see here, which builds and runs just fine but cannot be archived and uploaded:
https://www.dropbox.com/sh/jpa4oe7zlnb21wl/AACXkLbxIbayZUtJr3VDwO07a?dl=0
That directory contains a zip file of the project, and an image showing the error encountered.

You have .xcframework in your project. May be you haven't enable Build Libraries for Distribution in Build setting when you have build .xcframework. You can refer this link for this.
Edit:
Error message is Invalid Bundle. So check bundle name of message extension and frameworks which are in the .xcframework.

I've made a few changes regarding the stub app, it seems to work and validate ok.
Remove the Embed Framework from the extension target.
Add the Embed Framework in the app target, set the Destination to 'Frameworks'

Related

How can I properly share the Amplify framework with my Main App and my App Extension for an iOS app?

I have an iOS app using AWS amplify for the backend. I am using Xcode 13 and SwiftUI.
I previously added the Amplify framework using Cocoapods however I was unable to get the framework to work with the extension.
So I recently switched to Swift Package Manager. I added the package to my main project. Then I went to my Share Extension and in General - Frameworks and Libraries and manually added the libraries.
After doing this the app builds and runs and both the main app and extension work fine and are able to use the libraries.
The problem is that I cannot archive and upload the app to the App Store. I get the following error:
CFBundleIdentifier Collision. There is more than one bundle with the
CFBundleIdentifier value 'com.amazonaws.AWSAuthCore' under the iOS
application 'MyAPP.app'. With error code
STATE_ERROR.VALIDATION_ERROR...
I went on many forums and spent many hours trying to fix this but to no avail. The suggestions are to click 'do not embed' for the libraries but that option is not available for me.
I wonder if there is anyway to resolve this?
Below are my General and Build Phases for the Share Extension:
Just remove explicit Amplify dependency from extension, ie. next section should be empty
Make sure (it should be automatically, but anyway)
Link Frameworks Automatically parameter (in Build Settings) is true
Runpath Search Path parameter is related to main bundle
So as targets from SPM are built in same location as product and extension and automatic framework linking is enabled the imported modules in extension will available and linked automatically and due to run paths are set the frameworks will be found in run-time as well.
Note: of course in main app target all should be included
Tested with Xcode 13.1 / iOS 15.1

Can't submit iOS app to iTunes connect when using a SPM package

When I try to submit an iOS app that includes an SPM package which uses the new binary target the submission fails with the following two errors:
Invalid Swift Support. The file MyApp.app/Frameworks/libHello.a doesn’t have the correct file type for this location. Ensure you’re using the correct file, rebuild your app using the current public (GM) version of Xcode, and resubmit it.
Invalid Bundle Structure - The binary file 'MyApp.app/Frameworks/libHello.a' is not permitted. Your app can’t contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the iOS app bundle structure.
I believe it's to do with SPM as when I manually drag the Hello.xcframework package to the project it allows me to submit successfully.
Trying to do other things like changing Xcode build settings, customising the package.swift and using lipo to make sure the architecture slices are valid doesn't lead to anyway.
I looked at the embed framework in Build phases, it's not been included only in the link framework phase. One thing I noticed is when I archived the app the static library libHello.a was in the app's framework folder, which is weird since it shouldn't be there as they are integrated with the app binary. When I delete that file I can continue the app submission without any issues. But I don't think this workaround would be ideal long term.
I've created a simple static library with one class and method to keep thing simple. I then use Xcode archive the resulting static library in an XCFramework using xcodebuild -create-xcframework. See Github Repo: https://github.com/shams-ahmed/Hello
Steps to reproduce:
Create a new Xcode project
Add the Hello SPM package using the SPM interface with URL: https://github.com/shams-ahmed/Hello
Archive the project
Validate the App
You can deselect all the options
Fails with the above error message
What do I need to do to get SPM working with a static library? This is now meant to be supported with Xcode 12 and Swift 5.3
Info:
Xcode 12.0
Swift 5.3
Using a new Xcode project
P.S must use a static library
Looks like it's not possible with static libraries (.a files) because .binaryTarget with a xcframework is associated with dynamic frameworks and XCode just copy a platform depended entity from the xcframework to Frameworks folder of your .app instead of linking to your application's binary.
XCode build log:
PBXCp .../Hello.xcframework/ios-x86_64-simulator/libHello.a .../Test.app/Frameworks/libHello.a
There are two solutions:
Compile library sources as dynamic frameworks and make the xcframework from them.
If you have .a files only you can make dynamic frameworks wrappers which link static libraries and provides API access to them and then make the xcframework.

Non-public API usage: The app references non-public symbols: __XCTFailureFormat, __XCTFailureHandler

I am using react-native to build iOS app. I have successfully uploaded the app to app store but itunes sent me this email, saying that there are some issues in my app so I can not upload this build.
I have searched for the symbols in my whole react-native project. There are no results were found that match the __XCTFailureFormat or __XCTFailureHandler. How can I solve this?
I don't think this is an issue with React. __XCTFailureFormat and __XCTFailureHandler are part of XCTest, the unit testing framework.
My guess is that you have unit test files compiled and bundled in the target you use for AppStore release.
In the project view in Xcode, select the target used to release on the App Store, then go into the Build Phases tab and search for files that should be in the Compile Source section.
Usually, unit tests filenames end with Test so it's easy to use the search filed to filter the list. Then, just remove these files and re-upload a new binary to the App Store.

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.

Issue with nested Framework for Watchkit Extension

My Watchkit app does not work in production (TestFlight && rejected from AppStore).
I think the issue come from a nested framework. Here the architecture :
I've made a framework "ModelLayer" (Cocoa Touch Framework) with the app's model, so it can be shared across all targets. This framework use another third party framework (UICKeyChainStore.framework).
And the apple watch extension use "ModelLayer".
When debugging everything works fine. But when I uploaded the archive on iTunes connect I had an error saying that nested frameworks where not allowed. So I removed the copy file phase that I had in the Build Phase of "ModelLayer"'s target. It did not worked well as the app has been rejected...
I found some threads on internet that says that the copy file phase should have as Destination 'Shared Frameworks' and not 'Frameworks' (as I've done before). So I tried this, I've uploaded a pre-release of my app on itunes connect and tried the app with testflight. The app is now on my Apple Watch, but impossible to load the app. The loader stay on screen.
Did I miss something ? How can I use UICKeyChainStore.framework in my 'ModelLayer' framework ??
Thanks in advance !
So I found the solution.
The third party framework in my custom framework was not the problem. But It was my custom framework in the watch kit extension. So it's not possible to embed directly a framework in an extension. The framework should be embedded by the main app. And the extension will be able to use it.
Add the framework to the main app target
In Build Phases Tab
Use the framework in extension target
In General Tab
And in Build Settings Tab -> Linking
Add #executable_path/../../Frameworks to Runpath Search Paths

Resources