在CocoaPods项目中使用@import

时间:2023-01-27 11:02:18

I have a header in a CocoaPods project I'm working on in Xcode 6, in which I have an @import Cocoa; statement. It builds fine in its own project, but when I integrate it into the client app, I get the following error:

我在Xcode 6中的CocoaPods项目中有一个标题,其中我有一个@import Cocoa;声明。它在自己的项目中构建良好,但当我将其集成到客户端应用程序时,我收到以下错误:

Use of '@import' when modules are disabled

禁用模块时使用'@import'

I checked the CLANG_ENABLE_MODULES setting in every target of my client project, as well as every target in the Pods project, and every single one is set to YES. What could be triggering this error. I can switch back to a #import, which does fix it, but I'd like to understand why this is happening, since everything looks like it's configured properly.

我检查了客户端项目的每个目标中的CLANG_ENABLE_MODULES设置,以及Pods项目中的每个目标,并且每个目标都设置为YES。什么可能触发此错误。我可以切换回#import,它会修复它,但我想了解为什么会发生这种情况,因为所有内容看起来都配置正确。

I pushed my podspec (UnzipKit), but I also replaced the @import statements with #import to get it working. Also, I'm using Cocoapods 0.35.0. If you use this in your Podfile, it'll get you the @import version.

我推了我的podspec(UnzipKit),但我也用#import替换了@import语句以使它正常工作。另外,我正在使用Cocoapods 0.35.0。如果你在Podfile中使用它,它将为你提供@import版本。

pod 'UnzipKit', :git => 'https://github.com/abbeycode/UnzipKit.git', :commit => '38cd0225015a245b0d3167666b3f40d57f99147a'

1 个解决方案

#1


5  

Use of '@import' when modules are disabled

If you are using Xcode version6 then make sure that below two things should be enable inside Language Module settings. Refer the attached screenshot:- 在CocoaPods项目中使用@import

如果您使用的是Xcode版本6,请确保在语言模块设置中应启用以下两项内容。请参阅随附的屏幕截图: -

If you are using Xcode version lower than 6, You will get error because the module only work with apple framework and you cannot use them in other framework or third party Apps. You can check here

如果您使用的Xcode版本低于6,则会出现错误,因为该模块仅适用于Apple框架,您无法在其他框架或第三方应用程序中使用它们。你可以在这里查看

For more details of this answer check this * answer

有关此答案的更多详细信息,请检查此*答案

#1


5  

Use of '@import' when modules are disabled

If you are using Xcode version6 then make sure that below two things should be enable inside Language Module settings. Refer the attached screenshot:- 在CocoaPods项目中使用@import

如果您使用的是Xcode版本6,请确保在语言模块设置中应启用以下两项内容。请参阅随附的屏幕截图: -

If you are using Xcode version lower than 6, You will get error because the module only work with apple framework and you cannot use them in other framework or third party Apps. You can check here

如果您使用的Xcode版本低于6,则会出现错误,因为该模块仅适用于Apple框架,您无法在其他框架或第三方应用程序中使用它们。你可以在这里查看

For more details of this answer check this * answer

有关此答案的更多详细信息,请检查此*答案