In my project, I have Swift extensions on Objective C enums that worked brilliantly in Xcode 7.2.
But with Xcode 7.3, it does not work with the โundeclared typeโ in the Swift file, where I extend the enumeration of Obj C.
I built a sample project and it compiles and works well, but I cannot force an existing project to accept the extension over the Obj C listing.
UPDATE:
After reinstalling Xcode 7.2, I can confirm that the project compiles and builds successfully.
After he worked in Xcode 7.2, I again tried to run this project in Xcode 7.3 and again the same problem -> Swift extension on top of Obj C enums cannot be created.
After clearing and deleting the resulting data in Xcode 7.3, I also get the -Swift.h header error because the Swift classes have not been compiled, so the header has not yet been created.
Code designation:
My Obj C enum inside "FriendRequestResult.h":
typedef NS_ENUM(NSInteger, FriendStatus) { FriendStatusRequestedByUser = 1, FriendStatusRequestedByOtherUser, FriendStatusFriends, FriendStatusBlocked, FriendStatusNone, FriendStatusError, };
Now, as expected in my AppName-Bridging-Header.h, I:
#import "FriendRequestResult.h"
Then I have a quick extension over FriendStatus, which builds in Xcode 7.2, but with the error "use an undeclared type" in Xcode 7.3:
extension FriendStatus { init(stringValue : String?) { if let stringValue = stringValue { switch stringValue { case "REQUESTED_BY_USER": self = .RequestedByUser case "REQUESTED_BY_OTHER": self = .RequestedByOtherUser case "FRIENDS": self = .Friends case "BLOCKED": self = .Blocked default: self = .None } } else { self = .None } } }
Actually this extension over enumeration also has some other helper functions, but this should not in any way change the problem.
Of course, if the enumeration extension gives an undeclared type, then the use of this type does not occur everywhere in Swift code with the same "undeclared things". In principle, the enumeration is not visible at all for the Swift part of the project, even if the import is done in the header of the bridge.
This question has been substantially modified from its first version.