Reputation: 777
I am new to Swift and I have already run into problem.
I can't run iOS application written in Swift due to Error:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have my AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
var homeChainingViewController = HomeViewController(nibName: "HomeViewController", bundle: nil)
var navigationController = UINavigationController(rootViewController: homeChainingViewController)
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
Also, I have my Build Phases:
I have tried clean building:
Despite of these, I can't load my Application due to previous error.
Where is the problem and how to solve it?!
Upvotes: 2
Views: 2875
Reputation: 31
I just hit the same problem.
In the AppDelegate, I'd managed to lose the @UIApplicationMain annotation.
e.g. What it should have been:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...
Upvotes: 3
Reputation: 6806
The Copy Bundle Resources
line in the image you have shown is not right. And, iOS apps are in Arm architecture, not x86!
To make an iOS app in Xcode, do File - New - Project - iOS - Application. Pick Single View Application
if you don't know what to try, just to get started.
If your build is complaining about x86 architecture, you must be trying to build for Mac, not iOS.
The Copy Bundle Resources
line when building for either iOS or Mac has a minimum of 2 items to copy, for the automatically generated project.
Upvotes: 1