비슷한 질문이 있지만 내 질문에 대한 대답은 없습니다.Swift : 오류 : 종료 코드 1로 인해 링커 명령이 실패했습니다.
저는 Swift 2.0을 사용하고 있습니다. CoreLocation을 사용하여 경도와 위도를 보여주는 프로젝트를 진행하고 있습니다.
나는 또한 사회 프레임 워크를 사용하여 트위터와 페이스 북에 게시하고 있습니다.
"오류 : 링커 명령이 종료 코드 1과 함께 실패했습니다"라는 오류가 발생하고 "(호출을 보려면 -v 사용)"이라고 알려주지 만 이해가되지 않습니다.
위치 서비스 부분을 작성하려면 여기에서 답변을 참조하겠습니다. 여기 링크 여기 https://stackoverflow.com/a/24696878/6140339
내 코드입니다 :
import UIKit
import Social
import CoreLocation
@UIApplicationMain
class FirstViewController: UIViewController, CLLocationManagerDelegate, UIApplicationDelegate {
var window: UIWindow?
var locationManager: CLLocationManager!
var seenError : Bool = false
var locationFixAchieved: Bool = false
var locationStatus : NSString = "Not Started"
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
initLocationManager();
return true
}
func initLocationManager() {
seenError = false
locationFixAchieved = false
locationManager = CLLocationManager()
locationManager.delegate = self
CLLocationManager.locationServicesEnabled()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
locationManager.stopUpdatingLocation()
if (error == true) {
if (seenError == false) {
seenError = true
print(error)
}
}
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if (locationFixAchieved == false) {
locationFixAchieved = true
let locationArray = locations as NSArray
let locationObj = locationArray.lastObject as! CLLocation
let coord = locationObj.coordinate
print(coord.latitude)
print(coord.longitude)
}
}
func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
var shouldIAllow = false
switch status {
case CLAuthorizationStatus.Restricted:
locationStatus = "Restricted Access to location"
case CLAuthorizationStatus.Denied:
locationStatus = "User denied access to location"
case CLAuthorizationStatus.NotDetermined:
locationStatus = "Status not determined"
default:
locationStatus = "Allowed to location Access"
shouldIAllow = true
}
NSNotificationCenter.defaultCenter().postNotificationName("LabelHasBeenUpdated", object: nil)
if (shouldIAllow == true) {
NSLog("Location to Allowed")
//Start location services
locationManager.startUpdatingLocation()
} else {
NSLog("Denied access: \(locationStatus)")
}
}
@IBAction func postToFacebookButton(sender: UIButton) {
if(SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook)){
let socialController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
//creates post with pre-desired text
socialController.setInitialText("")
self.presentViewController(socialController, animated: true, completion: nil)
}
}
@IBAction func postTweetButton(sender: UIButton) {
if(SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter)){
let socialController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
//creates post with pre-desired text
socialController.setInitialText("")
self.presentViewController(socialController, animated: true, completion: nil)
}
}
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return .LightContent
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//layer.cornerRadius layer.cornerRadius
}
전체 오류 메시지 :
에 _main 중복 기호 : /사용자/사용자/라이브러리/개발자/엑스 코드 /DerivedData/FarOut-ekrxzlgzfahpruavmlhyhiwiynum/Build/Intermediates/FarOut.build/Debug-iphonesimulator/FarOut.build/Objects-normal/x86_64/AppDelegate.o /사용자/사용자/라이브러리/개발자/Xcode/DerivedData/F 아키텍처/x86/64/FirstViewController.o ld : 1 중복 심볼 x86_64 clang : 오류 : 링커 명령이 종료 코드 1을 사용하여 실패했습니다. (호출을 보려면 -v를 사용하십시오.)
당신은 링커 출력을 볼 수 있습니다 ..
가 당신을 도움이되기를 바랍니다 프로젝트를 실행 연설 거품)을 선택한 다음 "빌드"로그를 확장하십시오. 빨간색 링커 오류를 찾아 클릭하여 해당 텍스트를 확장하십시오. 링커가 왜 완료하지 못했는지 보여 주어야합니다. – Paulw11