Search Unity

Unity iOS plugin linker error

Discussion in 'iOS and tvOS' started by ercion, Jul 18, 2018.

  1. ercion

    ercion

    Joined:
    Aug 15, 2016
    Posts:
    73
    Hi, I encountered the following error while trying to build an iOS plugin I created for Unity. Can anyone please help me fix this error and successfully build this app?


    Undefined symbols for architecture armv7:
    "_Foo", referenced from:
    _Bar_Foo_m2346119406 in Bulk_Assembly-CSharp_0.o
    (maybe you meant: _Bar_Foo_m2346119406)
    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 Unity C# code:
    Code (CSharp):
    1. public class Bar : MonoBehaviour {
    2. ...
    3.     [DllImport("__Internal")]
    4.     private static extern void Foo(string URL, string Quote);
    5. ...
    6. }

    Here's my Objective-C header:
    Code (CSharp):
    1.  
    2. //
    3. //  FooUtil.h
    4. //
    5. //
    6.  
    7. #ifndef FooUtil_h
    8. #define FooUtil_h
    9.  
    10. #import <Foundation/Foundation.h>
    11. #import <UIKit/UIKit.h>
    12.  
    13. @interface FooUtil : NSObject
    14.  
    15. + (void)Foo:(const char*)URL :(const char*)Quote;
    16.  
    17. @end
    18.  
    19. #endif /* FooUtil_h */

    Here's my class file code in Objective-C:
    Code (CSharp):
    1. //
    2. //  FooUtil.m
    3. //
    4.  
    5. #import "FooUtil.h"
    6. #import <Foundation/Foundation.h>
    7.  
    8. @interface FooUtil ()
    9. @end
    10.  
    11. @implementation FooUtil
    12. + (void)Foo:(const char*)URL :(const char*)Quote {
    13. }
    14.  
    15. @end
    16.  
    I've never actually written Objective-C code so I have no idea what I'm doing.
     
  2. ercion

    ercion

    Joined:
    Aug 15, 2016
    Posts:
    73
    Okay I successfully built the plugin by removing the header file, and changing my Objective-C code to the following:

    Code (CSharp):
    1.  
    2. //
    3. //  FooUtil.m
    4. //
    5. #import <Foundation/Foundation.h>
    6.  
    7. void Foo(const char* URL, const char* Quote) {
    8. }