Validation Error: The bundle contains disallowed nested bundles - ios

As a followup to my other question, I'm continuing to have issues submitting my iOS 8 app (which includes a Sharing Extension and a framework target). On a submission attempt I receive the above error message. Others with my issue (as pointed out in the afore-linked question) have the same issue, but resolved it in ways that aren't relevant to my case.
The error message implicates my Sharing Extension target, which links to a framework that I wrote, which is shared between the Extension and the app. I'm pretty sure Apple was clear that I'm allowed to use frameworks in Extension targets (in fact, it's preferred!). So what other causes might there be for this error?

Well, the answer seems simple enough: in the Extension target I was embedding the framework (Build Phases > Embed Framework). Once I removed that setting, everything works fine.
Sigh.

I had to remove
(Build Phases > Embed Pods Frameworks)
From the today excitation.
Was able to upload to appstore but this bring other problem the today excitation is not working
dyld: Library not loaded: #rpath/AFNetworking.framework/AFNetworking

For me, Aaron's answer was only half the answer.
After removing my framework from my extension's Embedded Binaries, I had to add it to my extension's Linked Frameworks and Libraries.
(Both can be found in the extension's General tab.)

Related

Xcode automatically renames libraries inside the library

I have an issue and I guess somebody can help me to resolve it.
So, I created my own framework from my code and I added dependent frameworks in it. That's OK.
There is the struct of it:
After that I've implemented my own framework into my app. I can launch app without any issues on my real device. There are no any issues with it. My framework works as expected.
I need publish my app with implementation of my own framework. And I see that for some reason the frameworks inside my framework have the same name:
Although it should be 7 frameworks with names as in the structure. As result I see the error from Apple:
The question is: why did my internal frameworks get the same name when trying to publish and how to fix it?
Please check under your "Build Settings" option, there is "Build Options", check if below setting is switched to "Yes".

The bundle at … contains disallowed file 'Frameworks'

I'm trying to deploy a .dylib library wrapped in a framework, and I'm experiencing the following issue: 'ERROR ITMS-90206: "Invalid Bundle. The bundle at X.app/Frameworks/PoemsRecommender.framework' contains disallowed file 'Frameworks'."
It looks like there's a framework nested in a framework:
Things I tried:
Remove "Frameworks" folder in the "Run Script" phase (it actually helps with submission but the app crashes because it can't find the dylib which is in the Frameworks folder)
Change "Frameworks" to "Shared Frameworks" in "Embed Frameworks"
Disable "Always Embed Swift.."
Reason
The error message indicates that you are trying to package a framework that has its own frameworks embedded inside.
This is not currently supported through traditional framework embedding
The fix is, unfortunately, to link all frameworks separately in your main target.
How do I know?
When you see this error X.app/Frameworks/PoemsRecommender.framework contains disallowed file 'Frameworks'."
Apple is explicitly saying that a framework that embeds a "Frameworks" folder is disallowed. There is a great discussion here that goes into a lot more detail.
Recommended Solution
Package your frameworks separately and link them all manually. Apple has good guidelines here
Not Recommended but will achieve your goal
If you must use a single framework, there is quite a bit of work involved. Effectively you want to create an Umbrella framework that will mask all underlying frameworks. This can get messy if you ever decide to link those sub-frameworks in other parts of your application. Since your question is vague on the details I cannot ascertain if this will affect you.
There are a number of resources that can guide you through the laborious process.
Effectively the steps involve creating an aggregate target that can use a build script to bind all your frameworks at runtime.
I have done this in the past and we ran into lots of issues on the way and I would not recommend this approach. In the past we had a white-labelled SDK that consisted of a number of internal frameworks that were binded by an aggregate target. More often than not it was difficult to maintain and difficult to understand by new team members. Eventually we just migrated to multiple frameworks.
I think Apple has their own tooling to support how they do it but, sadly, it is not available to us peasants.

Xcode 8 : Disabling bitcode and Umbrella frameworks

I'm currently building an Umbrella framework (before anyone say so, I know this is discouraged by Apple, but I am in the case were I'm the owner of all the sub-frameworks, they are not distributed if they are not part of this or another Umbrella framework I may create, and we are in a closed source configuration) within Xcode 8.
I've followed this post to create the framework: https://stackoverflow.com/a/41815368/2572568
Everything is working fine except that I got the following error:
dyld: Library not loaded: #rpath/B.framework/B
Referenced from: /private/var/containers/Bundle/Application/E0113060-CA91-47F8-BEE3-BDF1F847DB3A/app.app/Frameworks/A.framework/A
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/E0113060-CA91-47F8-BEE3-BDF1F847DB3A/app.app/Frameworks/A.framework/Frameworks/B.framework/B: required code signature missing for '/private/var/containers/Bundle/Application/E0113060-CA91-47F8-BEE3-BDF1F847DB3A/app.app/Frameworks/A.framework/Frameworks/B.framework/B'
app is the Application using the Umbrella framework A which has a sub-framework B
I found that disabling bitcode from all the projects is solving this issue (and that's what I am doing now) from this thread : https://github.com/CocoaPods/CocoaPods/issues/3661
So here are my questions:
What does disabling bitcode is exactly doing ? I found that Apple can run optimization after you submitted your code. Are these speed optimization or disk space optimization, or any other optimization ?
Am I doing something wrong building my Umbrella framework ? Is it possible not to disable bitcode ?
First of all:
I came into the exact same problem today and I couldn't fix it. But removing Bitcode fixt it for me. Thanks for that
To your questions:
Bitcode is something kind of similar to Java's Bytecode. Your app gets compiled completely, but not in machine code (like assembler). Your app is compiled to Bitcode. This helps Apple to build different versions of your app on their server. One for 64bit and one for 32bit devices. Then they separate both apps, which saves disk space on the actual device.
And they probably have some further optimisations, which could speed up the app. Generally it's not needed today.
I tried almost everything I could imagine and at the moment I would say: No it's not possible to disable bitcode, if you have a big umbrella framework. Can you check if you have sub-frameworks in your umbrella framework which do not support Bitcode ? Like AWS SDK, Facebook SDK...
It may be possible to support Bitcode if all sub-frameworks support Bitcode. This answer seems promising me, but it's a bit old: https://stackoverflow.com/a/27638841/1203713
Regards,
Alex
Ok so after a few more researches on completely unrelated questions, I found this thread : https://github.com/Carthage/Carthage/issues/535
In substance, this solve question 2 and another one : Yes, you can enable bitcode for your Umbrella framework.
To do so, you must manually set a User-defined setting (inside Build settings, click on the plus in the top bar) named BITCODE_GENERATION_MODE to bitcode. This will force Xcode to build you project with real bitcode and not only a bitcode subset.
You have to set this flag for all the frameworks under your Umbrella framework.

dyld: Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib

I've built a Swift framework and now I'm trying to start building a Swift iOS application that will use that framework. I'm getting this error:
dyld: Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: /Users/tdean/Library/Developer/Xcode/DerivedData/NFLApplication-ejmafvjrlqgjaabggwvadjarjjlg/Build/Products/Debug-iphonesimulator/NFLStatsModel.framework/NFLStatsModel
Reason: image not found
I've scoured SO and found similar reports and tried the fixes listed there, including:
Clearing out my DerivedData folder
Restarting Xcode and the iPhone simulator
Ensuring that Always Embed Swift Standard Libraries = YES is set, both in my framework and my application's build settings
Ensuring that Enable Bitcode=NO is set, both in my framework and my application's build settings
Ensuring that Runpath Search Paths is set to #executable_path/Frameworks, both in my framework and my application's build settings
Copied all the libswift files from my Xcode installation into a local copy within my project, and added a custom build phase to copy those files into the frameworks folder.
In every case, I get the same error when I try to run my application.
Xcode Version 8.1 (8B62)
Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
I eventually got this working using a mix of fixes. I'm not sure if all of them are needed, but I'm documenting what seemed to work for me here, just in case anyone else can benefit by what I've found.
I have set Always Embed Swift Standard Libraries to a value of YES in the build settings tab for both my Swift framework and in the Swift application that uses the framework.
I have added Foundation.framework to the Linked Frameworks and Libraries section of the general tab for both my Swift framework and in the Swift application that uses the framework.
I have added Foundation.framework to the Embedded Binaries section of the general tab for the Swift application that uses the framework.
With all 3 of these settings in place, I am able to build and run my application without encountering this error.
This might not be the case for everyone, but I solved it by actually writing some code in the main target.
I had an empty project consisting of a framework and a test target, and when running tests I was getting this error. Apparently Swift is pretty smart to detect that you don't actually need this library and does not link to libswiftSwiftOnoneSupport.dylib.
The fix is just to add some code, I just added:
class Test {
func a() { print ("something") }
}
and libswiftSwiftOnoneSupport.dylib got linked.
After several days of being stuck with this issue I finally found something that worked for me; hopefully this will help others too.
Turns out that specifically using print() anywhere in the code will somehow force libswiftSwiftOnoneSupport.dylib to be loaded and the issue will go away.
I'm using Xcode 10.1, Swift 4.2 and the pod that was giving me this issue was Nimble.
BTW, I am aware of #S2dent's suggestion to "just add some code" but in my case my framework already had several different classes so it didn't help me.
How are you installing your dependencies?
I had a similar issue:
dyld: Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: <internal framework>
Reason: image not found
It turned out to be related to Swift whole-module optimization.
Using Carthage as a dependency manager, they were being compiled for Release, and thus compiled with whole-module optimization, which Xcode suggested I turn on. Running the app on the simulator compiles it for Debug. I'm guessing that dynamic frameworks cannot be at a different level of optimization from the app running it.
The solution was to explicitly specify the configuration I wanted Carthage to build for. (carthage bootstrap --configuration Debug) Oh, and cleaning my build folder, of course.
I had the same issue, adding the library (my own build one) to Linked Frameworks and Libraries in General tab of the app solved the issue.
You can also provide an Host Application to your test target if you don't want to add Foundation.framework to Linked Frameworks or Embedded Binaries
You can solve this by setting "Always Embed Swift Standard Libraries" to "Yes" in the Build Settings of your target.
It is an dynamic linker error which links binary in load or runtime
[#rpath]

How to fix Application Loader Error: Invalid Bundle. The bundle ... contains disallowed file 'Frameworks'

I have a Swift project with three Swift custom frameworks. The App builds and runs successfully but when I try to upload to iTunes Connect using Application Loader I get the following error for all three frameworks:
ERROR ITMS-90206: "Invalid Bundle. The bundle at 'XXX.app/Frameworks/YYY.framework' contains disallowed file 'Frameworks'."
As discussed in this SO answer I have set the 'Embedded Content Contains Swift Code' to NO in the frameworks and YES in the App, but this error persists.
The three Frameworks are all my own (I am seriously considering reworking the project to avoid Frameworks altogether but that is a chore I would like to avoid right now).
I am not using cocoapods.
Any ideas on how to resolve this error?
The key to solving this for me was, in addition to ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO, also setting EMBEDDED_CONTENT_CONTAINS_SWIFT=NO in build settings for all targets except the main app target. Had to clear out derived data, but after that all was well.
In (SE-0133) of the Xcode 8.3 Release note, there's a description about EMBEDDED_CONTENT_CONTAINS_SWIFT setting:
The new build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES replaces the EMBEDDED_CONTENT_CONTAINS_SWIFT setting, which has been deprecated. This new setting indicates that Xcode should always embed Swift standard libraries in a target for which it has been set, whether or not the target contains Swift code. A typical scenario for using this setting is when a target directly uses or embeds another product that contains Swift code. (26158130)
which means ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES has replaced EMBEDDED_CONTENT_CONTAINS_SWIFT, thus you need to change the former one(ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES) to NO in the extension target.
So this is not a good answer, but it is what I did to resolve it:
I created a new project and copied in all my files - in a flat structure without Frameworks, editing just to remove the relevant import statements. It now uploads fine. So it is the Framework structure that is the root of the problem. Not sure if the idea of Swift embedded custom libraries is just broken or I was doing something wrong so still looking for better answers...

Resources