Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 未找到目标的伞形标头,将不会生成模块映射_Ios_Xcode - Fatal编程技术网

Ios 未找到目标的伞形标头,将不会生成模块映射

Ios 未找到目标的伞形标头,将不会生成模块映射,ios,xcode,Ios,Xcode,当我尝试在Xcode 6.3中构建框架时,它抱怨 警告:未找到目标“CKCountdownButton”的伞形标题,将不会生成模块映射 然后,当我在其他项目中导入此框架时,它失败了,没有此类模块“CKCountdownButton”在框架中添加一个CKCountdownButton.h修复了此问题 我认为伞形头是指与框架同名的头文件我找到了另一个解决方案,Xcode提供了通过模块映射文件配置指定伞形头的方法 modulemap.modulemap的内容应为: framework module

当我尝试在Xcode 6.3中构建框架时,它抱怨

警告:未找到目标“CKCountdownButton”的伞形标题,将不会生成模块映射


然后,当我在其他项目中导入此框架时,它失败了,没有此类模块“CKCountdownButton”在框架中添加一个
CKCountdownButton.h
修复了此问题


我认为伞形头是指与框架同名的头文件

我找到了另一个解决方案,Xcode提供了通过模块映射文件配置指定伞形头的方法

modulemap.modulemap的内容应为:

framework module Foo {
    umbrella header "Bar.h"

    header "other-header.h"

    export *
    module * { export * }
}

该目标需要至少有一个Swift文件。检查是否已将Swift文件添加到目标中

我对“谷歌工具箱”也有同样的问题。它发生在我试图更新pod回购协议时,发生了一些错误。刚从项目文件夹上的终端安装了“pod”,一切正常。

自定义框架模块映射(.modulemap)并定义了模块

公共文件结构:

header_1
  header_1_1
header_2
将应向消费者公开的所有标题标记为公共标题(标题1.h、标题2.h、标题1.h)<代码>标题
公共部分,否则将出现下一个错误

//For example in umbrella.h
Include of non-modular header inside framework module '<module_name>'

//or in upper .h file
'PBURLConnectionStub.h' file not found
使用或创建自定义
.modulemap
文件。您可以根据需要调用
.modulemap
文件,编译后它将被称为
modulemap.modulemap
。另外,我不建议您将其称为
module.modulemap
,因为它可能会导致此文件发生不可预知的更改

默认情况下生成的模块映射:

//the same for Objective-C and Swift framework
framework module SomeModule {

    //umbrella header "<umbrella_name>.h"
    umbrella header "Umbrella.h"
  
    export *
    module * { export * }
}

//unique for Swift framework
module SomeModule.Swift {
    header "SomeModule-Swift.h"
    requires objc
}
多个模块

.modulemap可以包含多个模块。其中一个必须与
PRODUCT\u MODULE\u name

//.modulemap
framework module SomeModule
framework module SomeModule2

//using
import SomeModule
import SomeModule2
子模块
模块

//.modulemap
framework module SomeModule {
  explicit module Submodule1 {
      header "header_1.h"
      export Submodule2
  }
  explicit module Submodule2 {
      header "header_2.h"
  }
}

//using
import SomeModuleObjC.Submodule1

//availability
header_1
header_2
导入外部模块时,可以使用子模块中的标题

//.modulemap
framework module SomeModule {
    module Submodule1 {
        header "header_1.h"
    }
}

//using
import SomeModuleSwift.Submodule1
//or even
import SomeModuleSwift

//availability
header_1

显式子模块
显式模块

//.modulemap
framework module SomeModule {
  explicit module Submodule1 {
      header "header_1.h"
      export Submodule2
  }
  explicit module Submodule2 {
      header "header_2.h"
  }
}

//using
import SomeModuleObjC.Submodule1

//availability
header_1
header_2
您不能对子模块头使用模块名(默认情况下可以这样做,如前一个示例所示)

显式子模块之间的依赖关系导出

//.modulemap
framework module SomeModule {
  explicit module Submodule1 {
      header "header_1.h"
      export Submodule2
  }
  explicit module Submodule2 {
      header "header_2.h"
  }
}

//using
import SomeModuleObjC.Submodule1

//availability
header_1
header_2
带伞工作

模块*
仅适用于
雨伞
,如果您没有

Inferred submodules require a module with an umbrella
生成下一个代码

framework module SomeModule {

  //module * { export * }
  module header_1 {
    header "header_1.h"

    export header_2 
    export header_1_1 
  }

  module header_2 {
    header "header_2.h"
    
    export header_1 
    export header_1_1 
  }

  module header_1_1 {
    header "header_1_1.h"
    
    export header_1 
    export header_2 
  }

  //export *
  export header_1 
  export header_2 
  export header_1_1 
}

//using one of them
import SomeModule.header_1 
//or 
import SomeModule.header_2
//or
import SomeModule.header_1_1 
//or
SomeModule

//availability
header_1
header_2
header_1_1
当找不到某个文件时,会发生下一个错误

Error: Cannot find 'header_name' in scope
要查看效果,请使用显式模块

module*
-为
伞内的每个
模块头创建子模块

导出*
-将所有子模块导出到当前子模块中

如果我们使用
module*{}
而不是
module*{export*}
import SomeModule.header_1
没有任何更改,那么在导入单个子模块时,我们可以使用所有
模块头
。这是安全的,因为父模块
SomeModule
可以访问所有子模块

import SomeModule.header_1

header_1
header_2
header_1_1
如果我们使用
explicit module*{}
而不是
explicit module*{export*}
import SomeModule.header_1
我们会得到错误

import SomeModule.header_1

header_1
//header_2 //Error: Cannot find 'header_2' in scope
制作人:

定义模块(定义模块)

生成设置->定义模块
如果是-Xcode生成.modulemap。如果未指定'MODULEMAP_FILE',请尝试使用Xcode自动生成它
模块映射文件(模块映射文件)

生成设置->模块映射文件
自定义“.modulemap”文件的路径
将生成结果文件'module.modulemap',并将其嵌入到.framework中
消费者:

导入路径(SWIFT\u包括\u路径)

生成设置->导入路径
自定义“.modulemap”文件的路径

此处完整参考modulemap语法:换句话说,确保框架标题与模块名称匹配。在我的例子中,我创建了一个名为“myframeworkmacos”的新框架目标(它生成了
MyFramework\u macOS.h
)。然后我将模块名更改为“MyFramework”,但我没有更改标题。我通过将标题重命名为
MyFramework.h
并更新其中的导出以匹配新模块名(
MyFramework\u macOSVersionNumber
MyFrameworkVersionNumber
等),解决了伞式标题问题。
import SomeModule.header_1

header_1
header_2
header_1_1
import SomeModule.header_1

header_1
//header_2 //Error: Cannot find 'header_2' in scope