Alyoshak Alyoshak - 1 year ago 213
Objective-C Question

How to use PHPhotoLibrary in a mixed code Objective-C/C++ file (a .mm file)?

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.

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

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

Answer Source

You can use

  #import <Photos/Photos.h>  

in your .mm file

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download