amplitude / unity-plugin

Official Amplitude Unity Plugin
https://developers.amplitude.com/docs/unity
MIT License
44 stars 34 forks source link

Unity iOS xcode 'Amplitude\Amplitude.h' file not found #118

Closed Brian-McElroy closed 1 year ago

Brian-McElroy commented 1 year ago

I added Amplitude to an existing Unity project, on Android it was fine, but on iOS when I try to build I get this error ... "'Amplitude\Amplitude.h' file not found"

Project uses Unity 2021.3.9f1 and Ar foundation

I get the same issue with a brand new Unity 2021.3.9f1 project, with nothing in it but the Amplitude SDK. I used the 2.6.0 amplitude-unity.unitypackage file from here https://github.com/amplitude/unity-plugin/releases

image

qingzhuozhen commented 1 year ago

Hi @Brian-McElroy, thanks for choosing Amplitude. Would you mind sharing how you install the SDK? In recent versions, we updated to use the DependencyManager to resolve the iOS dependency. There are tags including the DependencyManager or not.

Brian-McElroy commented 1 year ago

@qingzhuozhen yeah I updated my original comment saying how I installed the smaller unitypackage on a blank project.. I am now trying the bigger unitypackage with the dependency manager thing, and clicking on install cocoapods option before building.. I am having more errors though.

" '/Users/bm/Library/Developer/Xcode/DerivedData/Unity-iPhone-ashdibvxumgdwsahvbmbnujwnvks/Build/Products/ReleaseForRunning-iphoneos/Amplitude/Amplitude.framework/Amplitude(AMPDeviceInfo.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/bm/Library/Developer/Xcode/DerivedData/Unity-iPhone-ashdibvxumgdwsahvbmbnujwnvks/Build/Products/ReleaseForRunning-iphoneos/Amplitude/Amplitude.framework/Amplitude' for architecture arm64 "

image

JonLandmark commented 1 year ago

I am also getting the same bitcode error seen above. Sounds like it requires amplitude to rebuild with ENABLE_BITCODE. Annoyingly without this, I'm having to disable bitcode for my whole project. Can this be looked into?

There is an old issue on the ios SDK which sounds like it shares some similarities - https://github.com/amplitude/Amplitude-iOS/issues/384

DiegoDePalacio commented 1 year ago

I created an empty Unity 2021.3.17f1 project, added Amplitude SDK, and create an Xcode project by building for iOS in the Unity Editor.

Trying to Archive, using Xcode 14.3, gives me that exact error.

Is there any workaround to create an iOS build with the latest Unity's Amplitude SDK?

DiegoDePalacio commented 1 year ago

I found the solution.

In Unity is necessary to choose from the menu: Assets > External Dependency Manager > iOS Resolver > Settings

On the settings is necessary to change the "Cocoapods Integration" from Xcode Workspace - Add Cocoapods to the Xcode workspace, to be instead Xcode Project - Add Cocoapods to the Xcode project

In Xcode is necessary to choose the "Project", then "Build Settings" and in the "Build Options" is necessary to set "Enable Bitcode" to "No"

Then "Archive" can be completed successfully, at least in my case 😅