Swift 初始化ABBeaconManager時錯誤

您好,在使用swift時出現了以下問題。

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_ABBeaconManager", referenced from:
      type metadata accessor for __ObjC.ABBeaconManager in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我在AppDelegate.swift中試圖初始化ABBeaconManager()就出現錯誤了,
想請問是何原因?
有我用bridging-header.h來import你們的SDK了

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, ABBeaconManagerDelegate {

    var window: UIWindow?
    let beaconManager = ABBeaconManager()

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
//        self.beaconManager.delegate = self
//        self.beaconManager.requestAlwaysAuthorization()
//        self.beaconManager.startMonitoringForRegion(ABBeaconRegion(
//            proximityUUID: NSUUID(UUIDString: "E2C56DB5-DFFB-48D2-B060-D0F5A71096E0")!,
//            major: 100, minor: 101, identifier: "monitored region"))
        
        return true
    }

....
...

謝謝~

你用的SDK 会多少版本的?最新的是2.0.3
正好我们一个项目中也是用的Swift,也集成了我们SDK,是完全没有问题的。


如果你用的cocoapods 集成,是需要iOS8 以上的。

太開心了,看到你也是用swift搭配這beacon開發!

我用的SDK也是2.0.3

//
//  ABBeaconManager.h
//  AprilBeaconSDK
//
//  Created by AprilBrother LLC on 14-4-1.
//  Copyright (c) 2014年 AprilBrother LLC. All rights reserved.
//  version 2.0.3

Xcode是7.3,不知問題何在?

我發現問題所在了,我沒有把framework加到project中。
謝謝回覆~

解决了,就好。可以尝试用 cocoapods 管理第三方。