Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by roypo · Oct 28, 2016 at 01:05 PM · iospluginopencvframeworkhowto

iOS C++ plugin that itself relies on framework

From my understanding, basic iOS C++ plugins are dead simple. Simply jot down working code in a .mm text file and shove that file into Assets/Plugin/iOS. Even simpler than making a windows .dll plugin.

But... what about an iOS plugin that itself makes calls to another framework like, say, OpenCV? How do you include that? The documentation beyond the most basic examples like the one I linked is sparse. Do I just dump opencv2.framework into Assets/Plugin/iOS and cross my fingers my own C++ code will know to talk to OpenCV's through some kind of magic? I am pretty sure there must be some additional steps, probably once the generated project's gotten to Xcode's side of things. What would these steps be?

Any help or link to a tutorial or documentation pertinent to my use case highly appreciated. Thanks!

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sergio7888 · Oct 28, 2016 at 06:45 PM 0
Share

User code in unity uses C# or UnityScript(very similar to javascript) to use a code from a c++ dll you will need use C# Interoperability to use the dll content.
See Interoperability (C# Program$$anonymous$$g Guide)

avatar image roypo Sergio7888 · Oct 28, 2016 at 07:03 PM 0
Share

I know that. I successfully made what I needed for Editor / Windows and Android phones / tablets as a .dll and a .so respectively. $$anonymous$$y C++ .dll gives me a layer to interface with the few OpenCV for Windows methods I need while in the Editor, and my C++ .so gives me the same for Android.

Now I need to get the same functionality ported to iOS, which probably means dancing with Xcode to create my own static library (.a) to, again, interface between Unity and OpenCV. $$anonymous$$aking a straight iOS Unity plugin for something like adding two int or returning "hello world" is simple. $$anonymous$$aking a straight include of OpenCV for an iOS app without going through Unity at all is also simple. It's both ends, Unity > iOS <- OpenCV (or any other framework) that there doesn't seem to be any documentation about gluing together.

avatar image Sergio7888 roypo · Oct 28, 2016 at 11:32 PM 0
Share

You can't create the methods in C# or UnityScript? Unity have packages specific for iOS and Android and you can use #if to check the plataform.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by roypo · Nov 03, 2016 at 02:21 PM

In Xcode I made a static library (a .a file) implementing the header and source for my methods. That static library was linked to the OpenCV for iOS framework. I had to make sure to copy the framework's Headers and Resources subfolders and opencv2 file, all located in Versions\A, back to the root of the framework.

I could then place the static library and the OpenCV for iOS framework in my Unity iOS plugin folder, and use the library from Unity script as I would a .dll or .so through [DllImport ("__Internal")].

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Using a .embeddedframework (ios) in Unity - EntryPointNotFoundException 0 Answers

iOS framework integration 0 Answers

Using OpenCV/Python script with Unity on Mobile device (iOS) 0 Answers

Linker errors on Xcode 4.5.2 with OpenCV 2.4.3 2 Answers

Custom swift framework in Unity iOS game 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges