• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

[复制链接]
菜鸟教程小白 发表于 2022-12-12 11:31:19 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我有一个源文件,实际上它是一个 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 文件?在 AFAIK 中,我们总是导入 .h 文件。



Best Answer-推荐答案


这只是构建所有源文件的便捷方式,无需将所有源文件都包含在您的项目中。见 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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap