Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by lee__ · Aug 12, 2012 at 08:29 PM · iosxcodepluginsautomation

iOS Plugin Files Not Being Added To Project

I'm trying to add a simple iOS plug in to my project. I'm having no luck so I've stripped it down to the basic and still nothing is working. I've tried a few things...

I'm using Unity Pro with the Pro iOS licence v3.5.5f2 (most recent).

So here's my iOS script

TestPlugIn.m

 int IntReturn()
 {
   return 4;
 }

I've tried variations of this (.mm extension, adding extern "C" when changing it to a .cpp/.mm file, adding the inline keyword, splitting it into a .h/.cpp or .h/.mm file which generate the same results).

In my C# script I have the following

 public class TestScript : MonoBehaviour 
 {
     private void Start()
     {
         Debug.Log( IntReturn() );
     }
  
  [DllImport ("__Internal")]
  private static extern int IntReturn();
 }

Now I've tried adding this to the generated Xcode project in a number of ways.

  • Adding to the Unity project under 'Assets/Plugins/iOS' (no sub folders).

  • Adding to the 'Classes' folder of a pre-generated Xcode project.

In both cases I get the following linker errors when building the generated Xcode project (generated both through the Build Settings options and BuildPipeline.BuildPlayer) because the PlugIn source files have not beed added to, or built by, the Xcode project.

 Undefined symbols for architecture armv6:
   "_IntReturn", referenced from:
       RegisterMonoModules() in RegisterMonoModules.o
 ld: symbol(s) not found for architecture armv6
 clang: error: linker command failed with exit code 1 (use -v to see invocation)

 (null): "_IntReturn", referenced from:
 
 (null): RegisterMonoModules() in RegisterMonoModules.o
 
 (null): Symbol(s) not found for architecture armv6
 
 (null): Linker command failed with exit code 1 (use -v to see invocation)

Looking at the generated project there is no reference to the TestPlugIn.m file, the only reference to the IntReturn function is in the Register Modules file and the Unity generated dlls.

Now, if I manually copy the plug-in files to the classes folder, and manually add them to the project, they work fine. The project builds, copies over to the iPhone and runs quite happily.

But you can't exactly have an automated build process when you have to manually add files to a project half way through.

So, what am I doing wrong because according to the iOS plug-in documents I'm doing everything I should. Any help is appreciated.

(I should also mention that the 'Bonjour Browser Sample' on the iOS Plug Ins documentation page generates the same issues too, even when I change the 'Code' folder to 'Assets/Plugins/iOS')

Thanks

Lee

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by lee__ · Aug 13, 2012 at 07:15 AM

Ok, to answer my own question and in case anyone else has the same issue.

I took the Unity docs at face value

All files with extensions .a,.m,.mm,.c,.cpp located in the Assets/Plugins/iOS folder will be merged into the generated Xcode project automatically

What I took this to mean was in the project view in Unity you needed the following hierarchy (since the majority of the work is done inside Unity itself, I didn't think at this point they were referencing folder structures on disk)

alt text

What it really means is to have the 'Assets/Plugins/iOS' folder structure on disk, so removing the additional Assets folder, and having only Plugins/iOS in the Project view caused the plug-ins to be added as they should.

alt text

One of those things that is obvious now but when reading the documentation it isn't. The documentation could do with a lot more images to make things like this clearer!


wrong path.png (8.7 kB)
right path.png (9.0 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nschrag · Oct 08, 2015 at 06:39 PM 1
Share

Note that this has changed in Unity 5. You can put plugin files anywhere. When you select a plugin file, it will display platform options in the inspector.

http://docs.unity3d.com/$$anonymous$$anual/PluginInspector.html

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Vuforia and Scaleform in Unity 4 on iOS 0 Answers

How ro rewrite Unity XCode Project to make a like Vuforia? 0 Answers

Have to "Replace" iOS project every build because of Linker Errors 0 Answers

UnityAppController.mm copied in 1 Answer

BuildPlayer and Plugins on Ios 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges