“Invalid Swift Support” Using Native Swift Library

2019-05-31 00:00发布

问题:

I just implemented a native library, Charts (original native library), and its working on my phone and simulator. Unfortunately, when I submit it to iTunes connect, it kicks it back after processing and says:

Invalid Swift Support - The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it.

I'm using XCode to publish the archive to iTunes connect, but don't know how to do what this StackOverflow solution is saying. Since I don't use XCode to start the build process, I'm using Xamarin Studio 6, not sure how to set that setting.

So ideally, I need to "Set the flag EMBEDDED_CONTENT_CONTAINS_SWIFT to YES in the target settings".

Anybody have any ideas on how to do this? At a roadblock on releasing the beta until I can get this uploaded.

Thanks for your help!

回答1:

What's your Xcode version? Make sure to be using the latest and GM one, I believe it to be 7.3. The script described on the Readme copy the files from Xcode folder.

If you unpack the IPA created after the script ran you can check for the folder's existence.

When rebuilding and binding the library the option "Set the flag EMBEDDED_CONTENT_CONTAINS_SWIFT to YES in the target settings" Didn't work for me as well.

Apple stated when trying to publish: "Invalid Frameworks folder". Xcode will embed files as in: 'Payload/YOURAPP.app/Frameworks/Charts.framework/Frameworks/libswiftCore.dylib', but in the final App it should be as in: 'Payload/YOURAPP.app/Frameworks/libswiftCore.dylib' and 'SwiftSupport/libswiftCore.dylib'.

To solve the problem the library does it in the build process. And you need the script to fix the 'SwiftSupport' folder. I didn't found a way to tamper with Xamarin Studio 'Archive for Publish' function.



回答2:

Update: You can just use this script I threw together to fix your IPA so it's properly formatted, download the Auto IPA Packager on Github. It's a simplification of the IPA Packager I reference below, and handles all of the steps below too.

So, I've finally made it submit properly to the App Store, just had to hop through a few more steps than I expected. A lot of my confusion was because I didn't want to leave out other artifacts. I've decided to list the process here so it's very clear for anybody deploying an iOS app in the future that needs to use this tool.

  1. Download the IPA Packager from GitHub.
  2. Then go to Xamarin Studio, and Build > Archive for Publishing.
  3. I've been using XCode to export my archives. Open XCode, Window > Organizer. Find your app archive, and click "Export" and follow the appropriate steps, then save it.
  4. Locate the .ipa file and change it to .zip, and extract it.
  5. Next, in the extracted files, locate the "AppNameFolder > Payload > AppName.app".
  6. Load terminal and execute the following:

    sh package_ipa.sh /AppNameFolder/Payload/AppName.app /AppNameFolder/AppName.ipa

  7. AppName.ipa should now be created. This file should be ready to upload to the App Store. However, if your AppNameFolder has a "Symbols" directory you should follow the additional steps below...

  8. Optional: If you have symbol files, you should change the AppName.ipa to AppName.zip and extract the files.

  9. Drag the "AppNameFolder > Symbols" directory into the extracted AppName folder, then zip the contents of the folder and change the extension back to .ipa.



回答3:

I had some issue getting @jamesbar2 solution to work. Here are my manual steps for uploading Xamarin builds with Swift packages.

  1. Archive your app for Publishing.
  2. When the Archives window pops up, go to it in Finder (right click on it and select "Reveal in Finder").
  3. When Finder appears, we need to access the archive's content (right click and select "Show Package Contents").
  4. Inside of the archive package, create a folder called "SwiftSupport".
  5. Inside of the package navigate to "Product/Applications/YourAppName.app/Frameworks" (You will need to right click on the .app and select "Show Package Contents").
  6. Copy all the swift ".dylib" files inside of the Frameworks directory.
  7. Navigate back to "SwiftSupport" and paste those copied libraries.
  8. Now Launch Xcode and load Organizer (Window -> Organizer).
  9. Find your app in the Archives and "Upload to App Store...".

I was only able to get this to work using Xcode Organizer, using Xamarin always failed.

Note: I am using Visual Studio for Mac Community 7.3.2 (build 12).

Update:

I recently had issues with uploading, with TestFlight rejection email saying something like:

 The file libswiftCore.dylib doesn’t have the correct code signature. blah, blah, blah. 

To fix this problem instead of copying the Frameworks from your app Framework folder, grab them from Xcode. You can find them at:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos

Note TestFlight would reject my build if I added all the Frameworks to SwiftSupport folder. Only include the Frameworks that your app is using.