UnityAds/UnityAds.h file not found (Xcode)

Hello, after updating Unity Ads Legacy to v4.12.0 and exporting to iOS Xcode 16 I get this error in xcode:
UnityAdsShowListener UnityAds/UnityAds.h file not found.
I’m using only Unity Ads.

My Unity version is 2022.3.47f1

Edit: I have tried the latest version 2022.3.49f1 and the same result.
I have downgraded to Unity Ads Legacy 4.4.2 and now it works.
The problem is that the newest Unity Ads Legacy SDK does not include the UnityAds.framework in xcode and I can’t include it manually.

9 Likes

Thank you so much for posting this! The problem fixed when I downgraded to Ads Legacy 4.4.2. Please fix this Unity developers!

4 Likes

Thank you! I downgraded to 4.4.2 as well and it fixed the problem!

1 Like

Downgrade is fixed my problem, but I think there will be a problem during the live release because I’m not using the latest version. Thanks for posting this.

2 Likes

Ok in package manager I upgraded from Advertisements Legacy from 4.4.2 to 4.12.0 (to support the Apple Privacy Manifest update orelse Apple rejects your build)… Unity then tries to install cocoapods… and in my case fails.

Open a terminal and type ‘pod’ - if its installed then great, in my case in Unity I got an error saying it couldn’t install cocoapods for the current user.

I then went down some rabbit hole learning about cocoapods and trying to get cocoapods setup correctly… some posts say use bash, some say zsh, run install, gem install, sudo install, install to the user directory… blah blah… I ended up in a situation where cocoapods was installed, but couldn’t run as one of its dependencies was throwing an error…

so I then uninstalled cocoapods completely:
sudo gem uninstall cocoapods -n /usr/local/bin
sudo gem uninstall cocoapods

then installed brew:
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

then used brew to install cocoapods (this also installs its dependencies):
brew install cocoapods

at the end of the install it asks you if you want to link, you need to run the 3 commands that it gives you.

Then do a clean build of the unity project and hopefully its builds fine.

In the built Xcode project open the file with the .xcworkspace extension, this will open Xcode, with the pods, and the iPhone project should now find UnityAds/UnityAds.h and build.

1 Like

Same error with my project:

In file included from Libraries\com.unity.ads\Plugins\iOS\UnityAdsLoadListener.mm:1:
Libraries\com.unity.ads\Plugins\iOS/UnityAdsLoadListener.h(1,9): fatal error: 'UnityAds/UnityAds.h' file not found

Did you ever find a resolution for this? I need 4.12.0 for ad targeting.

1 Like

Thank you very much!!!
4.4.2 can fixed!!!

acytall I start at 4.12.0 But it didn’t works!
I wondering why Unity let this happen?

Here is the SOLUTION :
The best way is to install homebrew via terminal in macOS.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

brew install ruby

gem install cocoapods

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

source ~/.zshrc

gem environment

Look for the value for INSTALLATION DIRECTORY (it will probably look something like /usr/local/lib/ruby/gems/3.4.0/ or a similar Homebrew path).

Next, look for the value for EXECUTABLE DIRECTORY. This is the path you need to run pod and might look something like this: /usr/local/lib/ruby/gems/3.4.0/bin (or a path under ~/.gem/ruby/3.4.0/bin).

ruby -v

Based on what version of ruby you have installed, type the following command (replace 3.4.0 with your version)

echo 'export PATH="/usr/local/lib/ruby/gems/3.4.0/bin:$PATH"' >> ~/.zshrc

source ~/.zshrc

which pod

cd /Users/macbook/Desktop/thegame (replace this with your unity exported folder)

pod install

Wait for it to install dependencies..
Now open the project .xcworkspace in xcode.
This is the setup you need to install homebrew, you will make this only once and from now on , on each project you just need to open terminal and use cd command and pod install.
This worked on my Intel based macbook.