Build Issues on MacOS M1 Arch

I’ve been trying to build code developed by my team on MacOSM1 architecture using xCode 12.4.
Mac is running BigSur version 11.2.3. I’ve tried this with JUCE 6.0.6, 6.0.7, 6.0.8 and the develop branch. Each time I try to build for a Release target the following build error occurs:

In XCode file->project->build system is set to “New Build System Default”

Use of undeclared identifier 'objc_msgSend_fpret' juce_osx_ObCHelpers.h

The code snippet that this points to is:

typedef double (*MsgSendFPRetFn) (id, SEL op, ...);
static inline MsgSendFPRetFn getMsgSendFPRetFn() noexcept  { return (MsgSendFPRetFn) (void*) objc_msgSend_fpret; }
#endif````

Are you sure that the project is using your upgraded version of JUCE and not one that is part of the project?

I had exactly the same error because I was trying to build one of my old plugins for M1, and the Projucer project was set up such that it was using the JUCE modules that are included in the repo (I have it set up like this in order to simplify building Windows and Linux versions on Azure Pipelines).

As soon as I made sure that the Projucer project was actually picking up the latest version of JUCE then that error went away.

1 Like

I am trying to update a midi app I wrote a few years ago, and compile with Xcode for M1 Mac.

I may well be doing something stupid as I’m not a regular coder and I’ve forgotten much of what I knew when I wrote the app.

I have installed Juce 6 and updated my project with the projucer but Xcode throws a spurious error, that has me completely confused.

the code Xcode objects to is longstanding boilerplate virtual midi output code:

void MidiIO::makeMainOut()
{

delete mainOutput; //close old output // is this needed?


    //create virtual midi out
    mainOutput = MidiOutput::createNewDevice ("MantaMainOut");
    if (mainOutput != nullptr)
    {
        deviceManager.setDefaultMidiOutput("MantaMainOut");//what does default do anyway?
        cout << "created MantaOut main out \n";
    }
    else
        cout << "failed to create main out \n";
}

the error is:

Assigning to 'juce::MidiOutput *' from incompatible type 'std::unique_ptr<MidiOutput>'

Some parts of JUCE’s API have changed in the past couple of years. The error is telling you that the return type of MidiOutput::createNewDevice isn’t assignable to the type of mainOutput. To resolve the issue, you probably need to update the type of mainOutput to be a std::unique_ptr<juce::MidiOutput>.

That seems reasonable. However I have no idea how.

mainOutput is declared in MidiIO.h like this:

private:
AudioDeviceManager deviceManager;
MidiOutput *mainOutput;
MidiOutput *expOutput;

I looked up std::unique_ptr but it is over my head for now.

Is there a code example anywhere of creating and opening midi virtual output?

I’m going to check again, but I think I also got this error trying to compile using an old version of Juce, where this code had worked fine…

There’s no examples in the JUCE repo, but it should be as simple as changing
MidiOutput *mainOutput; to std::unique_ptr<MidiOutput> midiOutput;. You would then need to remove any calls to delete mainOutput as the unique_ptr will handle this automatically.

Thanks! that did it!

I also had to change some ScopedPointers to std::unique_ptr in another part of the app entirely to do with a file tree

it now seems to run, at least in debug mode in Xcode…