Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Martin Schultz · Mar 13, 2013 at 07:04 PM · macdllnative pluginosx

Native Mac Plugin: EntryPointNotFoundException

I'm trying to get my feet wet with native plugin programming and my goal is to write a OSX / Mac plugin that can be used for Push notifications on the Mac. So far I've followed the basic steps to create a cocoa bundle and created an objective C class named "Plugin" (Plugin.h/.m).

For a simple test I would like to call from Unity a NSLog output in the plugin via the SoundTest method. The .m file looks like this:

#include #import "Plugin.h"

@implementation Plugin

  • (void)DebugLog:(NSString *)msg { NSLog(@"###################################"); }

  • (void)SoundTest { // <-------------- WANT TO CALL THIS ONE FROM C# CODE NSLog(@"======================================"); } ... ...

I created a corresponding C# file to import the plugin:

using UnityEngine; using System.Collections; using System; using System.Runtime.InteropServices;

public class PushNotificationPlugin {

 //Calls to the native plugin
 [DllImport ("PushNotification")]
 public static extern void SoundTest();

Now I got in Xcode a pre-defined PCH file and I read that I have to define in there via some extern "C" the method call. But how?

This is the generated PushNotification-Prefix.pch file:

#ifdef __OBJC__ #import <Cocoa/Cocoa.h>

extern "C" { static extern void SoundTest(); // <----- doesn't work }

endif

/pre>

Comment
Add comment
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

2 Replies

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

Answer by jonas-echterhoff · Mar 14, 2013 at 08:48 AM

Hey Martin,

you cannot call Obj-C code directly from C#. The line:

  static extern void SoundTest();

declares a C prototype for a function SoundTest(), but your code does not actually define such a function, so it cannot be found. The Obj-C method you have is not a C function and won't match that prototype. In your case, I don't see a reason to write SoundTest as an Obj-C method at all, just make it a normal C function:

 void SoundTest() { // <-------------- WANT TO CALL THIS ONE FROM C# CODE
     NSLog(@"======================================");
 }

Lastly, make sure you are compiling with the correct architecture (Unity 4.1 will only load 32-bit plugins, but latest versions of Xcode default to building 64 bit binaries).

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
avatar image
1

Answer by Graham-Dunnett · Mar 13, 2013 at 09:37 PM

http://docs.unity3d.com/Documentation/Manual/PluginsForDesktop.html

Comment
Add comment · Show 1 · 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
avatar image Martin Schultz · Mar 14, 2013 at 06:49 AM 0
Share

Thanks Graham. I followed that tutorial, but it is written for C++ and I need to code that in Objective-C. The code in the manual page doesn't work for Obj-c.

Btw, the $$anonymous$$idi Plugin link is broken on that page.

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

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using a DLL assembly on Mac 2 Answers

Using native plugin with callbacks in editor (OS X) 3 Answers

Can't run unity 2.6.1 on mac os x 10.6.3 2 Answers

Unity fails to include .bundle for native code plugin when building Intel Mac player. 0 Answers

Xamarin, MonoDevelop 4 or current unity mono? 1 Answer


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