xcode 无效的 Swift 支持 - 文件不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32526526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:48:25  来源:igfitidea点击:

Invalid Swift Support - Files don’t match

iosxcodeswift

提问by Dan

I just re-wrote an app in Swift 2. I'm trying to upload the app to iTunesConnect (via Xcode 7 GM) for internal testing.

我刚刚在 Swift 2 中重新编写了一个应用程序。我正在尝试将该应用程序上传到 iTunesConnect(通过 Xcode 7 GM)进行内部测试。

I wrestled with an "Invalid Swift Support" error for awhile (which has other, related questions) ... but now it's changed to something a little different.

我与“无效的 Swift 支持”错误搏斗了一段时间(还有其他相关问题)……但现在它变成了一些不同的东西。

The error from Apple now says:

来自苹果的错误现在说:

Invalid Swift Support

无效的 Swift 支持

The files libswiftCoreLocation.dylib, libswiftCoreMedia.dylib, libswiftCoreData.dylib, libswiftAVFoundation.dylib don't match

文件 libswiftCoreLocation.dylib、libswiftCoreMedia.dylib、libswiftCoreData.dylib、libswiftAVFoundation.dylib 不匹配

/Payload/App.app/Frameworks/libswiftCoreLocation.dylib, /Payload/App.app/Frameworks/libswiftCoreMedia.dylib, /Payload/App.app/Frameworks/libswiftCoreData.dylib, /Payload/App.app/Frameworks/libswiftAVFoundation.dylib

/Payload/App.app/Frameworks/libswiftCoreLocation.dylib、/Payload/App.app/Frameworks/libswiftCoreMedia.dylib、/Payload/App.app/Frameworks/libswiftCoreData.dylib、/Payload/App.app/Frameworks/libswiftAVFoundation。动态库

Make sure the files are correct(?), rebuild your app, and resubmit it.

确保文件正确(?),重建您的应用程序,然后重新提交。

Don't apply post-processing to

不要将后处理应用于

/Payload/App.app/Frameworks/libswiftCoreLocation.dylib, /Payload/App.app/Frameworks/libswiftCoreMedia.dylib, /Payload/App.app/Frameworks/libswiftCoreData.dylib, /Payload/App.app/Frameworks/libswiftAVFoundation.dylib.

/Payload/App.app/Frameworks/libswiftCoreLocation.dylib、/Payload/App.app/Frameworks/libswiftCoreMedia.dylib、/Payload/App.app/Frameworks/libswiftCoreData.dylib、/Payload/App.app/Frameworks/libswiftAVFoundation。动态库。

I've been unable to find similar errors by searching for "Don't apply post-processing", "Make sure the files are correct, rebuild your app, and resubmit it", etc.

我一直无法通过搜索“不应用后处理”、“确保文件正确,重建您的应用程序,然后重新提交”等来找到类似的错误。

Does anyone know how I can "Make sure the files are correct" --or-- have any other recommendations? Thank you.

有谁知道我如何“确保文件正确”——或者——有任何其他建议?谢谢你。

采纳答案by cockscomb

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

