C/C++ External dynamic library linkage -- example project?

  1. ‹ Older
  2. 2 years ago

    Stephen G

    4 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    @Norman P --

    I think the problem(s) I'm running into with IOS MAY be due to using Xcode 7.2.1. Xcode 8.x is the minimum required for proper IOS & Xojo?

  3. Stephen G

    4 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    I'm also seeing an issue with normal macOS where a Xojo External Method with a parameter of Int32 is not finding the corresponding C-API dylib function with that parameter defined as int32_t. That should absolutely work, right?

  4. Norman P

    4 Nov 2017 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    @StephenGreenfield @Norman P --

    I think the problem(s) I'm running into with IOS MAY be due to using Xcode 7.2.1. Xcode 8.x is the minimum required for proper IOS & Xojo?

    For what you're doing Xcode 7 or 8 should be OK as really Xojo just needs to be able to start the simulator & those two versions behave similarly in this regard

  5. Norman P

    4 Nov 2017 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    @StephenGreenfield I'm also seeing an issue with normal macOS where a Xojo External Method with a parameter of Int32 is not finding the corresponding C-API dylib function with that parameter defined as int32_t. That should absolutely work, right?

    I'd expect so yes

  6. Stephen G

    4 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    @Norman P --

    Got Xojo's invocation of the IOS SIMULATOR to access and correctly call dylib, but ONLY if I use soft declare and provide a full path to the dylib.

    But trying to use the External Method approach didn't work for IOS as it had for macOS -- it results in a compile-time error, "this item does not exist", for each of the External Methods I call.

    HOW I SET UP THE EXTERNAL METHODS:

    • Build Copy step copies dylib to Frameworks
    • Lib field in External Method definition uses @executable_path/Frameworks/libIOSTestLibForXojo_simulator.dylib
    • Soft checkbox selected; Objective-C checkbox NOT selected. Scope = "Global"

    Even explicitly setting each External Method's Lib field to the same exact path as I provided for soft declare results in the compile-time error "this item does not exist" for each call.

    In both cases (soft declare and External Method) the dylib was compiled for i386 architecture. That worked perfectly with soft declare and IOS Simulator.

    Is there any documentation, FAQ, tutorial, etc. that discusses the library path for calling one's own dylib / framework for an IOS project?

  7. Stephen G

    4 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    As for submission to the app store I am not 100% sure if they will or will not accept apps with dylibs in the Frameworks dir of the app package

    @Norman Palardy --

    I'm happy to package my library for IOS by any method (dylib, Framework, or Xcode-linked .a file) that allows it to become part of the Xojo-generated app but it MUST get into the app store. There MUST be an absolute sure-fire route to do so, Right? Otherwise the thousands of IOS MonkeyBread functions offered by @Christian Schmitz wouldn't function on IOS?

    I have a large, deep, and battle-tested library of non-UI cross-platform C++ code with a C-API that is essential to work with the Xojo front end on ALL platforms.

  8. Norman P

    4 Nov 2017 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    @StephenGreenfield There MUST be an absolute sure-fire route to do so, Right?

    I expect there is for the very reasons you said but

    @Norman P I am not 100% sure

    :P

  9. Stephen G

    7 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    @Norman P -- Xojo support god Jason is presently researching the answer on C/C++ library (dylib, framework, et al) inclusion as part of an IOS app submitted to the Apple App Store. But seeing as this very basic question has taken two days (so far) to research, I'm getting a bit nervous...

  10. Norman P

    7 Nov 2017 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    The App submission guidelines are usually very thorough about what is / isn't permitted
    They don't explicitly say this is or is not allowed
    I havent spoken to Jason so it could be he's put the question to our Apple Support Rep and that can take time to get an answer

    I'm reasonably sure this is OK (google "ios using a dylib in your app" and you get a pile of hits)
    Plus
    - Apple gives you "how to's" on doing this with a "framework" which is a header + dylibs (and maybe other resources like images)(https://developer.apple.com/library/content/technotes/tn2435/_index.html )
    At the very least I suspect you could make this a framework and then its certainly OK and the declares are not much different just the location
    - there are several discussions on StackOverFlow about this https://stackoverflow.com/questions/4733847/can-you-build-dynamic-libraries-for-ios-and-load-them-at-runtime , https://stackoverflow.com/questions/37257763/can-i-compile-c-library-into-dylib-and-use-them-in-ios-9-project (and several others)

    Now Apple _may_ have changed the rules and require an app extension (that I'm not sure of)
    But I sure cannot find anything from them that says a dylib loaded this way is NOT ok

  11. Christian S

    7 Nov 2017 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    App submission with library is not a problem.

    I did submit a FileMaker based iOS app with my plugins.
    If you follow all the rules, they allow that.

  12. Stephen G

    8 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    @ChristianSchmitz -- Thanks -- I didn't see this before I emailed you earlier.

    I wonder if the rules for what is permitted is different for FILEMAKER (because Apple owns FIleMaker, Inc) than for Xojo? Do your own MBS IOS plug-ins make calls into a custom IOS Framework during IOS runtime?

    As I am beginning to understand the picture, a Xojo use must:

    1) generate a Framework -- not a bare dylib -- which gets included in the Xojo app "package". Of course, it must be properly signed.

    2) To make calls into that Framework, Xojo IOS uses MUST use soft declare and NOT External Method definitions, correct?

    3) Callbacks into the main Xojo code from the Framework are permitted by Apple?

  13. Christian S

    8 Nov 2017 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Xojo has no plugin SDK for iOS, but FileMaker has one.
    The plugin is just another framework the app loads.

  14. Stephen G

    8 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    @ChristianSchmitz --

    So your MBS functions for IOS are via your own IOS Framework? And those are called via soft declares?

  15. Christian S

    8 Nov 2017 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    my iOS stuff for Xojo is only Xojo source code without a library/framework.

  16. Stephen G

    8 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    Thanks, Christian -- then I guess I need to find someone else that has actually made calls into their own IOS Framework!

  17. Norman P

    8 Nov 2017 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    I thin Jean Paul Devulder did some stuff for iOS that uses his own dylib
    BUT I could be wrong
    You could PM him
    He's on here reasonably frequently

  18. Stephen G

    9 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    @Norman P -- yes, Paul Devulder has created his own Framework that integrates into an IOS project. He has shared that with me, and I think I see the process involved.

    However, he hasn't tried submitting a Xojo-generated IOS app containing his Framework to the IOS App Store. I'm not certain if anyone has.

    However, as @ChristianSchmitz states above, he has submitted an app to the IOS App store that contains his own Framework(s). So it seems doable.

  19. Stephen G

    12 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    @Garth H -- You mentioned earlier:

    I use a "callback" - I send the AddressOf of a Xojo function to the DLL, and call that.

    Do you have a simple example of this process? When calling from a Windows DLL vs a macOS dylib, is there a different calling convention to pass parameters back from the C-API code to the Xojo callback function?

  20. Eli O

    is not verified 12 Nov 2017 Europe (Berlin, Germany)

    #Pragma Directives Keyword
    Scroll to X86CallingConvention.

  21. Stephen G

    12 Nov 2017 Pre-Release Testers, Xojo Pro Ellensburg, Washington

    Cool! So stdCall on Windows -- but for macOS? CCDecl?

or Sign Up to reply!