“unsafeMutableAddressor : Swift.String”, reference

2019-04-23 13:15发布

I got an error:

Undefined symbols for architecture x86_64: "DirectBistro.DBTabBarOrderedIndexesKey.unsafeMutableAddressor : Swift.String", referenced from: DirectBistroUITests.TabBarControllerTests.setUp (DirectBistroUITests.TabBarControllerTests)() -> () in TabBarControllerTests.o ld: symbol(s) not found for architecture x86_64

This is my simple UITest class:

import XCTest
@testable import DirectBistro

class TabBarControllerTests: XCTestCase {

    override func setUp() {
        super.setUp()

        let defaults = NSUserDefaults.standardUserDefaults()
        defaults.setObject([], forKey: DBTabBarOrderedIndexesKey)
        defaults.synchronize()
    }
}

This is how it is defined in DBTabBarController.swift:

let DBTabBarOrderedIndexesKey = "TabBarOrderedIndexesKey"

Info pane:

enter image description here

General pane:

enter image description here

1条回答
我想做一个坏孩纸
2楼-- · 2019-04-23 14:15

The conslusion is: it is not going to work.

I report it as a bug to Apple, and got a response:

UI tests execute differently from Unit tests - Unit tests run inside your application process so they can access your application code. UI tests execute in a separate process, outside your application, so they can simulate how the user interacts with the application. It’s not expected that you will be able to access your app class from a UI test.

查看更多
登录 后发表回答