问题描述
我已经看过类似问题的答案,但我仍然感到困惑.
I have looked at answers to similar problems and I'm still confused.
背景
我有一个正在工作的项目,但是我试图在Xcode 8.3.1中重新创建它.我首先使用具有一个依赖项的Swift软件包管理器:[.Package(url:" https://github .com/OpenKitten/MongoKitten.git ,majorVersion:3)].然后,我按照我的笔记将可可转换为iOS(因为SPM不直接支持iOS),该项目在上一个项目开始时就起作用了:
I had a project working, but I'm trying to recreate it in Xcode 8.3.1. I start by using the Swift Package Manager with one dependency: [.Package(url: "https://github.com/OpenKitten/MongoKitten.git", majorVersion: 3)]. I then follow my notes to convert from Cocoa to iOS (because SPM doesn't directly support iOS) that worked in previous project starts:
- 启动Package.swift文件
- swift包generate-xcodeproj
- 在Xcode中打开项目
- 项目:构建设置:基本SDK ==>更改为IOS
- 编辑器:添加目标:(iOS ...单视图应用程序)
- 选择您的项目,查看目标列表,找到您新添加的目标:常规:部署信息
- 在工具栏上,更改活动方案"
一切似乎都很好,我的项目包括MongoKitten及其依赖的其他框架.其中之一称为"CLibreSSL".我将所有框架作为目标添加到了新创建的目标中.
Everything seems fine, and my project includes MongoKitten and a bunch of other frameworks that it relies on. One of which is called "CLibreSSL". I added all of the frameworks as targets to my newly created target.
错误消息
我可以导入MongoKitten"到我的viewcontroller中(自动完成工作).但是,当我进行编译时,会收到此错误消息(即使我亲自未尝试导入CLibreSSL):
I can "Import MongoKitten" into my viewcontroller (with autocomplete working). However, when I compile, I get this error message (even though I personally did not try to Import CLibreSSL):
Compile Swift source files
[... bunch of stuff referring to my new target and the viewcontroller ...]
<unknown>:0: error: missing required module 'CLibreSSL'
我无法导入CLibreSSL"到我的视图控制器中(没有自动完成识别功能).我注意到当我转到与MongoKitten相关的源文件时,它们确实在导入语句中成功识别了CLibreSSL.我什至可以删除它们并通过自动补全功能重新输入.
I cannot "Import CLibreSSL" into my viewcontroller (no autocomplete recognition). I notice that when I go to the MongoKitten-related source files, they do recognize CLibreSSL successfully in their import statements. I can even delete them and retype with successful autocompletion.
问题
我意识到,像我一样,当我创建一个新目标时,我可能需要做一些额外的事情,这可能与搜索路径有关,但是我尝试了很多东西,结果没有改变.有人可以告诉我如何解决此问题吗(当我发现这些东西令人困惑时,请不要以我的知识为前提)?
I realize I probably need to do something additional when I make a new target like I did, and it probably has something to do with the search paths, but I've tried a lot of stuff and the result has not changed. Can someone please tell me how to resolve this (and please don't assume too much knowledge on my part as I find this stuff confusing)?
如果您需要更多信息,请告诉我.谢谢
Please let me know if you need more information. Thank you
推荐答案
按照user3441734的建议添加"Other Swift Flags"构建设置已为我修复.依赖CLibreSSL模块的库(在我的情况下为OpenCloudKit)可以找到它似乎很奇怪,但是导入OpenCloudKit的我的应用程序离不开帮助.作为参考,我的嵌套在导入到我的应用程序中的SPM生成的Xcode项目(名为"Dependencies")中,构建设置为-Xcc -fmodule-map-file=$(SRCROOT)/Dependencies/.build/x86_64-apple-macosx10.10/debug/CLibreSSL.build/module.modulemap
.请注意,这似乎有点脆弱,因为它的文件名中硬编码了一个macOS版本,并且我认为如果将其更新为更高版本,它可能会中断.另外请注意,在我的情况下,不需要搜索路径"构建设置,仅需要其他快捷路径"设置.
Adding the "Other Swift Flags" build setting as suggested by user3441734 fixed it for me. It seems odd that the library (in my case OpenCloudKit) that depends on the CLibreSSL module can find it, but my app that imported OpenCloudKit can't without help. For reference , mine was nested in a SPM-generated Xcode project (named "Dependencies") imported into my app and the build setting was -Xcc -fmodule-map-file=$(SRCROOT)/Dependencies/.build/x86_64-apple-macosx10.10/debug/CLibreSSL.build/module.modulemap
. Note that this seems a bit fragile because it has a macOS version hard-coded into the file name and I assume that could break if it's updated to a later version. Also note that the Search Paths build setting was NOT needed in my case, only the Other Swift Paths setting.
这篇关于Xcode:缺少必需的模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!