Error when compiling a static library using Swift "unknown option character `X' in: -Xlinker" [duplicate] Error when compiling a static library using Swift "unknown option character `X' in: -Xlinker" [duplicate] ios ios

Error when compiling a static library using Swift "unknown option character `X' in: -Xlinker" [duplicate]


Update: It seems like the official release of Xcode 6 still has that same issue.

From the xcode 6 beta 2 release notes:

It is not possible to build static libraries which contain Swift code in this release


I have found the solution. This is hook, but it works.You should do this as root.

  1. Go to default toolchain bin directory

    cd $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin

  2. Rename current libtool to old_libtool

    mv libtool old_libtool

  3. Create new libtool

    touch libtool && chmod +x libtool

  4. Insert current script as content of new libtool

    #!/usr/bin/pythonimport osimport subprocessimport sysargs=[]for arg in sys.argv[1:]:    if arg != '-Xlinker' and arg != '-add_ast_path' and not arg.endswith('swiftmodule'):        args.append(arg)args.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), 'old_libtool'))subprocess.check_call(args)
  5. Compile.