- Home /
AWS in iOS not working
Hello,
I have setup AWS in my Unity game and it works fine in the editor and on Android but when I test it on iOS it doesn't seem to access AWS properly.
I have added the NSAppTransportSecurity elements to my info.plist file but that doesn't seem to help.
If it helps, the services I'm using are Cognito and SimpleDB.
This is the error I get from the Xcode debugger when trying to access AWS:
NullReferenceException: A null value was found where an object instance was required. at Amazon.AWSConfigs.get_LoggingConfig () [0x00000] in :0 at Amazon.Runtime.ClientConfig..ctor () [0x00000] in :0 at Amazon.CognitoIdentity.AmazonCognitoIdentityConfig..ctor () [0x00000] in :0 at Amazon.CognitoIdentity.AmazonCognitoIdentityClient..ctor (Amazon.Runtime.AWSCredentials credentials, Amazon.RegionEndpoint region) [0x00000] in :0 at Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String accountId, System.String identityPoolId, System.String unAuthRoleArn, System.String authRoleArn, Amazon.RegionEndpoint region) [0x00000] in :0 at GameControl.get_Credentials
This is how credentials is defined:
private CognitoAWSCredentials _credentials;
public CognitoAWSCredentials Credentials
{
get
{
if (_credentials == null)
_credentials = new CognitoAWSCredentials("IDENTITY_POOL_HERE", RegionEndpoint.APSoutheast2);
return _credentials;
}
}
Thanks for any help
Answer by umerPC · Jul 02, 2018 at 08:45 AM
I have fixed the problem with help from Unity support (Thanks Aurimas!)
In order to solve the issue, I had to add the following to my link.xml file.
The managed code stripper was removing types that were needed during compile time.
<linker>
<assembly fullname="log4net" preserve="all"/>
<assembly fullname="System.Configuration" preserve="all"/>
<assembly fullname = "System">
<type fullname = "System.ComponentModel.NullableConverter">
<method name = ".ctor">
</type>
<type fullname = "System.ComponentModel.ReferenceConverter">
<method signature = "System.Void .ctor(System.Type)" /> </type>
</linker>
I am having a similar problem with Aws. I stripped out everything from the project, and am trying to run a stored procedure from Aws Rds ( I know that's not usual standard practice, but this demands it).
All works well in Editor / Android / Pc, but iphone is breaking it. I get this error
System.TypeInitializationException: The type initializer for 'Amazon.AWSConfigs' threw an exception. --->
System.Configuration.ConfigurationErrorsException: Type 'System.Configuration.AppSettingsSection,
System.Configuration, Version=4.0.0.0, Culture=neutral, Public$$anonymous$$eyToken=b03f5f7f11d50a3a' not found.
Which seems like a dumb error, but I couldn't find the solution. It also seems to be a not so uncommon issue (https://github.com/aws/aws-sdk-ios/issues/581).
From the suggested solution here, these lines keep breaking my linker: ("UnityLinker.exe didn't run properly!")
<type fullname = "System.Component$$anonymous$$odel.NullableConverter">
<method name = ".ctor">
</type>
<type fullname = "System.Component$$anonymous$$odel.ReferenceConverter">
<method signature = "System.Void .ctor(System.Type)" /> </type>
Any assistance would be greatly appreciated, my head is already hurting from hitting the wall so much.
my awsconfig.xml
<?xml version="1.0" encoding="utf-8"?>
<aws correctForClockSkew="true" region="eu-central-1">
<logging logTo="UnityLogger" logResponses="Always" log$$anonymous$$etrics="true" log$$anonymous$$etricsFormat="JSON" />
<s3 useSignatureVersion4="true" />
</aws>
And my link.xml
<linker>
<!-- if you are using AWSConfigs.HttpClient.UnityWebRequest option-->
<!--assembly fullname = "UnityEngine">
<type fullname="UnityEngine.Networking.UnityWebRequest" preserve="all" />
<type fullname = "UnityEngine.Networking.UploadHandlerRaw" preserve="all" />
<type fullname = "UnityEngine.Networking.UploadHandler" preserve="all" />
<type fullname = "UnityEngine.Networking.DownloadHandler" preserve="all" />
<type fullname = "UnityEngine.Networking.DownloadHandlerBuffer" preserve="all" />
</assembly-->
<assembly fullname="log4net" preserve="all"/>
<assembly fullname="System.Configuration" preserve="all"/>
<assembly fullname = "mscorlib">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname = "System" >
<namespace fullname="System.Security.Cryptography" preserve="all"/>
<!--type fullname = "System.Component$$anonymous$$odel.NullableConverter">
<method name = ".ctor"/>
</type>
<type fullname = "System.Component$$anonymous$$odel.ReferenceConverter">
<method signature = "System.Void .ctor(System.Type)" />
</type-->
</assembly>
<assembly fullname = "AWSSD$$anonymous$$.Core" preserve="all">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname = "AWSSD$$anonymous$$.CognitoIdentity" preserve="all"/>
<assembly fullname = "AWSSD$$anonymous$$.SecurityToken" preserve="all"/>
</linker>
I had the unitylinker.exe did not run properly. The problem was related to the version of unity I was using, as it had a bug. Can't remember what the version was, but when I updated it to a newer release it got rid of that error!
I just upgraded to a newer unity version and the above method no longer works.
If you are experiencing this bug when switching to IL2CPP , the following fix worked for me on android:
1) Navigate to : C:\Program Files\Unity\Hub\Editor\2018.3.12f1\Editor\Data\$$anonymous$$onoBleedingEdge\lib\mono\unityjit 2) copy and paste these .dlls -system core,systemconfiguration,$$anonymous$$ono.Posix.dll into the desired platform you're building to . e.g. Assets/Plugins/Android.
For ios : 1) Navigate to Fix : C:\Program Files\Unity\Hub\Editor\2018.3.12f1\Editor\Data\$$anonymous$$onoBleedingEdge\lib\mono\unityjit 2) copy and paste these .dlls -system core,systemconfiguration
Does it need to be unity 2018? it doesn't seem to be working from the folder in unity 2020.1.15
Answer by Gwom · Oct 20, 2020 at 05:02 PM
Not sure if it was switching to Mono from IL2CPP but here is my link.xml that is in the root folder (in case anyone needs it):
<linker>
<assembly fullname="UnityEngine">
<type fullname="UnityEngine.Experimental.Networking.UnityWebRequest" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandlerRaw" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandlerBuffer" preserve="all" />
</assembly>
<assembly fullname="mscorlib">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="System">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.Core" preserve="all"/>
<assembly fullname="AWSSDK.CognitoIdentity" preserve="all"/>
<assembly fullname="AWSSDK.SecurityToken" preserve="all"/>
<assembly fullname="log4net" preserve="all"/>
<assembly fullname="System.Configuration" preserve="all"/>
<assembly fullname="AWSSDK.Core">
<type fullname="Amazon.Util.Internal.PlatformServices.NetworkReachability" preserve="all"/>
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.CognitoIdentity">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.SecurityToken">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.DynamoDBv2" preserve="all"/>
</linker>