Bill Needels
Bill Needels

Reputation: 567

Xamarin.iOS app with Google AdMob package gets 'The type or namespace name 'Google' could not be found'

I am working up a new Xamarin.iOS app is VS for Mac with Google AdMob support. Similar to this post and that post. I get

The type or namespace name 'Google' could not be found...

Steps to repro in Visual Studio for Mac are

  1. Create a new project using the Xamarin.iOS Single View App template. Take all the defaults.
  2. Use the NuGet Package Manager to add Xamarin.Google.IOS.MobileAds and its prerequisites.
  3. Open AppDelegate.cs and add the line

    using Google.MobileAds;

  4. Build the project.

My VS for Mac is up to date in the stable channel. Xcode and MacOS are up to date.

What is needed to get such a project in VS for Mac to recognize the reference? (I recommend trying proposed solutions on a project created using the repro steps above or trying some other technique in a Xamarin.iOS project in VS for Mac before posting.)

example of issue

Upvotes: 1

Views: 278

Answers (1)

Bill Needels
Bill Needels

Reputation: 567

It looks like my VS for Mac was messed up (across several dot upgrades, hmmm). After the latest upgrade (to 8.6 build 4520) I started another solution and this time the process of adding NuGet packages and getting references in the project works seamlessly.

Should VS for Mac fail again, a workaround is to edit the .csproj file and add the references manually:

<ItemGroup>
    <Reference Include="System" />
    ...
    <Reference Include="Firebase.Core">
      <HintPath><your path>\.nuget\packages\xamarin.firebase.ios.core\6.6.6\lib\xamarinios10\Firebase.Core.dll</HintPath>
    </Reference>
    <Reference Include="Google.MobileAds">
      <HintPath<your path>\.nuget\packages\xamarin.google.ios.mobileads\7.57.0\lib\xamarinios10\Google.MobileAds.dll</HintPath>
    </Reference>
</ItemGroup>
<ItemGroup>
  ...
  <PackageReference Include="Xamarin.Google.iOS.MobileAds">
    <Version>7.24.1</Version>
  </PackageReference>
</ItemGroup>

Upvotes: 1

Related Questions