I'm trying to get a simple objective C iOS plugin working and am having problems with linker errors. There's various discussions about this but no clear simple working samples that I can find. See my code below. I'm getting the following error:> Undefined symbols for architecture armv7:
"__getO2", referenced from:
RegisterMonoModules() in RegisterMonoModules.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here's my code. (Note that it's the .h and .m files that don't work. If I replace the .h and .m with the .mm file it runs perfectly):
**Assets/Scripts/CubeLevitate.cs:**
@interface O2Plugin : NSObject
{
float _getO2;
}
@end
**Assets/Plugins/iOS/O2Plugin.m:**
#import "O2Plugin.h"
@implementation O2Plugin
-(float)_getO2
{
return 98.2f;
}
@end
**Assets/Plugins/iOS/O2Plugin.mm (this works when I replace the .h and .m above with this C++ code, but I want to use Objective C directly. Do I really have to call the obj C from C++??**
extern "C"
{
float _getO2(void)
{
return 98.2f;
}
bool _initializeBT(void)
{
}
}
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class CubeLevitate : MonoBehaviour {
[DllImport ("__Internal")]
private static extern float _getO2();
private float o2Val;
void Start () {
o2Val = getO2();
Debug.Log("Return Float = " + o2Val);
}
void Update () {
}
float getO2()
{
if (Application.platform == RuntimePlatform.IPhonePlayer)
return _getO2();
else
return 95f;
}
}
**Assets/Plugins/iOS/O2Plugin.h:**
#import