Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid Swift Support - Files don’t match

Tags:

xcode

ios

swift

Same problem here. I think this is most likely a bug of the Developer Tools, related to the Bitcode.

I just found the workaround for this.

  1. Archive your app with new build number :(
  2. Find the archive (.xcarchive file) in Finder from Organizer “Show in Finder”
  3. Open the package and find directories like Products/Applications/YourApp.ipa/Frameworks/ and SwiftSupport/iphoneos/
  4. Copy all libswiftXxx.dylib files from SwiftSupport/iphoneos/ into Products/Applications/YourApp.ipa/Frameworks/ and overwrite
  5. Now, Upload to App Store from Organizer

With this process, I succeed in uploading my build. Now I’m waiting for review.

NOTE:

I’m using CocoaPods, and the ENABLE_BITCODE option was NO.


Edit: CocoaPods 0.39.0 has been released which fixes this issue!

As @orkenstein mentioned, there is a simpler solution by commenting out some code in Pod-frameworks.sh. I'm including a bit more details here.

In your Xcode project directory, open Pods/Target Support Files/Pods/Pods-frameworks.sh

Comment out the following lines:

# Embed linked Swift runtime libraries
local basename
basename="$(basename "$1" | sed -E s/\\..+// && exit ${PIPESTATUS[0]})"
local swift_runtime_libs
swift_runtime_libs=$(xcrun otool -LX "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/${basename}.framework/${basename}" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u  && exit ${PIPESTATUS[0]})
for lib in $swift_runtime_libs; do
  echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
  rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
  code_sign_if_enabled "${destination}/${lib}"
done

=>

# Embed linked Swift runtime libraries
# local basename
# basename="$(basename "$1" | sed -E s/\\..+// && exit ${PIPESTATUS[0]})"
# local swift_runtime_libs
# swift_runtime_libs=$(xcrun otool -LX "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/${basename}.framework/${basename}" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u  && exit ${PIPESTATUS[0]})
# for lib in $swift_runtime_libs; do
#   echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
#   rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
#   code_sign_if_enabled "${destination}/${lib}"
# done

Save Pods-frameworks.sh and you should be good to go!


The fix for this issue has been merged and it is available on the latest CocoaPods version 0.39.0.beta.5

https://github.com/CocoaPods/CocoaPods/pull/4268

To get the latest version of CocoaPods run gem install cocoapods --pre

Alternatively, follow instructions for running unreleased features: http://guides.cocoapods.org/using/unreleased-features

Once you have the latest version of CocoaPods, run pod install again.


I was using fastlane gym 1.9.0 to build my app and it kept getting rejected by apple because the files didn't match, whereas if i uploaded through XCode 8 it was accepted. I checked the swift libs in the ipa's swift support folder and in the Frameworks folder, I found that the libs in the swift support folder were for swift 2.3 while in the Frameworks folder it was swift 3. So in my gym file I added the toolchain option:

gym(
  scheme: "CoCadre", 
  configuration: "Production Release",
  clean: true,
  use_legacy_build_api: false,
  toolchain: "com.apple.dt.toolchain.Swift_2_3"
)

*Note that i had to change use_legacy_build_api to false to use the toolchain option

In order to use toolchain option, need to set use_legacy_build_api: false https://github.com/fastlane/fastlane/issues/6003#issuecomment-244792185


There is a little less complex solution, found on GitHub:

I had a look around in Pods-frameworks.sh and found a section commented as:

Embed linked Swift runtime libraries
Commenting the block of code which copies these libraries across (and code signs them) seems to have fixed my submission woes. I've not dived in deeper yet to see if it's just the copying of them which causes the issues or if it's the code-signing. I'm getting a bit out of my depth there.