Welcome! › Forums › Unity Plugins › Precise Locale › Crash on Iphone simulators
- This topic has 6 replies, 4 voices, and was last updated 6 years, 2 months ago by Piotr.
-
AuthorPosts
-
February 14, 2018 at 3:49 pm #736bananalopaParticipant
Hi, could you help me?
Looks like plugin crashes the app when I am trying to use it with any iphone simulator in xcode.
Code in unity which causes this error is calling: PreciseLocale.GetLanguageID()
Output:
dyld: Symbol not found: __getLanguageID
Referenced from: /Users/admin/Library/Developer/CoreSimulator/Devices/EA30ED97-A267-4690-91C1-3D2642B825C5/data/Containers/Bundle/Application/A8F3B4C9-70DF-4E4C-B3AF-C5C8A4E1E8D6/mandala.app/mandalaCould you fix it or at least add handler that prevents the crash?
February 20, 2018 at 10:35 pm #756GillissieParticipantI ran into this too, and it’s unfortunate that the plugin doesn’t handle it gracefully. What I did was make my own define for IOS_BUILD at the top of PreciseLocale.cs
#if UNITY_IOS && !IOS_SIMULATOR // The iOS plugin for this crashes in the simulator, so don't use it if in simulator mode. #define IOS_BUILD #endif
Then in the rest of the code, replace UNITY_IPHONE with IOS_BUILD (UNITY_IPHONE is considered obsolete anyway, so the author should change it).
Then, when you want to build for the simulator, you have to add IOS_SIMULATOR to the Scripting Define Symbols under “Other Settings” on the build settings (a little bit under where you have to choose “Simulator SDK” for Target SDK).
- This reply was modified 6 years, 7 months ago by Gillissie.
February 20, 2018 at 10:37 pm #758GillissieParticipantOf course, the downside to this hack is that it uses the default settings in the simulator, instead of the simulator’s settings, but you can temporarily change them in code if you need to test other values.
February 22, 2018 at 5:10 am #759PiotrKeymasterGuys, I am sorry but will check it next week since I am out now. Frankly I’ve never run Unity app in simulator.
July 26, 2018 at 10:18 am #1156denboParticipantHey Piotr,
is there any update on this?
Since Facebook asks for a Simulator build for their submission this problem is kind of a hassle…
July 28, 2018 at 12:16 pm #1166PiotrKeymasterYes, I’ve checked this issue and Unity simply does not support iOS plugins working on simulator.
https://answers.unity.com/questions/768959/why-are-unity-plugins-disabled-on-the-ios-simulato.htmlAs a workaround (so it will use the same dummy values as in Editor):
1. OpenPreciseLocale.cs
2. Replace it content with this:#if UNITY_IOS && !IOS_SIMULATOR #define IOS_BUILD #endif using UnityEngine; using System.Collections; using System.Runtime.InteropServices; using System; public class PreciseLocale : System.Object { private interface PlatformBridge { string GetRegion(); string GetLanguage(); string GetLanguageID(); string GetCurrencyCode(); string GetCurrencySymbol(); } private class EditorBridge : PlatformBridge { public string GetRegion() { return "US"; } public string GetLanguage() { return "en"; } public string GetLanguageID() { return "en_US"; } public string GetCurrencyCode() { return "USD"; } public string GetCurrencySymbol() { return "$"; } } private static PlatformBridge _platform; private static PlatformBridge platform { get { if (_platform == null) { #if UNITY_ANDROID && !UNITY_EDITOR _platform = new PreciseLocaleAndroid(); #elif IOS_BUILD && !UNITY_EDITOR _platform = new PreciseLocaleiOS(); #elif UNITY_STANDALONE_OSX && !UNITY_EDITOR _platform = new PreciseLocaleOSX(); #elif UNITY_STANDALONE_WIN && !UNITY_EDITOR _platform = new PreciseLocaleWindows(); #else _platform = new EditorBridge(); #endif } return _platform; } } public static string GetRegion() { return platform.GetRegion(); } public static string GetLanguageID() { return platform.GetLanguageID(); } public static string GetLanguage() { return platform.GetLanguage(); } public static string GetCurrencyCode() { return platform.GetCurrencyCode(); } public static string GetCurrencySymbol() { return platform.GetCurrencySymbol(); } #if UNITY_ANDROID && !UNITY_EDITOR private class PreciseLocaleAndroid: PlatformBridge { private static AndroidJavaClass _preciseLocale = new AndroidJavaClass("com.kokosoft.preciselocale.PreciseLocale"); public string GetRegion() { return _preciseLocale.CallStatic<string>("getRegion"); } public string GetLanguage() { return _preciseLocale.CallStatic<string>("getLanguage"); } public string GetLanguageID() { return _preciseLocale.CallStatic<string>("getLanguageID"); } public string GetCurrencyCode() { return _preciseLocale.CallStatic<string>("getCurrencyCode"); } public string GetCurrencySymbol() { return _preciseLocale.CallStatic<string>("getCurrencySymbol"); } } #endif #if IOS_BUILD && !UNITY_EDITOR private class PreciseLocaleiOS: PlatformBridge { [DllImport ("__Internal")] private static extern string _getRegion(); [DllImport ("__Internal")] private static extern string _getLanguageID(); [DllImport ("__Internal")] private static extern string _getLanguage(); [DllImport ("__Internal")] private static extern string _getCurrencyCode(); [DllImport ("__Internal")] private static extern string _getCurrencySymbol(); public string GetRegion() { return _getRegion(); } public string GetLanguage() { return _getLanguage(); } public string GetLanguageID() { return _getLanguageID(); } public string GetCurrencyCode() { return _getCurrencyCode(); } public string GetCurrencySymbol() { return _getCurrencySymbol(); } } #endif #if UNITY_STANDALONE_OSX && !UNITY_EDITOR private class PreciseLocaleOSX: PlatformBridge { [DllImport ("PreciseLocaleOSX")] private static extern string _getRegion(); [DllImport ("PreciseLocaleOSX")] private static extern string _getLanguageID(); [DllImport ("PreciseLocaleOSX")] private static extern string _getLanguage(); [DllImport ("PreciseLocaleOSX")] private static extern string _getCurrencyCode(); [DllImport ("PreciseLocaleOSX")] private static extern string _getCurrencySymbol(); public string GetRegion() { return _getRegion(); } public string GetLanguage() { return _getLanguage(); } public string GetLanguageID() { return _getLanguageID(); } public string GetCurrencyCode() { return _getCurrencyCode(); } public string GetCurrencySymbol() { return _getCurrencySymbol(); } } #endif #if UNITY_STANDALONE_WIN && !UNITY_EDITOR private class PreciseLocaleWindows: PlatformBridge { [DllImport ("PreciseLocale", EntryPoint="_getLanguage")] private static extern IntPtr _getLanguage (); [DllImport ("PreciseLocale", EntryPoint="_getRegion")] private static extern IntPtr _getRegion (); [DllImport ("PreciseLocale", EntryPoint="_getCurrencyCode")] private static extern IntPtr _getCurrencyCode (); [DllImport ("PreciseLocale", EntryPoint ="_getCurrencySymbol")] private static extern IntPtr _getCurrencySymbol (); public string GetLanguage() { return Marshal.PtrToStringUni(_getLanguage()); } public string GetLanguageID() { return GetLanguage() + "_" + GetRegion(); } public string GetRegion () { return Marshal.PtrToStringUni(_getRegion()); } public string GetCurrencyCode () { return Marshal.PtrToStringUni(_getCurrencyCode()); } public string GetCurrencySymbol () { return Marshal.PtrToStringUni(_getCurrencySymbol()); } } #endif }
3. Go to PlayerSettings and under Scripting Define Symbols put
IOS_SIMULATOR
, just like here: https://monosnap.com/file/I6roysuGhvcjyvbVajHwGUWwSvFuCgLet me know if that worked for you.
- This reply was modified 6 years, 2 months ago by Piotr.
July 28, 2018 at 12:17 pm #1168PiotrKeymasterThanks Gillissie for all your tips.
-
AuthorPosts
- You must be logged in to reply to this topic.