同样的问题在这里。我认为这很可能是与 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. Copyall libswiftXxx.dylibfiles from SwiftSupport/iphoneos/into Products/Applications/YourApp.ipa/Frameworks/and overwrite
  5. Now, Upload to App Storefrom Organizer
  1. 使用新版本号归档您的应用程序 :(
  2. 从管理器“在 Finder 中显示”在 Finder 中找到存档(.xcarchive 文件)
  3. 打开包并找到像Products/Applications/YourApp.ipa/Frameworks/和这样的目录SwiftSupport/iphoneos/
  4. 所有libswiftXxx.dylib文件复制SwiftSupport/iphoneos/Products/Applications/YourApp.ipa/Frameworks/并覆盖
  5. 现在,从 Organizer上传到 App Store

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

通过这个过程,我成功上传了我的构建。现在我在等待。

NOTE:

笔记:

I'm using CocoaPods, and the ENABLE_BITCODEoption was NO.

我正在使用 CocoaPods,ENABLE_BITCODE选项为 NO。

回答by DJ Tarazona

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

编辑:CocoaPods 0.39.0已经发布,修复了这个问题!

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

作为@orkenstein提到,有一个简单的解决方案通过注释掉一些代码Pod-frameworks.sh。我在这里包含了更多细节。

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

在您的 Xcode 项目目录中,打开 Pods/Target Support Files/Pods/Pods-frameworks.sh

Comment out the following lines:

注释掉以下几行:

# Embed linked Swift runtime libraries
local basename
basename="$(basename "" | 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 "" | 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.shand you should be good to go!

保存Pods-frameworks.sh,你应该很高兴去!

回答by Will Y

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

此问题的修复已合并,可在最新的 CocoaPods 版本上使用 0.39.0.beta.5

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

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

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

运行最新版本的 CocoaPods gem install cocoapods --pre

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

或者,按照运行未发布功能的说明进行操作:http: //guides.cocoapods.org/using/unreleased-features

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

获得最新版本的 CocoaPods 后,pod install再次运行。

回答by Zhong Huiwen

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:

我正在使用 fastlanegym 1.9.0 来构建我的应用程序,但它一直被苹果拒绝,因为文件不匹配,而如果我通过 XCode 8 上传它被接受。我检查了 ipa 的 swift 支持文件夹和 Frameworks 文件夹中的 swift 库,我发现 swift 支持文件夹中的库用于 swift 2.3,而在 Frameworks 文件夹中它是 swift 3。所以在我的健身房文件中我添加了工具链选项:

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

*请注意,我必须将 use_legacy_build_api 更改为 false 才能使用工具链选项

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

为了使用工具链选项,需要设置 use_legacy_build_api: false https://github.com/fastlane/fastlane/issues/6003#issuecomment-244792185

回答by orkenstein

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

GitHub 上找到了一个不太复杂的解决方案:

I had a look around in Pods-frameworks.shand 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.

我在Pods-frameworks.sh 中环顾四周,发现一个部分评论为:

嵌入链接的 Swift 运行时库
注释复制这些库的代码块(并对它们进行代码签名)似乎解决了我提交的问题。我还没有深入研究是否只是复制它们导致了问题,或者是否是代码签名。我在那里有点超出了我的深度。

回答by Bart?omiej Semańczyk

  1. Update your cocoapods to the latest version, type sudo gem install cocoapodsin terminal.
  2. Run pod updateunder your project's directory.
  3. Remember to set Enable Bitcodeto NOfor Debugoption for all your pods.
  4. Fixed
  1. 将你的 cocoapods 更新到最新版本,输入sudo gem install cocoapods终端。
  2. pod update在您的项目目录下运行。
  3. 请记住将所有 pod 的选项设置为“启用位码”为“Debug
  4. 固定的

The problem is fixed because the following code in Pods-frameworks.sh:

问题已解决,因为以下代码在Pods-frameworks.sh

# Embed linked Swift runtime libraries
local basename
basename="$(basename "" | 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

was changed to:

改为:

# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
    local swift_runtime_libs
    swift_runtime_libs=$(xcrun otool -LX "$binary" | 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
fi

回答by Urkman

My Solution for this:

我的解决方案:

I'm using Reveal through Cocoapods and Reveal needs to disable Bitcode. So I included Reveal(should work for any other Framwork) only for Debug:

我正在通过 Cocoapods 使用 Reveal,而 Reveal 需要禁用 Bitcode。所以我只为调试包含了 Reveal(应该适用于任何其他框架):

pod 'Reveal-iOS-SDK', :configurations => ['Debug']

As my Reveal is now only configured for Debug, I disabled Bitcode only for Debug.

由于我的 Reveal 现在仅针对 Debug 进行了配置,因此我仅针对 Debug 禁用了 Bitcode。

enter image description here

在此处输入图片说明

With this settings everything works fine, without any hacks...

使用此设置一切正常,没有任何黑客...

回答by JAL

I've seen this error occur when integrating libraries that do not support bitcode (such as the current stable version of New Relic). The solution is either to remove the libraries, disable bitcode (and potentially not be able to submit to the store), or wait for updated binaries that support bitcode from your library vender.

我已经看到在集成不支持位码的库(例如 New Relic 的当前稳定版本)时会发生此错误。解决方案是删除库,禁用位代码(并且可能无法提交到商店),或者等待更新的二进制文件支持来自您的库供应商的位代码。

回答by jarora

The error for me was that i built with Adhoc profile instead of App Store profile for uploading the spa to the app store.

对我而言,错误是我使用 Adhoc 配置文件而不是 App Store 配置文件构建了将 spa 上传到应用程序商店的配置文件。