Coder Social home page Coder Social logo

Comments (10)

webern avatar webern commented on June 20, 2024

You should add Sourcode/include/mx to your project, not Sourcecode/private/mx/api.

from mx.

CoderAndCat avatar CoderAndCat commented on June 20, 2024

hank you, I fixed it.
I try "#import "mx/api/ApiCommon.h"" . also error when compile.
截屏2021-02-04 14 00 50

This is my xcode configuration for c++
截屏2021-02-04 14 03 16

from mx.

webern avatar webern commented on June 20, 2024

Now I think you're back to the problem where headers are being interpreted as C instead of C++.

Are you including an mx file from a .m file, a .mm file, or something else?

from mx.

CoderAndCat avatar CoderAndCat commented on June 20, 2024

Now I think you're back to the problem where headers are being interpreted as C instead of C++.

Are you including an mx file from a .m file, a .mm file, or something else?

#import "mx/api/ApiCommon.h" in a .mm file.

from mx.

webern avatar webern commented on June 20, 2024

Hmmm, ultimately what you are trying to do is use C++ code in an iOS project, which is a fairly common thing to do.

Xcode build settings are very complicated, and without access to the project it's going to be difficult to help you set it up. Maybe there's an issue with header search paths? Maybe your .mm file is being interpreted as Objective-C instead of C++?

Maybe I can try to set up an example iOS project, but it's not my area of expertise. I think I would probably do one of these things.

  1. add the mx source code to my iOS project directly, or

  2. add the existing mx Xcode project into my project and depend on its iOS framework target, or

  3. build the iOS.framework target from the checked-in Xcode project, then add that and the headers to the iOS project.

Option 3 is what we did when we were working on the Komp iOS project. We chose option 3 because mx takes a while to compile and we didn't want to have to recompile frequently.

Option 1 seems like the simplest to me. Both Option 1 and 2 avoid the possibility of not having the right architecture compiled (when using the simulator, for example). Option 1 avoids having any dependency on someone else's complicated Xcode settings.

from mx.

CoderAndCat avatar CoderAndCat commented on June 20, 2024

Thank you very much for spending time on my question.
Another way is to support'cocoapods'. Is it currently possible?

from mx.

webern avatar webern commented on June 20, 2024

I have not published anything on cocoapods.

Attached is a project that may help you. I will explain in the next message.

mxios-example.zip

from mx.

webern avatar webern commented on June 20, 2024
  • To create this project, I copied mx/Sourcecode into the ios project and renamed it mx-sourcecode.
  • I deleted these, they are not needed:
    • Sourcecode/private/mxtest
    • Sourcecode/private/mx/examples
  • I added the mx-sourcecode to the Xcode iOS project.

My header and C++ settings look like this:
Screen Shot 2021-02-04 at 7 06 48 PM

  • I created a function named getXml() using a .mm file, but exporting it as extern "C" Swift cannot interact with C++, only with C.

image

  • I added that header to the mxios-Bridging-Header.h which made it available in Swift.

image

  • I called it in a swift file

image

  • It worked

image

from mx.

webern avatar webern commented on June 20, 2024

It would certainly be easier if you could find a Swift implementation of MusicXML. With C++ you will have to write C functions and Objective-C classes to bridge between Swift and the C++ layer. I hope this helps!

from mx.

CoderAndCat avatar CoderAndCat commented on June 20, 2024

Thank you very much for your guidance, but I am still a bit new to the C language. I will use it in my project as you demonstrate. Thanks again, I hope to support cocoapods soon

from mx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.