简体   繁体   English

项目中 Xcode 生成的缺少必需的模块“SwiftShims”错误

[英]missing required module 'SwiftShims' error generated by Xcode in project

I copied my project in a running state but the copied project doesn't work for me although the actual project is running fine.我以运行状态复制了我的项目,但复制的项目对我不起作用,尽管实际项目运行良好。 When I build my copied project it gives me the following error:当我构建我复制的项目时,它给了我以下错误:

在此处输入图像描述

I have cleared the cache and the derived data but the build still fails.我已清除缓存和派生数据,但构建仍然失败。

Does anyone have an idea what might cause this issue?有谁知道可能导致此问题的原因? Thanks in advance.提前致谢。

如果您使用CocoaPods ,打开yourProject.workspace而不是yourProject.xcodeproj

Did you try to remove the cache ?您是否尝试删除缓存?

rm -rf /Users/abdulrehman/Desktop/StudentMentor/DerivedData/ModuleCache/DLJPQMLQI1Q/

(I might have wrong copied your file path. So feel free to type it manually if there is nothing to remove at this path) (我可能错误地复制了您的文件路径。因此,如果此路径中没有可删除的内容,请随时手动输入)

如果您使用 SPM,删除.build文件夹并重新运行swift build可以解决我的问题。

  • Goto your project folder转到您的项目文件夹
  • Delete the contents inside the DerivedDataXcode folder.删除 DerivedDataXcode 文件夹中的内容。
  • Clean the project清理项目
  • Run.跑。

我遇到了同样的错误,但原因是将不同的 iOS 版本指定为 Podfile 的platform :ios和我的项目的部署目标。

SwiftShims is a module defined in the standard library. SwiftShims是标准库中定义的一个模块。 It shouldn't be missing.它不应该丢失。 I think it's because your DerivedData path changed, and now the compiler can't find its cache anymore.我认为这是因为你的DerivedData路径改变了,现在编译器再也找不到它的缓存了。

I had the same issue...and after a lot of trial and error, the following worked for me..我遇到了同样的问题......经过大量的反复试验,以下对我有用..

  1. Open your Xcode Workspace File -> Project_name(directory option on left) -> build settings -> Excluded Architectures -> Select 'Any iOS simulator SDK' and type arm64 in front of that ( for both build and release).打开您的 Xcode 工作区文件 -> 项目名称(左侧的目录选项) -> 构建设置 -> 排除的架构 -> 选择“任何 iOS 模拟器 SDK”并在其前面键入 arm64(用于构建和发布)。

  2. Repeat the same procedure for pods对 pod 重复相同的过程

  3. Go to VS code and delete pod-lock and pod folder转到 VS Code 并删除 pod-lock 和 pod 文件夹

  4. open podfile and Paste the following code right above "target 'name-tvOS' do" in podfile.打开 podfile 并将以下代码粘贴到 podfile 中“target 'name-tvOS' do”的正上方。

    post_install do |installer| flipper_post_install(installer) installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end end

(Note: some of the code body form above may already be there. In that case replace that part with this.) (注意:上面的一些代码体形式可能已经存在。在这种情况下,用这个替换那部分。)

  1. Save it and run 'pod install' in your project's terminal.保存它并在项目的终端中运行“pod install”。

  2. go back to xcode and clear build (Cmd+Shift+K) and then build your project (Cmd+B)返回 xcode 并清除构建(Cmd+Shift+K),然后构建您的项目(Cmd+B)

Hopefully it will build without any issues.. Happy Coding!希望它可以毫无问题地构建..快乐编码!

I have once encountered for a private local pod, which somehow Cocoapod set the lib product name as eg.我曾经遇到过一个私有的本地 pod,它以某种方式 Cocoapod 将 lib 产品名称设置为例如。 "MyLib-6c4b1003" -- with a prefix in hex. “MyLib-6c4b1003”——带有十六进制前缀。

This random hex somehow changed, but the project Other Link Flags still using the old one.这个随机的十六进制不知何故改变了,但项目其他链接标志仍然使用旧的。 I did the search to find out the references to the old hex and deleted them, run pod install and the right name will be used.我进行了搜索以找出对旧十六进制的引用并删除它们,运行pod install并使用正确的名称。

I still cannot understand why there is this random hex in the prefix, but seems like Cocoapods setting up of the project could reference to the wrong one.我仍然无法理解为什么前缀中有这个随机的十六进制,但似乎项目的 Cocoapods 设置可能引用错误的十六进制。

I had a similar issue when I wanted to remove Alamofire from Cocoapods .当我想从Cocoapods删除Alamofire时,我遇到了类似的问题。 then it needs to delete something:那么它需要删除一些东西:

target -- Build Settings -- Other Swift Flags目标 -- 构建设置 -- 其他 Swift 标志

This junk of code worked for me.这些垃圾代码对我有用。

You may get this error if you rename the project directory.如果重命名项目目录,您可能会收到此错误。

For your reference, I was using Flutter, so供您参考,我使用的是 Flutter,所以

flutter clean

It was solved with.它被解决了。

It happened to me when I was running the release version and switched back to the Debug version with Product > Scheme > edit schemes .当我运行发布版本并使用Product > Scheme > edit schemes切换回调试版本时,这发生在我身上。

Deleting derived data didn't help.删除派生数据没有帮助。

But simply doing Product > Clean Build Folder and restarting XCode fixed the issue.但只需执行Product > Clean Build Folder并重新启动 XCode 即可解决该问题。

如果您在预览画布中看到此错误并且诊断“mtime changed”:

'\/var\/folders\/kv\/t_w2wdds3m1_0lr02hcp3dgw0000gn\/C\/clang\/ModuleCache\/12TRQXIDQ8QQD\/SwiftShims-2TTN5UXQBRCCQ.pcm' was built: mtime changed<\/code>

删除该文件夹中的所有 .pcm 文件,然后重试。您机器上的文件夹会有所不同。复制位置并运行:

rm <paste path here>/*.pcm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM