mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

iOS Build Failure - 'MapboxMobileEvents/MapboxMobileEvents.h' file not found

Open agent-reed opened this issue 9 years ago • 20 comments

When building from Unity to Xcode. It seems that MapboxMetricsClient.m can't import MapboxMobileEvents.h

The setup is:

  • Unity 2017.2.0f3
  • Xcode 9.0
  • Multiple Versions of Mapbox-unity-SDK

Using suggestions from other issues (#101 , #247) I've made sure of the following:

  • Deployment Version is set to 8.0
  • Header Search Paths includes: $(SRCROOT)/Libraries/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/include/

The strange thing is that the file MapboxMobileEvents.h absolutely exists right were the import is looking for it...So it seems like something bizzare with Xcode is going on. For now, we are able to get by simply by removing MapboxMetricsClient.m and any Telemetry Related items in Unity since we don't use any of the Telemetry stuff directly (AFIK). But obviously this isn't what should be done.

Any thoughts?

agent-reed avatar Oct 18 '17 18:10 agent-reed

We have not been able to reproduce this internally, but so far we have at least three reported resolutions. The gist is: remove Mapbox SDK from your project and reimport it.

For reference, did you use a .unityPackage to install Mapbox, or our repo? I wonder if this is related to the installation process.

Also, why do you have multiple versions of the SDK?

david-rhodes avatar Oct 18 '17 19:10 david-rhodes

Sorry, to clarify I meant that we've tried it with multiple versions of the SDK with the same result.

agent-reed avatar Oct 18 '17 19:10 agent-reed

I had this issue and solved it.

I put the entire mapbox repo inside a child folder in Assets. This is what caused the problem for me.

I took everything out of the child folder, and back into /assets/. This solved the problem for me.

UnityEQ avatar Oct 26 '17 12:10 UnityEQ

@UnityEQ Interesting--thank you for the find! I don't think we've ever tested that, but it makes perfect sense to allow developers to nest plugins as they see fit. I'll create a ticket to track that.

david-rhodes avatar Oct 26 '17 17:10 david-rhodes

Closing in favor of #327

david-rhodes avatar Oct 26 '17 20:10 david-rhodes

I discovered that this error occured for me because I had the Symlink Unity Libraries checkbox turned on while building for iOS. Please make sure this is unchecked before building 33154796-e62110da-cf9f-11e7-8010-c7e488e81b6b

apavani avatar Nov 27 '17 19:11 apavani

Was there ever a fix for this? I have ensured Symlink Unity Libraries is unchecked as above. Also moved the full MapBox directory to a child folder and back to original directory as advised but neither worked for me.

animotive avatar Jul 23 '18 16:07 animotive

Just got this problem when building for Ios. You can take the code/example from https://www.mapbox.com/help-video/tutorials/unity-game-pocketdroids-go/

Xcode Version 10.1 beta (10O23u) Unity 2018.2.10f1 mapbox-unity-sdk_v2.0.0.unitypackage

kaitlynhwang avatar Oct 17 '18 23:10 kaitlynhwang

Same problem. Taking project source from an online course and attempting to run it on iPhone and I receive this error. I just upgraded to the latest version of unity. Is there a fix for this? Using the Mapbox ARTable Top with modifications for Drenches of War class on UDemy.

dpruitt90 avatar Oct 30 '18 21:10 dpruitt90

@retinize @kaitlynhwang @dpruitt90 Please make sure you're using target version of 8 and above. Please rebuild the build for iOS from Unity editor, using the append option when overwriting the file. This solves the issue always for me. Unfortunately, there is some issue in the way Unity creates the Xcode project. The headers are all correctly set on our end 😞

abhishektrip avatar Oct 30 '18 21:10 abhishektrip

Same problem here. From official Unity docs:

Note: Subfolders are currently not supported.

Could this be the culprit?

vl4dimir avatar Oct 31 '18 11:10 vl4dimir

~~Confirmed~~ Attempted fix:

  1. Move all files from Assets/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/include/ and Assets/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/ directly into Assets/Mapbox/Core/Plugins/iOS/
  2. Build the project.
  3. Change all #imports that are throwing errors from the #import <MapboxMobileEvents/MapboxMobileEvents.h> format to the #import "MapboxMobileEvents.h" format.

EDIT: This solves the compiler errors, but the linker still bails with:

Undefined symbols for architecture arm64:
  "_inflate", referenced from:
      -[NSData(GZIP) mme_gunzippedData] in libMapboxMobileEventsStatic.a(NSData+MMEGZIP.o)

@atripathi-mb I tried your approach but I got the same errors. This seems to be related to subfolders not being supported.

vl4dimir avatar Oct 31 '18 11:10 vl4dimir

OK this is how I finally got the Xcode build to work:

  1. Build the project from Unity.
  2. In Xcode, add $(SRCROOT)/Libraries/MapBox/Core/Plugins/iOS/MapboxMobileEvents/include to Header Search Paths.
  3. In Build Phases → Link Binary With Libraries, click the "+" sign and add libz.tbd
  4. Build and run.

Hope this helps the maintainers nail down the cause of the issue! 😎

vl4dimir avatar Oct 31 '18 12:10 vl4dimir

@vl4dimir

I tried setting the Header Search Paths only to realize that under Xcode 10.1 beta the values do not set. 1. I went back to Unity and see how the folder was set up. Folder structure Mapbox SDK/Mapbox 2. Moved folder to be Assets/Mapbox instead of Assets/Mapbox SDK/Mapbox 3. Build the project for Unity 4. Build and run

This is only for people who are using Xcode beta and have problems for header search paths can't be saved.

Thanks for the heads up.

kaitlynhwang avatar Nov 01 '18 15:11 kaitlynhwang

Another possible solution/workaround is here: https://github.com/mapbox/mapbox-unity-sdk/issues/1353

jordy-isaac avatar May 08 '19 13:05 jordy-isaac

Another possible solution/workaround is here: #1353

This is the solution here. Fixed my issue. I'm working on PC and pushing through git to my mac to build. thank you!

mhellnerdev avatar Jul 06 '19 07:07 mhellnerdev

For me the problem was because the imported file path did not correspond to the actual location of the file. How I got it to work was:

  1. Inside MapboxMetrics.Client.m change the import line 1 from #import <MapboxMobileEvents/MapboxMobileEvents.h> to #import "MapboxMobileEvents/include/MapboxMobileEvents/MapboxMobileEvents.h"
  2. Inside MapboxMobileEvents.h change the import lines 11-14 from
#import <MapboxMobileEvents/MMEConstants.h>
#import <MapboxMobileEvents/MMEEvent.h>
#import <MapboxMobileEvents/MMETypes.h>
#import <MapboxMobileEvents/MMEEventsManager.h>

to

#import <MMEConstants.h>
#import <MMEEvent.h>
#import <MMETypes.h>
#import <MMEEventsManager.h>

oliviajohansen avatar Jan 03 '21 07:01 oliviajohansen

The above worked for me, BUT ...in conjunction with this thread related to the Build folder being lost due to .gitignore

olgv avatar Feb 07 '21 13:02 olgv

What finally worked for me was to select the UnityFramework in XCode, and then add this entry to the Header Search Paths - "$(SRCROOT)/Libraries/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/include"

I found this by cloning the mapbox-unity-sdk project (which built fine) to a new project where I imported the .package file from map-box. Literally every setting, library, dependency was identical except for the above.

bryanrtboy avatar Feb 16 '22 22:02 bryanrtboy

this issue persists as of August 2023 and the solutions in this thread were of no use so far. it is frustrating because it prevents me from using mapbox at all in my project. If anyone has a newer working solution let me know!

romtecmax avatar Aug 28 '23 13:08 romtecmax