IOS binding API using objective sharpie, enum defined duplicately error

Engineer Zhang 0 Reputation points
2023-07-26T03:29:24.8533333+00:00
I want to binding static library(.a) to Xamarin iOS.

Firstly I create a new Bindings Library project (IOS->Library->Unified API).

Then I generate ApiDefinitions.cs and StructsAndEnums.cs using objective sharpie( version 3.5.61) and copy codes to project files as official document says.

There are two problems:
  1. Codes in ApiDefinitions.cs cannot find types defined in StructsAndEnums.cs while they are in the same namespace.

Screenshot in ApiDefinitions.cs :

User's image

Screenshot in StructsAndEnums.cs

User's image

But this error will not show when building project.

  1. When building the project, it will show errors like "error CS0101: The namespace 'PushBindingLibIOS' already contains a definition for 'XGPushTokenBindType'".

That is because VS generate a file named like "XGPushTokenBindType.g.cs" in path "Project/PushBindingLibIOS/obj/Debug/iOS/PushBindingLibIOS/"

User's image

I don't know how to solve this problem.

Hoping for your answers.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,378 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Engineer Zhang 0 Reputation points
    2023-07-29T05:51:28.8166667+00:00

    Thank you for your reply. I have found the reason.

    When create new Bindings Library, the Build Action for StructsAndEnums.cs is ObjcBindingCoreSource by default. It works after I change it to ObjcBindingApiDefinition , the same as ApiDefinition.cs.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.