Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS status and how-to #305

Open
izzyreal opened this issue Nov 30, 2022 · 4 comments
Open

iOS status and how-to #305

izzyreal opened this issue Nov 30, 2022 · 4 comments

Comments

@izzyreal
Copy link

izzyreal commented Nov 30, 2022

What is the status of iOS support? I see some issues about iOS and something was merged back in 2020, but the https://github.com/thestk/rtmidi frontpage does not list iOS (yet?).

If (partial) iOS support is already implemented, how does this work? I'm including the following in my CMakeLists.txt:

set(RTMIDI_BUILD_STATIC_LIBS ON)
set(BUILD_SHARED_LIBS OFF)
set(RTMIDI_BUILD_TESTING OFF)
set(RTMIDI_TARGETNAME_UNINSTALL "rtmidi_uninstall")

FetchContent_Declare(rtmidi
    GIT_REPOSITORY https://github.com/thestk/rtmidi.git
    GIT_TAG        5.0.0
    SOURCE_DIR     ${CMAKE_SOURCE_DIR}/deps/rtmidi
)

FetchContent_MakeAvailable(rtmidi)

target_link_libraries(MyProject rtmidi)

This works fine for macOS, but when I build for iOS I get

/foo/rtmidi/RtMidi.cpp:43:6: warning: 'TARGET_OS_IPHONE' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
#if (TARGET_OS_IPHONE == 1)
     ^
/foo/rtmidi/RtMidi.cpp:890:16: error: use of undeclared identifier 'AudioGetCurrentHostTime'
        time = AudioGetCurrentHostTime();
               ^
/foo/rtmidi/RtMidi.cpp:893:14: error: use of undeclared identifier 'AudioConvertHostTimeToNanos'
      time = AudioConvertHostTimeToNanos( time );

and a bunch more errors.

Many thanks in advance.

@izzyreal
Copy link
Author

izzyreal commented Dec 2, 2022

For anyone reading this, for now I've resolved this by doing the below in my CMakeLists.txt:

if (IOS)
    target_compile_definitions(rtmidi PRIVATE TARGET_OS_IPHONE=1)
endif()

But setting this is actually the responsibility of #include <TargetConditionals.h> as far as I know. So I doubt this is the way to go. Not sure if I should do something different on my end, or if there's in issue in rtmidi.

PS: I first tried to #include <TargetConditionals.h> before including RtMidi.h, but this did not help.

@GarrettFleischer
Copy link

I'm completely lost here... Could you perhaps give some more details on how to set this up? Thank you

@izzyreal
Copy link
Author

@GarrettFleischer What is your issue precisely? For what it's worth, here's my static lib's CMakeLists.txt where you can see

target_compile_definitions(rtmidi PRIVATE TARGET_OS_IPHONE=1)

in context: https://github.com/izzyreal/mpc/blob/ee500b24c64b3bff438c533711c539541343c8ef/CMakeLists.txt#L127

@GarrettFleischer
Copy link

@izzyreal thank you for the response, I was able to do it through creating a new xcode project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants