Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Extension of generic type 'Array<T>' from a different module cannot provide public declarations #82

Open
prbaron opened this issue Feb 22, 2015 · 15 comments

Comments

@prbaron
Copy link

prbaron commented Feb 22, 2015

Hello, here is my problem when using your library. This is my first Swift (and iOS) application so I could have made errors in importing or whatever.

CONTEXT
importing your library into my application by drag and dropping the ExSwift folder (not the xcodeproj) into the root of my iOS application.

ACTION
Build the application. No error in my personal code.

RESULT
errors in all methods of the Array class of ExSwift : "Extension of generic type 'Array' from a different module cannot provide public declarations"

EXPECTED
The application should build.

Thanks in advance for your help. Great library by the way !

@pNre
Copy link
Owner

pNre commented Feb 23, 2015

Hi,
this is a known problem with Xcode <= 6.3 where Swift frameworks cannot declare public extensions.

@prbaron
Copy link
Author

prbaron commented Feb 23, 2015

I thought I followed the steps for Xcode 6.1.

Where do I should write this ?

components.takeFirst() { $0.completed }

@pNre
Copy link
Owner

pNre commented Feb 23, 2015

It's just an example, you don't have to write it anywhere.

@prbaron
Copy link
Author

prbaron commented Feb 23, 2015

Ok, then I made the point 2. Should I make the point 1 two ? i do not see why it should be needed.

@prbaron
Copy link
Author

prbaron commented Feb 23, 2015

Do I have to import ExSwift in the embedded libraries in the project manager ?

@pNre
Copy link
Owner

pNre commented Feb 23, 2015

Nope, you have to add the source files from ExSwift to your project (the second point in the list from the readme).

@prbaron
Copy link
Author

prbaron commented Feb 23, 2015

OK so do you know why do I have the error ? I am using Xcode 6.1.1

@pNre
Copy link
Owner

pNre commented Feb 24, 2015

You're probably still linking the framework.
Remove any reference to ExSwift from your project and just add the source files.

@prbaron
Copy link
Author

prbaron commented Feb 24, 2015

Still the same problem ...

@finestructure
Copy link

"1. Use Xcode 6.3 to compile the project (but in that case you won't be able to publish anything on the App Store until 6.3 is released to the public)"

@pNre Does this work for you with 6.3b? I'm using Version 6.3 (6D554n) (beta4) and I can't manage to avoid this error. I must be holding it wrong - is there a way to make these declarations public so it can be built und used as a framework?

@pNre
Copy link
Owner

pNre commented Mar 31, 2015

Can you please link an example project?

@vmanot
Copy link

vmanot commented Apr 3, 2015

What dark magic do you speak of @pNre? It is currently impossible to provide public extensions to generic classes from foreign modules. To till this date, no workaround has been found. I hope you've got a "... yet" stored in there for me.

@finestructure
Copy link

Just add 'public' to an Array extension method like 'each' and you'll get the error, no sample project required :)

@pNre
Copy link
Owner

pNre commented Apr 7, 2015

You're both right, this cannot be done (yet), I must have been drunk when I tried using it as module in beta 3.

@vmanot
Copy link

vmanot commented Jun 19, 2015

Swift 2.0 now allows extensions to generic types. Hooray!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants