• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trouble with imported enums in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with imported enums in Swift


  • Subject: Re: Trouble with imported enums in Swift
  • From: Greg Parker <email@hidden>
  • Date: Tue, 21 Oct 2014 18:13:03 -0700

> On Oct 21, 2014, at 5:45 PM, Rick Mann <email@hidden> wrote:
>
> I've created a sample project showing the behavior and submitted it with radar #18730653.

Thanks for the bug report. There is a Swift importer bug here. Your enumerators all have a common name prefix, but that name prefix differs from the type name. I think the importer tries to remove that prefix from the Swift names but gets it wrong.

typedef NS_ENUM(int, McpResponseStatus) {
    MCP_RESPONSE_SUCCESS       = 0,
    MCP_RESPONSE_BAD_TOKEN     = 1
};
// Swift names should be McpResponseStatus.SUCCESS etc.
// Swift is instead mistakenly importing these as McpResponseStatus.CP_RESPONSE_SUCCESS etc. (with only 'M' removed).


Workaround: add an enumerator that doesn't have the same name prefix. Then the importer will not try to strip any common prefix and you can use the long names in Swift.

typedef NS_ENUM(int, McpResponseStatus) {
    MCP_RESPONSE_SUCCESS       = 0,
    MCP_RESPONSE_BAD_TOKEN     = 1,
    SwiftHackForMcpResponseStatus
};
// Swift names are McpResponseStatus.MCP_RESPONSE_SUCCESS etc.


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Trouble with imported enums in Swift
      • From: Rick Mann <email@hidden>
References: 
 >Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Roland King <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Roland King <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: "Raglan T. Tiger" <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Greg Parker <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Quincey Morris <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Quincey Morris <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Greg Parker <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Trouble with imported enums in Swift
  • Next by Date: Re: Trouble with imported enums in Swift
  • Previous by thread: Re: Trouble with imported enums in Swift
  • Next by thread: Re: Trouble with imported enums in Swift
  • Index(es):
    • Date
    • Thread