Xcode: missing required module error

大兔子大兔子 提交于 2019-12-08 02:34:06

问题


I have looked at answers to similar problems and I'm still confused.

Background

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:

  1. Make starting Package.swift file
  2. swift package generate-xcodeproj
  3. Open project in Xcode
  4. Project : Build Settings : Base SDK ==> change to IOS
  5. Editor : Add Target : (iOS ... Single View App)
  6. Select your project, look at target list, find your newly added target : General : Deployment Info
  7. On toolbar, change "active scheme"

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.

Error Message

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' 

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.

Question

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


回答1:


i had the same issue "missing required module 'CLibreSSL'" when including Vapor in an iOS App. The fix is pretty simple and should work for you as well:

Go to your project’s Build Settings. Find the header Swift Compiler — Search Paths. In Import Paths, add a relative path to your C library’s folder using ${SRCROOT}. If your folder includes subfolders select the recursive option.

It's a tip from here

EDIT May 26,2017: As suggested in the comments - My solution does not work for me as well, when using real device. I was only playing around in simulator, where this fix helped. So sorry for the confusion. When compiling for real device, CLibreSSL/getentropy_osx.c does not compile due to missing header files (e.g. <sys/vmmeter.h>) - So bottomline: My suggestion works for me only in simulator. :-/




回答2:


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.



来源:https://stackoverflow.com/questions/43306779/xcode-missing-required-module-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!