# Call native plug-ins for iOS

> Understand how to run code when your application is running on a device.

Understand how to run code when your application is running on a device.

You can call iOS native plug-ins only when your application runs on a device or in the Simulator. Wrap native method calls in a C# layer that checks the current platform and returns placeholder values in the Unity Editor, so your scripts don't fail. Store this C# file in your project's `Assets` folder.

Use [platform conditional compilation](/engine/6000.6/manual/scripting/compilation-and-code-reload/script-compilation/conditional-compilation/platform-dependent-compilation.md) or [`Application.platform`](/engine/6000.6/script-reference/unityengine/application/platform.md) to branch your code.

## Use conditional compilation

Platform-dependent compilation is faster than checking `Application.platform` because it’s evaluated at compile time, rather than runtime.

Use the following pattern:

```lang-cs
void MyMethod()
{
#if UNITY_IOS && !UNITY_EDITOR
    CallNativeMethodImplementation();
#else
    CallEditorMethodImplementation();
#endif
}
```

## Check the platform at runtime

Alternatively, check `Application.platform` at runtime and return placeholder values in the Editor:

```lang-cs
void MyMethod()
{
    if (Application.platform != RuntimePlatform.OSXEditor)
    {
        return _GetLookupStatus();
    }
    else
    {
        return "Done";
    }
}
```

## Additional resources

* [Create callbacks from native code](/engine/6000.6/manual/platform-specific/iphone/ios-developing/plugins-for-ios/ios-native-plugin-call-back.md)
* [Unity native plug-in example for iOS](/engine/6000.6/manual/platform-specific/iphone/ios-developing/plugins-for-ios/ios-native-plugin-bonjour-sample.md)
