Explicitly referring to library global (if I follow compiler's suggestion, it complains)

I'm trying to move a bunch my iOS app's code into an Xcode local package. One thing I'm running into is that I have some structs that define a sharpImageURL method that's a wrapper to a global sharpURLMethod (with more parameters). When it was a monolithic app, we had to preface this call to the global with moduleName.. Now it can't find that module, obviously, so I tried prefacing it with the library module name AppLibrary. If I do that, it says AppLibrary doesn't have such a method. But if I leave off any prefix, I get this:

Use of 'sharpImageURL' refers to instance method rather than global function 'sharpImageURL(bucket:key:size:)' in module 'AppLibrary'
Use 'AppLibrary.' to reference the global function in module 'AppLibrary'

If I apply the fix-it, I get:

Type 'AppLibrary' has no member 'sharpImageURL'

Not that this error is in code within the library, and the method signatures differ, so there should be no ambiguity. In another situation I have, Swift has no qualms about choosing a method even when my intention isn't all that clear (IMHO).

Is this a bug? Xcode 13b1. If it’s not a bug, how do I get it to do what I need?

Read the error message carefully. It looks like you have a type named AppLibrary. When a type has the same name as a module, the type is preferred. This is why you should never have a type with the same name as a module. Rename the module to something more verbose like AppLibraryModule. Because this is a local package that (presumably) only you use, this should be easy.

Oh you're right. The template contained a struct AppLibrary auto-generated. Xcode would've been good to make that clear.

Terms of Service

Privacy Policy

Cookie Policy