0

So, as part of my effort to learn Swift, I got my hands on the open source "Adventure" project (found HERE) made available by Apple.

Embarrassingly, I didn't go too far before I ran into my first predicament. When I tried to compile the project, I got the following error:

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

Specifically, the error is found in the AppDelegate.swift file and the attribute comes immediately after the import UIKit declaration as follows:

import UIKit

@UIApplicationMain
class AppDelegate: NSObject, UIApplicationDelegate {
    var window: UIWindow?
    ....
    // a number of functions that I won't list here...
    ....
}

I did some research on this but understandably(?) there doesn't seem to be much information regarding this issue. I wonder if anyone has run into the same issue.

(By the way, I am using Xcode6-beta5)

EDIT 1 --------------

Now with a fresh install of Beta6, I get the following errors after compile:

Undefined symbols for architecture x86_64: "TFSs15_arrayForceCastU___FGSaQ__GSaQ0", referenced from: __TFC9Adventure13HeroCharacter20animationDidCompletefS0_FOS_14AnimationStateT_ in HeroCharacter.o __TFC9Adventure13HeroCharacter14fireProjectilefS0_FT_T_ in HeroCharacter.o __TFC9Adventure4Cave15applyCaveDamagefS0_FTSd10projectileCSo6SKNode_T_ in Cave.o __TFC9Adventure4Cave12performDeathfS0_FT_T_ in Cave.o __TFFC9Adventure4Cave16loadSharedAssetsFMS0_FT_T_U_FT_T_ in Cave.o __TFC9Adventure6Goblin20animationDidCompletefS0_FOS_14AnimationStateT_ in Goblin.o __TFFC9Adventure6Goblin16loadSharedAssetsFMS0_FT_T_U_FT_T_ in Goblin.o ... "__TFSsoi1aUSs17_RawOptionSetType_USs21BitwiseOperationsTypeSs9Equatable__FTQ_Q__Q_", referenced from: __TFC9Adventure21LayeredCharacterScene14handleKeyEventfS0_FTCSo7NSEvent7keyDownSb_T_ in LayeredCharacterSceneOSXEvents.o "__TFVSC6CGSizeCfMS_FT5widthSd6heightSd_S_", referenced from: __TFFC9Adventure6Archer16loadSharedAssetsFMS0_FT_T_U_FT_T_ in Archer.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1

I'm not even going to try to guess what these errors mean.

BinaryCat
  • 1,220
  • 2
  • 17
  • 32
  • It seems to work fine with no changes in Xcode6-Beta6 – Mike S Aug 26 '14 at 00:01
  • @MikeS - I just tried it on Beta6 but no dice :( – BinaryCat Aug 26 '14 at 02:27
  • Odd... did you try cleaning and re-building? Sometimes you also need to delete your derived data for a project after upgrading to Beta6, otherwise you get really strange compile errors. – Mike S Aug 26 '14 at 02:29
  • @MikeS - In all honesty, I'm not exactly sure how you'd "clean" and rebuild, but I just completely removed the project files and restarted Xcode with clean instance (really just another unzip) of the project. Now I get more errors! Please see above update. – BinaryCat Aug 26 '14 at 02:45
  • For that error I think you're going to need to delete your derived data. To do that, open the Organizer ("Window" menu -> "Organizer"), select the "Adventure" project on the left side of the window, then click the "Delete" button associated with the project's derived data (should be the top one on the far right). FYI, deleting the project files and creating a new set from a zip file will still leave the derived data in place because it's stored in a separate location. Also you can "clean" a project from the "Project" menu. – Mike S Aug 26 '14 at 03:00
  • @MikeS - Not only did you help me fix the error, but also I learned something new. Thank you, good sir! (Do u mind adding a quick comment as an answer so I can accept it?) – BinaryCat Aug 26 '14 at 03:13
  • Posted a quick answer. Glad I could help :) – Mike S Aug 26 '14 at 03:16

2 Answers2

1

Apparently the Adventure project doesn't compile correctly in Xcode6-Beta5. However, Xcode6-Beta6 compiles and runs it just fine.

As for the error encountered after upgrading to Beta6, the way to fix that is to delete the derived data for the project. To do that, open the Organizer ("Window" menu -> "Organizer"), select the "Adventure" project on the left side of the window, then click the "Delete" button associated with the project's derived data (should be the top one on the far right).

Mike S
  • 41,895
  • 11
  • 89
  • 84
0

For me, It seems there was another file called main.swift which was conflicting with my AppDelegate. I deleted it and the issue went away.

Siempay
  • 876
  • 1
  • 11
  • 32