ExSwift icon indicating copy to clipboard operation
ExSwift copied to clipboard

Impossible to use ExSwift.framework: architecture x86_64 error

Open rizal72 opened this issue 11 years ago • 8 comments

I've tried everything and more to include your wonderful library, as a single .framework file, in a project of mine, but all I get is a Mach-O Linjer Error: symbol(s) not found for architecture x86_64. All my other custom libraries included in my project compile correctly...

If I import the sources into my project everything compiles correctly. But i'd like to use the library feature instead...

Really I don't know if it's my issue or an XCode bug.

Thanks for any advice!

rizal72 avatar Jul 28 '14 13:07 rizal72

Yes, it's Xcode: • Xcode does not support building static libraries that include Swift code. (17181019)

pNre avatar Jul 28 '14 14:07 pNre

But I've succeded in building a custom library and then exported it as a .framework bundle. Than I've included it in my project and it compiles correctly... using XCode_6 beta 4. The issue happens only with your sources: if I include them in my custom library it stops compiling. If I delete them it starts compiling again. (?!)

rizal72 avatar Jul 28 '14 14:07 rizal72

A Swift library?

pNre avatar Jul 28 '14 15:07 pNre

Yes. It's a kind of test library containing only a few classes, with some public class methods. And It works... Create a new project then, under "iOS/Frameworks & Library", chose "Cocoa Touch Framework" as a template. Then add a Swift Class with a public class method and compile the library. Import this library in another project, under "Embedded Binaries", and it works as charme. Just be careful to copy the correct version of the library (Simulator, iOS, etc..) according to the kind of compilation you need.

rizal72 avatar Jul 28 '14 15:07 rizal72

I followed your instructions and created a test framework, with a simple extension, just like this:

public extension Array {
    public func test () -> Element? {
        return nil
    }
}

this way the linker outputs symbol(s) not found.

Changing the function's return type:

public extension Array {
    public func test () -> Int? {
        return nil
    }
}

compiles fine.

Looks like a bug in the compiler when using the generic type Element or T defined in Array.

I know it's ugly but if you need to use ExSwift in your project compile the sources with the rest of the project.

pNre avatar Jul 29 '14 10:07 pNre

Yes! You found it! Probably the compiler does not include all the Types still. Thanks

rizal72 avatar Jul 29 '14 10:07 rizal72

This is Xcode bug. It's not possible to make Frameworks with extension to generic classes https://devforums.apple.com/message/983747#983747

And it doesn't work to install this project with cocoa pods as well (because of linking error). Probably the best solution would be use submodules and copy all source files to your target

kostiakoval avatar Oct 17 '14 08:10 kostiakoval

1.Add ExSwift as a submodule 2.Open the ExSwift project folder, and drag ExSwift sub folder with source code into the file navigator of your Xcode project. Make sure you select add to target 3.Use it

kostiakoval avatar Oct 17 '14 09:10 kostiakoval