The problem is that the automatically synthesised initialiser you get with a struct is synthesised as internal
, meaning it can't be accessed from another module.
Your unit tests currently run in another module, so they can't see the initialiser. As Ben-G points out in his answer, this is addressed as of Swift 2.0 with the @testable
attribute.
It's part of the general brokenness of unit testing in Swift projects. The unit testing module should have special access to the app modules, otherwise you have to add loads of access control baggage.
From the documentation:
Default Memberwise Initializers for Structure Types
The default memberwise initializer for a structure type is considered private if any of the structure’s stored properties are private. Otherwise, the initializer has an access level of internal.
As with the default initializer above, if you want a public structure type to be initializable with a memberwise initializer when used in another module, you must provide a public memberwise initializer yourself as part of the type’s definition.