Programing

프레임 워크 모듈 내에 비 모듈 식 헤더 포함

lottogame 2020. 7. 9. 08:21
반응형

프레임 워크 모듈 내에 비 모듈 식 헤더 포함


Xcode 6을 사용하고 있습니다.

1) 먼저 동적 라이브러리 (CoreLibrary)를 만들고 있습니다. 이 라이브러리에는 RequestPoster.h 파일이 포함되어 있습니다.

2) 그런 다음 Cocoa Touch Framework를 만들고이 동적 라이브러리 (CoreLibrary)를 추가했습니다.

3) 그런 다음이 프레임 워크가 프로젝트에 추가되고 RequestPoster.h 파일 (CoreLibrary)에 오류가 발생합니다.

오류 : 프레임 워크 모듈 클래스 내에 비 모듈 식 헤더 포함 :

ifaddrs.h, arpa / inet.h, sys / types.h>

프로젝트에서이 파일을 찾을 수 없습니다.


"대상"아래의 빌드 설정으로 이동하여 "프레임 워크 모듈에 비 모듈 식 포함 허용"을 예로 설정하십시오.

실제 답변은 라이브러리 소유자가 가져 오기 위치를 변경해야한다는 것입니다. ifaddrs.h, arpa / inet.h, sys / types.h 파일은 Xcode가 싫어하는 프레임 워크의 .h 파일로 가져옵니다. 라이브러리 관리자는 .m 파일로 이동해야합니다. AFNetworking이 동일한 문제를 해결 한 GitHub에서이 문제를 예로 들어보십시오 : https://github.com/AFNetworking/AFNetworking/issues/2205


헤더 파일이 프레임 워크의 공개 헤더의 일부로 공개적으로 사용 가능한지 확인하십시오.

프레임 워크-> 대상-> 빌드 단계로 이동하고 끌어서 관련 헤더 파일을 프로젝트에서 공용으로 이동하십시오. 희망이 도움이됩니다!

스크린 샷


영향을받는 대상에 대한 빌드 설정의 프레임 워크 모듈 에서 비 모듈 식 포함 허용 을 YES로 설정할 수 있습니다 . 이것은 편집해야 할 빌드 설정입니다.

편집해야 할 빌드 설정 항목

참고 :이 기능을 사용하여 근본적인 오류를 발견해야합니다.이 오류는 종속 관계가있는 파일의 괄호로 묶인 전역 포함의 복제로 인해 자주 발생합니다.

#import <Foo/Bar.h> // referred to in two or more dependent files

설정이 경우 비 모듈 식 프레임 모듈에 포함 허용찬성 세트에서 결과 오류 또는 종류의 뭔가 "X가 모호한 참조입니다", 당신은 잘못된 중복 (들)을 추적하고이를 제거 할 수 있어야한다. 코드를 정리 한 후 프레임 모듈에서 비 모듈 식 포함 허용을 다시 NO로 설정하십시오 .


헤더 파일을 공개하여 동일한 문제가 발생했습니다. [문제]

프로젝트에서 여러 모듈로 작업하는 경우 그런 다음 프로젝트의 다른 부분에서 사용하려면 헤더 파일을 공개해야합니다. 필요한 것은 해당 헤더 파일을 선택하고 프로젝트 유틸리티보기에서하는 것입니다. 파일을 Project / Private에서 Public으로 변경하십시오. 아래 이미지를보십시오 :

헤더 파일 범위 변경


"프레임 워크 모듈 내에 비 모듈 식 헤더 포함"

이 오류가 발생하면 파일 관리자 "대상 구성원"에서 가져 오려는 파일을 단순히 "공용"으로 표시하는 것이 어떤 상황에서는 해결책이 될 수 있습니다. 기본값은 "프로젝트"이며이 방법으로 설정하면이 오류가 발생할 수 있습니다. 예를 들어 Google Analytic의 헤더를 프레임 워크로 가져 오려고 할 때도 마찬가지였습니다.


