Skip to content

## Bug Report: [iOS] 64-bit IL2CPP Builds Run but Does Not Send Analytics on 64-bit iOS Devices #226

@DailyInvestors

Description

@DailyInvestors

Issue Reference: Issue #37

Summary

When building Unity games with the IL2CPP backend for iOS (required for 64-bit support), analytics data is not sent or received on 64-bit devices. The build runs and the app functions as expected, but no analytics are transmitted. This problem does not occur with 32-bit devices or when using the Mono 2.x backend. As the App Store requires 64-bit builds, this is a major blocker.

Steps to Reproduce

  1. Build a Unity project using IL2CPP backend for iOS.
  2. Run on a 64-bit iOS device.
  3. Observe that Google Analytics data is not sent/received.

Expected Behavior

Analytics data should be sent and received as with 32-bit/Mono 2.x builds.

Actual Behavior

No analytics data is transmitted from 64-bit IL2CPP builds on iOS devices.


Patch and Upgrade Proposal

1. Problem Source

The likely cause is platform-dependent code (such as P/Invoke signatures or use of IntPtr) not being correctly marshaled for IL2CPP/64-bit, or missing DllImport attributes that specify CallingConvention.

2. Patch Example

Ensure all external calls use correct DllImport with explicit CallingConvention and use IntPtr for pointer types.

Example Patch for Native Methods (in C#):

// Before
[DllImport("__Internal")]
private static extern void GA_sendEvent(string category, string action, string label, int value);

// After: Add CallingConvention and check parameter marshaling
[DllImport("__Internal", CallingConvention = CallingConvention.Cdecl)]
private static extern void GA_sendEvent(string category, string action, string label, int value);

If you use pointers or handle types, prefer:

[DllImport("__Internal", CallingConvention = CallingConvention.Cdecl)]
private static extern void GA_sendEvent(IntPtr category, IntPtr action, IntPtr label, int value);

And marshal the strings to IntPtr using Marshal.StringToHGlobalAnsi or similar.

3. Additional Recommendations

  • Double-check all native bindings in the Unity plugin for proper 64-bit and IL2CPP compatibility.
  • Ensure .mm and .m files in Xcode project are compiled for both armv7 and arm64.
  • Use Unity’s UNITY_IOS and UNITY_TVOS preprocessor defines to ensure code is included for iOS builds only.

4. Testing

  • After applying the patch, build with IL2CPP for iOS and verify analytics events are received in the Google Analytics dashboard.

Issue Submission Template

Title: [iOS][IL2CPP] Analytics Not Sent on 64-bit Devices (Patch Included)

Description:
On 64-bit iOS devices with Unity IL2CPP backend, Google Analytics events are not transmitted. This is a critical issue because App Store builds must be 64-bit. The cause appears to be incorrect or missing CallingConvention in native plugin bindings.

Patch:
Update all DllImport statements to explicitly set CallingConvention = CallingConvention.Cdecl and verify parameter types are marshaled properly for 64-bit/IL2CPP.

Example Fix:

[DllImport("__Internal", CallingConvention = CallingConvention.Cdecl)]
private static extern void GA_sendEvent(string category, string action, string label, int value);

Impact:
Fixing this will restore analytics functionality for all required iOS builds, ensuring compliance with Apple’s 64-bit requirement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions