user3096733 user3096733 - 1 month ago 27
iOS Question

'UIApplicationMain' attribute cannot be used in a module that contains top-level code

All of a suden I got this error in my AppDelegate:

"'UIApplicationMain' attribute cannot be used in a module that contains top-level code"

in the line where it says: @UIApplicationMain

Now the project cannot build. I am using Swift and Xcode 6.2. I have tried deleting the derived data folder and even using the latest Xcode 6.3 beta, which was where I first created the project.

I don't know what's going on and I have searched everywhere with no luck.
Thank you

Answer

Ok, I finally solved it myself. It seems there was another file buried within a library I added called main.swift which was conflicting with my AppDelegate. I deleted it and the issue went away.