question

ValentinCHARLES-0039 avatar image
0 Votes"
ValentinCHARLES-0039 asked RobCaplan edited

Many CS0246 and CS0518 errors after adding an iOS part to a Xamarin Android project

After adding an iOS part to a Xamarin project that already had an Android part and a PCL part, I have a huge mass of errors that appear (5532 to be exact) (CS0518 and CS0246 type errors)

most of the errors are these :
- The type name or namespace 'System' cannot be found (are you missing a using or an assembly reference?)
- The predefined type 'System.Object' is not defined or imported
('.Object' can be replaced by other types)

The large majority of my errors are in the Android project

Thanks for your help!

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ValentinCHARLES-0039 avatar image
1 Vote"
ValentinCHARLES-0039 answered

Hello,

I had already tried these solutions, it didn't work.

However, I tried deleting the .VS folder from the application so that it would regenerate it, and it worked.

Thank you for your help

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered

Hello,​

Welcome to our Microsoft Q&A platform!

Here are the steps about how to add a platform project to a existing Xamarin.Forms project, you could refer to it.

  1. Create a iOS project or copy an iOS project to the target solution

  2. Install the Xamarin.Forms nuget and the other packages if necessary

  3. Add shared project reference to the iOS project

  4. Change the code of the AppDelegate class to add the 'LoadApplication' unfunction

Here is the related code about AppDelegate.cs.

[Register("AppDelegate")]
public class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        // create a new window instance based on the screen size
        global::Xamarin.Forms.Forms.Init();
        LoadApplication(new App());

        return base.FinishedLaunching(application, launchOptions);
    }
}


Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.