2

I am trying to publish an iOS swift app. I use Xcode 9.4.1. The app contains a share extension that does HTTP uploads of files. The share extension uses SwiftHTTP. Validation of the app fails with the following errors:

Invalid Bundle. The bundle at 'FooBar.app/PlugIns/FileUploadextension.appex' contains disallowed nested bundles.
An unknown error occurred.

Invalid Bundle. The bundle at 'FooBar.app/PlugIns/FileUploadextension.appex' contains disallowed file 'Frameworks'.
An unknown error occurred.

I checked other answers on StackOverfllow about the error messages.

I disabled embedding of swift libraries for the extension:

enter image description here

Embedding is enabled for the main app:

enter image description here

There is a frameworks copy step for the extension:

enter image description here

I tried adding this script to the extension build phase:

cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
if [[ -d "Frameworks" ]]; then
rm -fr Frameworks
fi

With this script in place the app passes validation but the extension does not work. It fails with:

Hub connection error Error Domain=NSCocoaErrorDomain
Code=4097 "connection to service named
xxx.FooBar.FileUploadextension"
UserInfo={NSDebugDescription=connection to service named

When I open my my FileUploadextension.appex in Finder I have a Frameworks directory with SwiftHTTP.framework in it. How can I fix the problem to pass the validation and have the extension working?

filo
  • 223
  • 3
  • 14
  • Have you solved this? I have a similar problem, but with other frameworks. – Martin Perry Oct 17 '18 at 18:35
  • I followed this guide twenty times and eventually succeeded, flip all the magic switches until it works :-| https://developer.apple.com/library/archive/technotes/tn2435/_index.html – filo Oct 17 '18 at 19:46
  • I'm having the exact same problem with an iOS share extension using MBProgress framework. Did you get it working? – Darren Apr 19 '19 at 09:34
  • I managed to get it working. My answer is below. – Darren Apr 19 '19 at 09:51

1 Answers1

3

So my problem was with an app extension (Share extension) needing a library. Your extension cannot have the library embedded, so what you must do is embed the library in the main app then link to it from the extension.

If you are using Carthage, then I assume you have the Carthage copy script added as a Run Script.

enter image description here

You must only have this for the Main App and NOT the extension. Any libraries that the extension uses must be listed in the Input Files.

Then in your extension, simply add the framework as a linked binary

enter image description here

Remove your Copy Frameworks step from your extension too.

Darren
  • 10,182
  • 20
  • 95
  • 162