0

I am trying to use RabbitMq in an iOS app. As recommended, I am using this Objective-C wrapper, which stipulates : There is nothing to build. Just include the source and header files into your Xcode project and link it againt librabbitmq-c. However, I have been unable to build the app so far. I am using the last stable versions available on GitHub.

1/ I have tried to include all files (both rabbitmq-objc and rabbitmq-c) in my project, and build as usual (as suggested here). After replacing a few types (uint8 into u_int8_t) and solving a few imports ("amqp.h" instead of < amqp.h>) as suggested by XCode, I ended up with this error : Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 254. I deep cleaned project, erased content of ~/Library/Developer/Xcode/DerivedData, but no luck.

2/ I have then tried to build rabbitmq-c with cmake via command-line :

mkdir build && cd build
cmake ..
cmake --build . --config Release

And then importing as a dynamic lib in my project. When linking in the project, XCode complains that building for iOS Simulator, but linking against dylib built for MacOSX file. I have read a few post on how to address this issue, but I am not sure exactly how to proceed.

3/ I have thus finally used the CMake.app for MacOS, setting the generator to XCode. I have imported the rabbitmq-c.xcodeproj built as a dynamic lib, and set the header path to the correct folder. After setting the Other linker flags to -ObjC -all_load, I still get an error : no such file or directory: '/Users/Guillaume/Library/Developer/Xcode/DerivedData/RabbitMQSandbox-bvhczedxhtejhxcwdqmdewzzexjj/Build/Products/Debug-iphonesimulator/librabbitmq.4.0.0.dylib'.

I am losing hope. Can somebody point me toward the right direction ?

Community
  • 1
  • 1
guik
  • 419
  • 6
  • 11

1 Answers1

1

I finally found it, here it is for further reference

1/ get the latest rabbitmq-c and rabbitmq-objc libraries.

2/ make sure Cmake is updated (2.6 or better)

3/ install iOS-cmake

4/ in rabbitmq-c directory (change OSX_ARCHITECTURES and IOS_PLATFORM flags for simulator or device)

mkdir build.ios && cd build.ios
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/iOS.cmake 
-DIOS_PLATFORM=SIMULATOR (resp. OS) 
-DCMAKE_IOS_DEVELOPER_ROOT=/Applications/Xcode.app/Contents/Developer     
-DCMAKE_IOS_SDK_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.2.sdk 
-DCMAKE_OSX_ARCHITECTURES=x86_64 (resp. i386)
-DBUILD_STATIC_LIBS=True 
-DENABLE_SSL_SUPPORT=False 
-GXcode ..

5/ in build.os/librabbitmq, rename directory Debug to Debug-iphonesimulator. Open in XCode the librabbitmq-c.xcodeproj, select target rabbitmq-static, build, and close this project.

6/ import in project that will be using the library librabbitmq.a. In build settings, make sure that Always Search User Paths is set to Yes and that User Header Search Path contains both paths to rabbitmq-c/librabbitmq and to rabbitmq-c/build.ios/rabbitmq-c.

7/ copy the rabbitmq-objc classes in the project, and set -fno-objc-arc flag for those classes.

8/ Replace occurences of uint8 by u_int8_t, replace occurences of #import < Cocoa/Cocoa.h> by #import < Foundation/Foundation.h>, replace occurences of #import < amqp.h> and #import < amqp_framing.h> by #import "amqp.h" and #import "amqp_framing.h".

9/ In AMQPConsumer.m, add missing parameter AMQP_EMPTY_TABLE in function amqp_basic_consume, and in AMQPExchange.m, add missing

#define AMQP_EXCHANGE_TYPE_DIRECT @"direct" 
#define AMQP_EXCHANGE_TYPE_FANOUT @"fanout"
#define AMQP_EXCHANGE_TYPE_TOPIC @"topic"

10/ Build project.

guik
  • 419
  • 6
  • 11