Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Loken_01 · Jan 26, 2017 at 03:18 PM · iosreflectioninvokelinkingstripping

iOS Reflection Code stripping problem

Hi all,

I've written a small system (node scripting) which invokes functions from different types dynamically, and this works great on most platforms, except iOS.

On Android/Standalone, when I check a reflected type with "GetMethods()", I can iterate through and see every method available.
However on iOS, I can't invoke any of the methods I want to, as "GetMethods()" returns 0 results on the same reflected type. And I've made sure that the type was found, etc.

The method I'm trying to dynamically invoke in this situation is the static "SceneManager.LoadScene(int)", under "UnityEngine.SceneManagement".

I'm pretty sure it's a linking/stripping problem. Due to none of these namespaces/types ever being directly written into the source code, and it's all called dynamically, I'm sure the code stripping is removing what it thinks isn't being used.

But even when I disable code stripping, and I add the "Link.xml" file, which preserves all the namespaces I want to use, I still have the same problem. (Just now with a much larger final build).

I've managed to create workarounds for a lot of the JIT/AOT related problems from IL2CPP, but this simple issue is crippling my project.
Literally everything else works, except apparently this function doesn't exist in the stripped end product.

Thanks in advance to anyone who can potentially help me out with this problem.

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

2 Replies

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

Answer by Loken_01 · Jan 29, 2017 at 09:21 AM

Future note for anyone interested:

If you're creating a link.xml file, "Type" doesn't work unless it is UNDER an "Assembly"...
I read and re-read that docs, and that didn't seem major, and I kept missing it.

 <Assembly> uses "Fullname"  
     <Type> uses "Fullname" and "Preserve"  
         <Method> uses "Name"  

Any other attributes or layout basically disables it, or throws an error from what I've found.
I originally just wanted to avoid stripping of a few types, but it requires being under the assembly tags.

I tried to simply preserve the entire Unity Assembly just to quickly check if it was a stripping issue.
That does not work!

Specify exactly what you want using the above tags/attributes.

  • Peace

Comment
Add comment · 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
0

Answer by v01pe_ · Sep 27, 2017 at 02:23 PM

Damn, that's nasty! I implemented a saving system based on reflection and well … you can imagine the rest.

Turns out to avoiding code stripping on members can be achieved much simpler, by just adding some strong references to the stripped methods/properties/fields.

In my case I implemented a Behavior that just sets some properties to their own values. This behavior is only used in one level that basically just contains this script. I build this level, but never actually load it.

 using UnityEngine;
 
 public class PreserveAssembly : MonoBehaviour
 {
     public SomeBehavior someBehavior;
 
     void Start()
     {
         someBehavior.someField = someBehavior.someField;
         transform.eulerAngles = transform.eulerAngles;
     }
 }

SomeBehavior is an other Behavior where I want to use reflection on its property someField.

Comment
Add comment · 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

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

82 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 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 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 Build Error 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do I remove plugin for iOS builds only 1 Answer

IOS : Which parts of the System namespace can you use with ' micro mscorlib' stripping 1 Answer

Xcode 8 linking error help 0 Answers


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