Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Write Unity IOS plugin in Swift code

Discussion in 'AR/VR (XR) Discussion' started by Ellajohn, Feb 23, 2018.

  1. Ellajohn

    Ellajohn

    Joined:
    Feb 23, 2018
    Posts:
    1
    Hi all,
    Is it possible to write unity IOS plugin in Swift?

    I already have a working swift framework and want to use it as a plugin in Unity

    I saw some places which say it can only be done on Objective-c but is there a workaround for swift?

    Thanks.
     
  2. johnson267

    johnson267

    Joined:
    Feb 1, 2022
    Posts:
    1
    Step 1: Create your Swift classes.
    Step 2: Include "unityswift-Swift.h" and define C functions to wrap Swift classes in .mm file (Objective-C++).
    Step 3: Create interface class to call exported C functions from C#.
    Step 4: Call the method from your C# code.
    Requirements

    iOS 7 or later

    Compatibility

    Unity 5.3.5f1 Xcode 7.3.1

    Thanks,
    KBS Training