如何在混合代码Objective-C/ c++文件(.mm文件)中使用PHPhotoLibrary ?

时间:2022-09-07 09:38:24

I am trying to use the PHPhotoLibrary class in an iOS project, but need it in one of my mixed code Objective-C/C++ files. I am getting a build error bc apparently the needed import is not correct. The Apple docs here clearly show that @import Photos is to be used, so in my Build Settings I turned on "Enable Modules (C and Objective-C)" and added @import Photos with my other imports. That however did not fix Xcode's objection to my using @import Photos. The problem is as one of the posts for this SO question here explains, you can only use the @import Photos style of include in .mm files.

我正在尝试在一个iOS项目中使用PHPhotoLibrary类,但是在我的混合代码Objective-C/ c++文件中需要它。我得到了一个构建错误bc,显然所需的导入是不正确的。这里的Apple docs清楚地显示了将要使用的@import Photos,所以在我的构建设置中,我打开了“启用模块(C和Objective-C)”,并在我的其他导入中添加了@import Photos。然而,这并没有解决Xcode反对我使用@import Photos的问题。问题在于,作为本文的一篇文章,这里的问题解释说,您只能使用.mm文件中包含的@import Photos样式。

(I'm not using Swift, only Objective-C and in a few files mixed Objective-C and C++)

(我不使用Swift,只使用Objective-C,在一些混合Objective-C和c++的文件中)

How then can I properly import/include in my .mm file so my PHPhotoLibrary code will build?

那么,如何正确地导入/包含我的.mm文件,从而构建我的PHPhotoLibrary代码呢?

1 个解决方案

#1


7  

You need to import Photos.framwork

你需要导入photo .framwork

  #import <Photos/Photos.h>  

in your .mm file

功能文件中

#1


7  

You need to import Photos.framwork

你需要导入photo .framwork

  #import <Photos/Photos.h>  

in your .mm file

功能文件中