简体   繁体   中英

Creating a static library using Swift with external cocoa pods dependencies

I'm having trouble creating a swift static library which uses external cocoa pods libraries (SSZipArchive).

I'm getting the following error:

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `X' in: -Xlinker
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]​

I have no clue why is this happening.

You cannot create static Swift libraries.

It was a 'bug' but then the Apple engineers decided to state this is intended behaviour. I needed to make static libraries myself and I am currently SOL on it.

Xcode does not support building static libraries that include Swift code.

@Aggressor is correct about the current state of affairs, but even if (when) Swift does allow the creation of static libraries, you must not do this. Third-party libraries must never be incorporated into a static library. This leads to all kinds of build conflicts later if the consumer also includes those libraries (or if another static library does). For more information (and links to even more information), see this ObjC version of the question . If Swift ever supports this, it will be the same issue. The final executable should link together all your libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM