“unsafeMutableAddressor : Swift.String”, referenced from:.."

耗尽温柔 提交于 2019-12-21 07:05:11

问题


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:

General pane:


回答1:


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.




回答2:


It is possible to access application code from your UI tests. Just add the source file to the UI test target:

You can then access that application code from within your UI test code:

But bear in mind that the "application code" you're accessing thus is code running in your UI Test target, not in your actual app. So do not use it to inspect or modify application state.



来源:https://stackoverflow.com/questions/32043920/unsafemutableaddressor-swift-string-referenced-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!