Actually an easier way to fix this is to move the #import statement to the top of the .m file instead (instead of having it in your .h header file). This way it won't complain that it's including a non-modular header file. I had this problem where Allow non-module includes set to YES did NOT work for me, so by moving it to the implementation file, it stopped complaining. This is in fact the preferred way of importing and including header files anyway. Once you've done this, setting this back to NO should work.

Ideally we should try and aim to have Allow non-module includes set to NO. Setting this to YES in most cases means you're doing something wrong. The setting translates to "Allow importing random header files on disk that aren't otherwise part of the module". This applies to a very few use cases in practice, and so this setting should always be NO (i.e. the default value).


In case if you are developing your own framework:

WHY is this happening?

If any of the public header files you have mentioned in your module.modulemap have import statements that are not mentioned in modulemap, this will give you the error. Since it tries to import some header that is not declared as modular (in module.modulemap), it breaks the modularity of the framework.

HOW can I fix it?

Just include the header that gave the error to your module.modulemap and build again!

WHY NOT just set allow non-modular to YES?

Because it's not really a solution here, with that you tell your project "this framework was supposed to be modular but it's not. Use it somehow, I don't care." This doesn't fix your library's modularity problem.

For more information check this blog post or refer to clang docs.


I had the same issue and nothing from above helped me. So I hope my answer will be helpful for somebody. In my case the problem was in ALWAYS_SEARCH_USER_PATHS setting. When it was set to NO project built and worked ok. But as far as one of the pod required it to be set to YES I was receiving an error

Include of non-modular header inside framework module

After couple cups of coffee and all day researching I found out that according to known issues of Xcode 7.1 Beta 2 release notes:

• If you get an error stating "Include of non-modular header inside framework module" for a framework that previously compiled, make sure the "Always Search User Paths" build setting is set to "No". The default is "Yes" only for legacy reasons. (22784786)

I was using XCode 7.3 though, but seems like this bug hasn't been fixed yet.


the same problem make crazy.finally, i find put the 'import xxx.h' in implementation instead of interface can fix the problem.And if you use Cocoapods to manager your project.you can add

s.user_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES' }

in your 'xxx.podspec' file.


If you need this for CocoaPods targets add this lines in Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      target.build_settings(config.name)['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
    end
  end
end

If you see this error in an umbrella header when building a dynamic framework, make sure you import your file as:

#import "MyFile.h"

and not as #import <MyFramework/MyFile.h>.


This was kind of an annoying issue for me. No suggestions seemed to help my particular case, since I needed to include the "non-modular" headers in my individual file header file. The work around I used was sticking the import call in the prefix header file.


I came across this issue as well and originally thought it was a CocoaPods issue, but it was an issue in the apps build settings where someone (probably me) had set ${PODS_ROOT} in Header Search Paths and set it to be a recursive search. This was allowing it to find headers that were not intended to be used when building the app. Once I set this to use non-recursive everything was fine. using recursive search is a terrible hack to try to find the proper headers. Lesson learned.


I ended up moving the Umbrella Header to bottom of the Headers list after checking the above solutions, and that worked in Xcode 9.3.


I solved it removing Modules folder from the framework.

  • Browse to your framework location which is present in the App Project using finder

  • Test.framework폴더 내부 (위의 경우 CoreLibrary.framework) 및 Modules폴더 삭제로 이동하십시오 .

  • 앱을 정리하고 다시 빌드하면 문제가 해결됩니다.


제 경우에는 .podspecs 파일의 "s.source_files"섹션에 .h 및 .m 파일을 추가하는 것을 잊었습니다.

이것을 추가하면 정상적으로 작동합니다.

여기에 이미지 설명을 입력하십시오


Git clean을 사용하여 수십 가지 오류를 해결할 수있었습니다. 명령은 다음과 같습니다.git clean -dffx && git reset --hard

참고 URL : https://stackoverflow.com/questions/27776497/include-of-non-modular-header-inside-framework-module

반응형