• 主页
  • 系列总集
  • OpenCV
  • CMake
  • iOS
  • Java
  • 前端
所有文章 关于我

  • 主页
  • 系列总集
  • OpenCV
  • CMake
  • iOS
  • Java
  • 前端

模块化与Framework(21):引用非Framework模块Include of non-modular header

2017-07-21

Include of non-modular header inside framework module

在进行Framework化的过程中,一旦引用了某些Framework其使用者Project,就会报错

1
2
3
HttpHelper.h:10:9: error : include of non-modular header inside framework module 'Ware.HttpHelper': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/usr/include/CommonCrypto/CommonHMAC.h'
[-Werror,-Wnon-modular-include-in-framework-module] #import <CommonCrypto/CommonHMAC.h>

提醒你 在Framework Module中加载了非当前Module的头文件

处理方法

处理方法有两种,一种是基于LLVM的配置,一种是手动梳理头文件

Allow Non-modular Include

根据StackOverflow的回答可以通过

  • Build Setting — Apple LLVM 8.1 Language Modules — Allow Non-modular Includes In Framework Modules

设置为YES,则可以在Framework中使用模块外的Include,不过这种过于粗暴

检查头文件引用关系

根据下文产生原因的分析,其本质原因类似C++文件file not found的加载与编译,是因为不同语言之间的头文件引用混乱产生的

手工检查头文件引用关系,特别是 Umbrella Header File中 不要引用Include 了 C/C++ 头文件的OC头文件 作为子模块放出

产生原因

关注点集中于 #import <CommonCrypto/CommonHMAC.h> 可以发现其 CommonCrypto 模块为一个系统库

与UIKit这样的Framework不同,CommonCrypto 是 C模块 ,也就是说其头文件 CommonHMAC.h 不应该伴随 SomeHeader.h 头文件对外暴露

  1. Target.app 引用了 SharedFrame.framework的Umbrella头文件 SharedFrame.h
  2. Umbrella头文件中包含了 SomeHeader.h
  3. HttpHelper.h 中暴露了 CommonCrypto 的 CommonHMAC.h
  4. 对于 SharedFrame.framework的Scope, 内部二进制包含有 CommonCrypto 模块的代码,CommonHMAC.h有效
  5. 对于 Target.app的Scope, 不确定SharedFrame.h内部引用 HttpHelper.h 是否包含CommonCrypto 模块的代码
  6. Target.app 判定 <CommonCrypto/CommonHMAC.h> 为模块外Header File报错

修改方法:

在 SharedFrame.h 中删除 #import <SharedFrame/HttpHelper.h>, 仅在 Target.app 的.m文件中使用时加载

赏

请问老板还招人么(/ω\)

支付宝
微信
  • iOS
  • IDE
  • Xcode
  • Compiler
  • Framework
  • Tutorial

扫一扫,分享到微信

微信分享二维码
模块化与Framework(22):常见真机调试崩溃Crash
模块化与Framework(20):C++头文件和C文件错误解析
© 2021 Alan Li
Hexo Theme Yilia by Litten
  • 所有文章
  • 关于我

tag:

  • iOS
  • Java
  • Collection
  • Python
  • Shell
  • CMake
  • Memory
  • JavaScript
  • Architecture
  • AnchorPoint
  • Android
  • Web
  • Annotation
  • AFNetworking
  • Window
  • ViewController
  • AutoLayout
  • Dozer
  • CoreAnimation
  • Cycle Retain
  • Block
  • UI
  • IDE
  • FrontEnd
  • CSS
  • Category
  • TableViewCell
  • Security
  • Net
  • JSP
  • Spring
  • C
  • MyBatis
  • Date
  • React
  • GCD
  • UITouch
  • Gesture
  • UIControl
  • Git
  • HTML
  • HTTPS
  • HTTP
  • Servlet
  • Server
  • DataBase
  • MySQL
  • Linux
  • Tutorial
  • Ajax
  • Type
  • JQuery
  • JSON
  • Exception
  • Parameter
  • Reflect
  • Thread
  • Sort
  • KVO
  • MKMapKit
  • Overlay
  • Maven
  • Configure
  • Tips
  • Transaction
  • Swift
  • NavigationBar
  • Nginx
  • Runtime
  • OpenCV
  • Property
  • Playground
  • Protocol
  • Redux
  • ScrollView
  • Session
  • Cookie
  • Shiro
  • Error
  • Singleton
  • RegEx
  • StackView
  • StatusBar
  • Base64
  • Socket
  • TCP
  • IP
  • TextField
  • CALayer
  • UILabel
  • View
  • Animation
  • Xcode
  • Hexo
  • Terminal
  • OC
  • Device
  • Log
  • Image
  • JUnit
  • Oval
  • Archive
  • XSS
  • Compiler
  • Aspect
  • Responder
  • Class
  • FireWall
  • RetainCount
  • Const
  • Frame
  • String
  • Symbols
  • Framework
  • CocoaPods
  • Unity
  • Message
  • Button
  • AuthorizationStatus
  • Struct
  • XCTest
  • NSNotification
  • Contact

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

我写的,大概率是错的。。。。。