OSX Plugin problems

Hello. I just want to clear few things.

I have downloaded simple example from this page

The unity project is working great.

But when I open XCode project I can not compile it. Because I need to change few settings

  1. Architecture → to Starndart(32/64) bit
  2. Base SDK → Lastest(OSX 10.8)
    The it compiles normal. And I can put it into the project.
    But the fun part begins. When I change simple functions inside xCode project, for example:
    from
const char* PrintHello(){
	return "Hello";
}

to

const char* PrintHello(){
	return "Hello222";
}

Inside Unity it steel return’s “Hello” and yes, I am shure that I replaced “ASimplePlugin.bundle”. And when I try to compile project, functions isn’t working. Despite that thay was working in editor second ego.

This is basically first questions. Because I simply cant’ understand what is going wrong.

Here is How try to create simple plugin.

Creating new XCode project

Adding new Objective-C file “Plugin”

Code of Plugin.mm

#import "Plugin.h"

@implementation Plugin


extern "C" {
    float HelloWorld () {
        //here should be some code
    }
}

@end

Then build bundle. Product->Build

Then I putting MyPlugin.bundle inside Assets->Plugins folder

and here is how I try to access my HelloWorld function from Unity.

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

public class PluginImport : MonoBehaviour {
	

	[DllImport ("MyPlugin")]
	private static extern float HelloWorld();	
	
	void Start () {
		
		HelloWorld();
	}
}

And this what I have so far.

DllNotFoundException: user/Documents/Important/OSX/SimplestPluginExample/Unity Project Plugin/Assets/Plugins/MyPlugin.bundle/Contents/MacOS/MyPlugin.bundle
PluginImport.Start () (at Assets/PluginImport.cs:14)

I will appreciate if some one could tell me what I’m doing wrong. Thx.

It’s going to sound snarky - but I just killed at least two hours to this same issue. You made the mistake of both reading and believing the documentation. Here’s where you went wrong:

  1. Architecture → to Starndart(32/64) bit

Don’t do that. Instead:

  1. Architecture → to 32 bit

Unity3D’s runtime, as of 4.2.2 is 32 bit ONLY on OSX. While you’re at it, you should go through the XCode project which comes with the Simplest Plugin Example and purge and and all references to Carbon. (There’s 3 or 4 at least.)

Good hunting.