gpt4 book ai didi

ios - 为什么要导入 .m 文件?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:56:45 26 4
gpt4 key购买 nike

我有一个源文件,实际上它是一个 Google API 库。

它在 GTLCommon_Sources.m 上有这段代码:

#if defined(__has_feature) && __has_feature(objc_arc)
#error "This file needs to be compiled with ARC disabled."
#endif

#import "Objects/GTLBatchQuery.m"
#import "Objects/GTLBatchResult.m"
#import "Objects/GTLDateTime.m"
#import "Objects/GTLErrorObject.m"
#import "Objects/GTLObject.m"
#import "Objects/GTLQuery.m"
#import "Objects/GTLRuntimeCommon.m"
#import "Objects/GTLService.m"
#import "Objects/GTLUploadParameters.m"

#import "Utilities/GTLBase64.m"
#import "Utilities/GTLFramework.m"
#import "Utilities/GTLJSONParser.m"
#import "Utilities/GTLUtilities.m"

但是,尝试构建它时,会在 GTLCommon_SourcesGTLJSONParser 上产生重复的符号。我尝试将源文件更改为 #import "Utilities/GTLJSONParser.h" 而不是 #import "Utilities/GTLJSONParser.m" 并且重复符号错误消失了。

谁能告诉我为什么这个库导入 .m 文件?据我所知,我们总是导入 .h 文件。

最佳答案

这只是一种构建所有源文件的便捷方式,而无需将所有源文件都包含在您的项目中。参见 the documentation .

Rather than link to the GTL framework, you can compile the GTL library sources directly into your own project. To do this, find the library's GTLCommon_Sources.m and GTLCommon_Networking.m files, and drag the files into your project's window.

Then add the library's source folders to the Header Search Paths entry of your project's build settings: Source, Source/Objects, Source/Utilities, Deps/gtm-session-fetcher/Source, Deps/gtm-oauth2/Source, Deps/gtm-oauth2/Source/Touch (or Deps/gtm-oauth2/Source/Mac).

要使其正常工作,请不要将任何其他来源(GTLBatchQuery.m 等)添加到您的项目中。

关于ios - 为什么要导入 .m 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37560704/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com