4

I need to embed a custom XMP file to a PNG in a iOS app. Until now, what I was able to do is to compile the Adobe XMP toolkit, that generated an Xcode project, then I compiled the project correctly.

From there I don't know how to use the library in my Xcode project and how to use it. I've found very little info about this on the Internet.

Anyone who did the same wishing to help?

Aleph72
  • 857
  • 1
  • 13
  • 35

3 Answers3

3

If you downloaded the Adobe XMP Toolkit SDK, you can find an example of writing the XMP metadata in "ModifyingXMP.cpp" and an example of reading the already XMP-written file in "ReadingXMP.cpp" file. Note that I am using XMP-Toolkit-SDK-CC201607 version.

You need static files and header files to be included in your iOS project later. Read the instructions carefully on how to generate them, specifically on what kind of archs you need. In my case, I generated [arm64, armv7, armv7s] and [x86_64] separately and then lipo them together later.

Try and modify "ModifyingXMP.cpp" according to what you need. Include these source codes into your iOS app project as Objective-C++ (with .mm extension). Don't forget to include the header file, libXMPCoreStatic.a file, libXMPFilesStatic.a file, make a bridging header, and configure your project to import external static libs. If you don't understand what I am talking about, check these links:

https://forums.adobe.com/thread/1360320

How can I use an .a static library in swift?

Here is what it looks like in my demo project: enter image description here

My implementation on XmpWriter.h:

#import <Foundation/Foundation.h>

@interface XmpWriter : NSObject

+(BOOL) writeXmp:(const char *) imageUrl Param1:(const char *) Param1 Param2:(float) param2 Param3:(float) Param3;
+(BOOL) readXmp:(const char *) imageUrl;

@end

In my XmpWriter.mm file, I modify the createXMPFromRDF() to accept my parameters like:

SXMPMeta createXMPFromRDF(const char *Param1, float Param2, float Param3)

I hope you can get closer to what you want to achieve from here.

Kevin
  • 311
  • 1
  • 7
  • Hi Kevin, thank you very much for helping. Yesterday I was stuck on the compiling of the libraries because I didn't "lipo" the libs together and I had errors compiling. Now I did that and I only have the same two libraries as in your project, but I'm getting the compile error "library not found for -lXMPCoreStatic". Don't know how to solve this, as it all seems correct in the build settings... – Aleph72 Jan 03 '18 at 08:18
  • 1. Please confirm using "lipo -info" that you got all the architecture you needed. 2. Go to 'Build settings' and double check your 'Library search paths'. You should put your libs path there. – Kevin Jan 03 '18 at 10:45
  • The lipo -info gives me this output: `MacBook-Pro-de-Michele:ios mike$ lipo -info libXMPCoreStatic.a Architectures in the fat file: libXMPCoreStatic.a are: armv7 i386 x86_64 arm64 MacBook-Pro-de-Michele:ios mike$ lipo -info libXMPFilesStatic.a Architectures in the fat file: libXMPFilesStatic.a are: armv7 i386 x86_64 arm64`. In the Library search paths I've only got $inherith and $(PROJECT_DIR). – Aleph72 Jan 03 '18 at 10:57
  • Ok, at the end I've been able to compile the project with the two libraries and adding the "include" folder. Now I'll try to modify the "ModifyingXMP.cpp" file. – Aleph72 Jan 03 '18 at 11:22
  • I've added the XmpWriter.mm and .h files (didn't modify the "createXMPFromRDF()"), and tried to build. I'm getting 192 errors of this type: `Undefined symbols for architecture x86_64: "std::string::_S_empty_rep()", referenced from: char* std::string::_S_construct<__gnu_cxx::__normal_iterator const="" std::string=""> >(__gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator, std::allocator const&, std::forward_iterator_tag) in libXMPFilesStatic.a(TimeConversionUtils.o)`. Any idea? – Aleph72 Jan 03 '18 at 12:07
  • 1
    Seems like your static libraries were not built properly. Go to Build Settings, find "C++ Standard library" and add "libc++ (with c++11 support)". If this doesn't solve your issue, please read XmpToolkit docs more carefully, especially the "XMPProgrammersGuide.pdf". You can try to google more about your specific issue. I did this long time ago and I don't remember some details specifically. [link](https://forums.adobe.com/thread/2393377) [link](https://github.com/zthomas/xmp-sdk) – Kevin Jan 04 '18 at 02:40
2

The iOS build support shown in the XMP specification PDF shows this was added in July 2016, but that indicates support for Xcode 7.2.1, so it's possible this library just won't work in Xcode 9, as it's not clear it's been updated anytime recently.

As far as a more concrete method of using the XMP sample project you generated, from the documentation linked above you should be able to find a ReadingXMP demo, which should be platform specific (so helpful for you in Xcode). The doc states that this demo will

Demonstrates the basic use of the XMPFiles and XMPCore components, obtaining read-only XMP from a file and examining it through the XMP object.

You'll need to compile and build them in command line, from <xmpsdk>/samples/source, and will be written to <xmpsdk>/samples/target/. I think filename specified will be the Xcode project the SDK generated, but as you've noticed there's not much documentation there.

I honestly haven't used it myself, but I'm hoping this will help a little :).

BHendricks
  • 4,181
  • 5
  • 28
  • 56
0

I faced a similar problem with needing to read/write XMP data, and ended up creating an Objective-C wrapper over Adobe's XMP ToolKit as an alternative for a more natural API.

I hope it'll come in handy for someone, you could find it on Github & CocoaPods: https://github.com/IHEARTCOOKIES/XMPFramework

COOKIES
  • 364
  • 2
  • 12