I created a new Xamarin Forms app for iOS in Visual Studio and added the following code in AppDelegate.cs referencing the ArcGIS runtime.
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize();
return base.FinishedLaunching(app, options);
}
This is the error I get with the Initialize method.
[0:] An error occurred: 'CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory assembly:<unknown assembly> type:<unknown type> member:(null)'. Callstack: ' at (wrapper managed-to-native) RuntimeCoreNet.GeneratedWrappers.CoreArcGISRuntimeEnvironment.CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory(byte[],intptr&)
at RuntimeCoreNet.GeneratedWrappers.CoreArcGISRuntimeEnvironment.SetInstallDirectory (System.String installPath) <0x138775060 + 0x00010> in <2a33546a5b934b588629d4e33895c554>:0
at Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.InitNative () <0x1387748c8 + 0x00004> in <2a33546a5b934b588629d4e33895c554>:0
at Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize () <0x138774538 + 0x00042> in <2a33546a5b934b588629d4e33895c554>:0
at App1.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00013] in C:\Users\Chris\Documents\OnScene Xplorer\App1\App1.iOS\AppDelegate.cs:33
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at App1.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\Chris\Documents\OnScene Xplorer\App1\App1.iOS\Main.cs:17
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 '
Per Reflector, it's attempting to make a call into a native method using DllImport.
[DllImport("__Internal")]
private static extern void CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory([In, Out, MarshalAs(UnmanagedType.LPArray)] byte[] installPath, out IntPtr outErrorHandle);
I checked the deployment folder on my iPhone. There is a native framework coming in from Nuget and it is making it onto the iPhone. It appears to be the target of the native call. In my UWP app, 2 dlls (runtimecore.dll and runtimecorenet.dll) appear to be the target of the native call.
[0:] File: /private/var/containers/Bundle/Application/5A23D747-9648-4727-8677-FB4E036F0343/App6.iOS.app/Frameworks/ArcGIS-arm64.framework/_CodeSignature/CodeResources
[0:] File: /private/var/containers/Bundle/Application/5A23D747-9648-4727-8677-FB4E036F0343/App6.iOS.app/Frameworks/ArcGIS-arm64.framework/ArcGIS-arm64
[0:] File: /private/var/containers/Bundle/Application/5A23D747-9648-4727-8677-FB4E036F0343/App6.iOS.app/Frameworks/ArcGIS-arm64.framework/Info.plist
I also see this in the verbose build output:
3>MtouchExtraArgs = --framework:"${ProjectDir}/framework/ArcGIS-arm64.framework" --dynamic-symbol-mode=code
...
3>Task "AssignLinkMetadata" (TaskId:169)
3> Task Parameter:
3> Items=
3> C:\Users\Chris\.nuget\packages\esri.arcgisruntime.runtimes.ios\100.10.0\buildTransitive\Xamarin.iOS10\..\..\framework\ArcGIS-arm64.framework\ArcGIS-arm64
3> CopyToOutputDirectory=PreserveNewest
3> Link=framework\ArcGIS-arm64.framework\ArcGIS-arm64
3> C:\Users\Chris\.nuget\packages\esri.arcgisruntime.runtimes.ios\100.10.0\buildTransitive\Xamarin.iOS10\..\..\framework\ArcGIS-arm64.framework\Info.plist
3> CopyToOutputDirectory=PreserveNewest
3> Link=framework\ArcGIS-arm64.framework\Info.plist (TaskId:169)
3>Done executing task "AssignLinkMetadata". (TaskId:169)
I've read that native calls in iOS are static have to be built/compiled into the app. Do you know how I can check that this is happening correctly? Any idea what is going wrong with this native call?
Any help would be GREATLY appreciated. I would very much like to use my iPhone without a Mac to do dev on this project. Also don't want to commit to a Mac and then find the same problem!