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 siddharth3322 · Oct 24, 2014 at 01:03 PM · iosnative pluginsharing

Executing native iOS code in Unity

I want to execute following code in Unity.

     UIImage *image      = [UIImage imageNamed:@"roadfire.png"];
     NSString *message   = @"Best image from my application.";
     
     NSArray *postItems  = @[message, image];
     
     UIActivityViewController *activityVc = [[UIActivityViewController alloc]initWithActivityItems:postItems applicationActivities:nil];
     [self presentViewController:activityVc animated:YES completion:nil];

I have implemented similar code for Android using AndroidJavaObject and AndroidJavaClass object but I can't able to understand how to convert this code?

Only starting point become enough for me.

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
0

Answer by Bunny83 · Oct 24, 2014 at 01:13 PM

AndroidJavaObject and AndroidJavaClass are wrapping the JNI interface that is available for native code by the JVM. So your route is:

 your managed code -> Unity's native JNI wrapper -> Java

iOS of course doesn't run Java since iOS requires all code to be compiled AOT to xcode / objective c. When you build an iOS project, Unity just creates an xcode project which then can be built using xcode. You are free to change the code that Unity has cross compiled, however you have to do this every time when you rebuild the xcode project from Unity.

It's probably possible to compile a native library for iOS that you can add to the Unity project itself as "plugin". However i'm not familiar with iOS development. Maybe someone else know how to create "objective c plugins" for unity.

I don't like the objective c syntax. It looks "too alien" to me :D

Comment
Add comment · Show 2 · 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 siddharth3322 · Oct 24, 2014 at 04:27 PM 0
Share

Thanks @Bunny83 for this help. I have one question in my $$anonymous$$d. Can I modify unity code using xcode means add some code?

avatar image Bunny83 · Oct 25, 2014 at 12:18 AM 0
Share

Yes, as i said when you build your Unity project for iOS you actually create an xcode project which can be modified in xcode. Just take a look at the project that get generated. Of course don't use "build and run" as this will tell xcode to build the project and push the app to your device.

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

28 People are following this question.

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

Related Questions

iOS native share PDF popup with QuickLook option 1 Answer

A node in a childnode? 1 Answer

Sharing image and text using objective c native code 1 Answer

Execute native ios code in unity 1 Answer

Share text message on selected media 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