Build ReWire device (.bundle) for MacOS X in XCode

Hello,

we are developing a cross platform application (Mac/Windows) with the juce framework and want to support ReWire. Our application shall be the audio generating part, the ‘device’ and ‘panel’ in ReWire terminology.
Under Windows the device must be compiled as a dynamic library (.dll). This works perfectly fine with the Projucer project type ‘Dynamic library’.
Our DLL is successfully loaded by the ReWire sample mixer application.
Under MacOS X the device must be compiled as a loadable bundle (.bundle). That’s the point where I’m stuck at the moment.
I was not able to compile and export a bundle from a XCode project generated by Projucer yet. I found this in the Juce forum:
https://forum.juce.com/t/convert-dynamic-library-project-to-loadable-bundle/15993
This seems to be exactly what I need but the proposed solution did not work for me. I was able to compile the project but I wasn’t able to export/archive anything. The build does not show up in the organizer.

Did anybody build a ReWire device with a xcode project generated by the Projucer? Can anybody give me a hint how to configure the XCode project to build a bundle?

Thank you very much in advance!

Jan

Have you found any solution for this? or did you end up making the Xcode project manually?

I can’t remember exactly what I did since it is already some time ago. I think I followed the advice in the post from Anthony_Nicholls I linked above. Additionally I found those notes:

manual changes in bundle project:

Set JUCE_STANDALONE_APPLICATION to ‘0’ in AppConfig.h

XCode settings:
Strip Debug Symbols During Copy : No (Otherwise archive does not work)
Strip style : Non-global Symbols (not sure if this is necessary)
Dead code stripping : Release : Yes (may be already default)

Deployment:
Skip Install : No (Otherwise archived bundle does not show up in organizer)

Symbol visibility:
To keep generated binary small ‘Symbols hidden by Default’ in xcode settings must be set to ‘Yes’ for release builds.

Especially the “Strip Debug Symbols During Copy” setting worries me a bit but since I am not shipping the application at the moment I didn’t look for a better solution.
If you find a better solution I would be interested how you set up your project since mine is still work in progress.

If you’re still looking for a solution, I can recommend not doing it via XCode, but using CMake instead - you can create a CMake build script that creates both the bundle on macOS and the DLL on Windows, and it’s not overly complicated.

If you’re interested, please ask and I’ll gladly share my solution :slight_smile:

1 Like

Yes, I’m definitely interested!

I’ll send you a DM, since I’m not sure how much I can share publicly given the ReWire SDK’s proprietary license.

Yes, CMake is probably the way to go on this. I’d be interested to see your solution as well :wink:
Too bad the Projucer doesn’t support OSX bundles though…

You know what, screw it - I’ll share my solution here.
Note that this ReWire Device doesn’t use the JUCE library, so I don’t link it.

Here’s the CMake script I use to build the ReWire Device on Windows and Mac (may contain errors, I edited my script to remove some application-specific code):

cmake_minimum_required(VERSION 3.15)

project(MyReWireDevice VERSION 0.0.1)

# set preprocessor OS definitions required by ReWire
if (APPLE)
    add_definitions(-DMAC)
elseif (WIN32)
    add_definitions(-DWINDOWS)
endif ()

# build the ReWireDevice bundle
# CHANGE THIS to list all the .cpp files that make up your ReWire Device
add_library(${PROJECT_NAME} MODULE
        MyReWireDevice/bundle.cpp
        MyReWireDevice/MyReWireDevice.cpp)

# CHANGE THIS to your location of the ReWireSDK
target_sources(${PROJECT_NAME} PRIVATE
        external/ReWireSDK/ReWire.c
        external/ReWireSDK/ReWireAPI.c
        external/ReWireSDK/ReWireDeviceAPI.c)

# CHANGE THIS to the location of the ReWireSDK header fles in your project
target_include_directories(${PROJECT_NAME} PRIVATE external)

if (APPLE)
    # on OSX, the ReWire Device needs the Carbon framework
    find_library(CARBON Carbon)
    target_link_libraries(${PROJECT_NAME} ${CARBON})

    # CHANGE THIS to the location of the Info.plist.in file
    configure_file(MyReWireDevice/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/MyReWireDevice/Info.plist)

    # CHANGE the location of the generated Info.plist file to that you specified in the line above
    # CHANGE the location of the ExportList.exp to the one where your file lives
    set_target_properties(${PROJECT_NAME} PROPERTIES
            BUNDLE 1
            MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/MyReWireDevice/Info.plist
            LINK_FLAGS "-Wl,-exported_symbols_list,\"${CMAKE_CURRENT_SOURCE_DIR}/MyReWireDevice/ExportList.exp\"")

elseif (WIN32)
    # on Windows, version.lib is needed
    target_link_libraries(${PROJECT_NAME} version.lib)
endif ()

This is the Info.plist.in file I use:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleDevelopmentRegion</key>
  <string>English</string>
  <key>CFBundleExecutable</key>
  <string>${PLUGIN_NAME}</string>
  <key>CFBundleGetInfoString</key>
  <string>${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}, ${FBSTRING_LegalCopyright}</string>
  <key>CFBundleIdentifier</key>
  <string>com.${ACTIVEX_PROGID}</string>
  <key>CFBundleInfoDictionaryVersion</key>
  <string>6.0</string>
  <key>CFBundlePackageType</key>
  <string>BRPL</string>
  <key>CFBundleShortVersionString</key>
  <string>${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}</string>
  <key>CFBundleSignature</key>
  <string>????</string>
  <key>CFBundleVersion</key>
  <string>${FBSTRING_PLUGIN_VERSION}</string>
</dict>
</plist>

This is the ExportList.exp file I use:

_RWDEFGetDeviceNameAndVersion
_RWDEFGetDeviceInfo
_RWDEFOpenDevice
_RWDEFIsCloseOK
_RWDEFCloseDevice
_RWDEFDriveAudio
_RWDEFIdle
_RWDEFSetAudioInfo
_RWDEFLaunchPanelApp
_RWDEFIsPanelAppLaunched
_RWDEFQuitPanelApp
_RWDEFGetEventInfo
_RWDEFGetEventBusInfo
_RWDEFGetEventChannelInfo
_RWDEFGetEventControllerInfo
_RWDEFGetEventNoteInfo

On macOS, I build this using make, on Windows, I use the Visual Studio compiler from CMake directly.

Let me know if you need any help :slight_smile:

1 Like