Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ld:Framework not found for architecture i386

I am trying to test a method in my framework, and I wrote a simple test case. But it fails to execute , and xcode gives me the error:

ld: framework not found V***ments for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I double checked that the framework is added in the embedded binary and also in build phase section.

Here is my test file:

import XCTest

@testable import MYClass


class MYClassTests: XCTestCase {

    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }

    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }

    func testExample() {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
    }

    func testPerformanceExample() {
        // This is an example of a performance test case.
        self.measureBlock {
            // Put the code you want to measure the time of here.
        }
    }

    func testInitalization() {

    // tests pass when I comment the following lines.
//        let one = MYClass.sharedInstance
//        XCTAssertNotNil(one, "Failed to create a MYClass instance")
    }
}

When I uncomment the above two lines, I get the Framework not found error.

Also I did tried the following ways:

  • The framework is added in the Embedded binaries framework section.
  • Embedded contains swift code is set to YES,as the framework contains swift code.
  • Executable Prefix in the Packaging section is empty. (It is not set to @executable_path/Frameworks)
  • Runpath Search path in linking is set to

    $(inherited) @executable_path/Frameworks @loader_path/Frameworks

  • Also I tried clean the project and restart the xcode, and build the framework.

  • Deleted the derived data.

I am not sure what could be the issue. Any ideas?

like image 250
Teja Nandamuri Avatar asked Jan 11 '16 20:01

Teja Nandamuri


Video Answer


1 Answers

This is likely because the framework isn't compiled for either the iOS simulator or for your Mac (maybe you've selected an iOS device as the build target).

If you have access to the framework target's project files, head to the Build Settings section and under Build Active Architecture Only select No.

Hope this helps!

like image 159
adamup Avatar answered Sep 30 '22 12:09

adamup