parse-community / Parse-SDK-dotNET

Parse SDK for .NET, Xamarin, Unity.
http://parseplatform.org
Apache License 2.0
323 stars 261 forks source link

Unable to build apk in Unity3d #331

Closed SMArhamsoft closed 4 years ago

SMArhamsoft commented 4 years ago

Hello,

I am having issues while making build for Android platform in Unity. The exceptions say this:

Assets/Parse/Parse/Internal/PlatformHooks/Unity/PlatformHooks.Unity.cs(1059,27): error CS0234: The type or namespace name 'iOS' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

Assets/Parse/Parse/Internal/PlatformHooks/Unity/PlatformHooks.Unity.cs(1080,31): error CS1579: foreach statement cannot operate on variables of type '?' because '?' does not contain a public instance definition for 'GetEnumerator'

I tried adding some Platform specific checks PlatformHooks.unity script but it didn't help at all.

TobiasPott commented 4 years ago

Hi @SMArhamsoft

based on the classes you mention I assume you are not using the latest state of this repository as I cannot find any class called "PlatformHooks.Unity.cs". Neither do I find one using the search here online, nor in my local copy of the repository.

I may ask you to try it with the latest state of the repository (you may take a look on other issues regarding building parse for Unity e.g. #313 ) as I cannot provide much help for outdated code or provide fixes which will not get added to the repository.

Back to your issues: You mentioned two compiler issues on two separate issues (as it seems to me). The first one (CS0234) sounds to me that there is some usage of Unity-iOS specific classes inside the "PlatformHooks.Unity.cs" which is not handled by a pre-compiler directive to exclude it from Android builds.

The second one (CS1579) doesn't sound like a Parse specific thing but a mis-use of the foreach statement. As I don't have the surrounding code to determine what the loop is trying to iterate over I would assume that whatever type hides behind the "?" lacks either the method implementation required or the use of foreach at that location in code might be incorrect (or also possible, something used from the Unity assembly was changed on the Unity side).

I would advise you to check out the latest commit to master and the linked issue (see above and the there mentioned repository of mine to use for Unity unless we managed to process the latest pull request from alex.

TheFanatr commented 4 years ago

What’s happening here as far as I can tell is the old SDK is trying to iterate over something it’s trying to get from the now-removed UnityEngine.iOS namespace; the old SDK was written to support a very old version of Unity’s core libraries and Unity has since changed the API surface significantly, including many breaking changes. TL;DR: the old SDK is not compatible with recent versions of Unity.

SMArhamsoft commented 4 years ago

Thanks for explaining what might be going wrong with the issue that I had posted. Yes I was using an old sdk which is working fine with the Unity Editor but when trying to build apk above mentioned errors are thrown. Is there any Unity3d specific unity package of the latest sdk? It would be great help for me if I could get the sdk in the form of a unity package.

I am using Unity Version: 2019.3.12f1

TobiasPott commented 4 years ago

@SMArhamsoft I'm currently preparing the downloadable files for the release section here on github and hope to publish them during the day (CEST). I would ask you to visit Releases and check later today for the binary download. It will not be provided as a .unitypackage file but as a .dll you can drop into your project (inside a "Plugins" folder). I've updated the nuget package a moment ago, you should be able to extract the assembly from it, but doing so would require some additional steps outside Unity and inside Visual Studio, which might be cumbersome.

I estimate to be done with the binaries within the next 2-3 hours. Could you check the above section during this period? And may I ask you to remember me if I did not get it finished by then (here in this issue).

TobiasPott commented 4 years ago

@SMArhamsoft I've added the pre-built assembly to the release section of the repository. If you like you can check them out and try it with your project in Unity.

SMArhamsoft commented 4 years ago

Thank you for the release. I am now able to build apk and it is running perfectly fine on Android platform. The only thing that I wasn't able to configure correctly was to access data without logging in. I don't want to login as it is not a requirement for my project. Without the login it just gets stuck in the loop from where I need to get ParseObjects from the class. I would appreciate if you can help me in this matter.

TobiasPott commented 4 years ago

@SMArhamsoft Glad to hear you could progress =). I've put your problem with access to objects without login into a new issue (#337) as I think it will be most helpful to others if it is not nested inside this issue as they are not directly related (I assume).