After converting some parts of my project to Swift, I've run into some problems 
with my tests.

The first problem was where an app (not test) function, in Swift, was iterating 
over an NSArray of instances of a Swift class, because that array was generated 
by Objective C code. It was throwing an exception because the objects were of 
the wrong type. I eventually figure out that it was because my Swift files are 
in both the app and test targets, so there are two versions of each Swift class.

For Swift tests, I understand that you're now supposed to not have your Swift 
sources in the test target, and instead use "@testable import MyAppModule". But 
what about test written in Objective C that need to access my Swift classes? If 
they're not in the test target, they won't be in AppTest-Swift.h. Is there some 
other way to generate a Swift header file?

Without that, I'm looking at two alternatives for the NSArray iterating 
scenario:
- Rewrite the function that does the iterating, using Objective C so that it 
doesn't do the type checking.
- Rewrite the function that creates the array, using Swift so that hopefully 
the classes will match.

Any other recommendations?

-- 
David Catmull
davidcatm...@gmail.com
http://uncommonplace.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to