How do I change an existing Xcode target from dynamic to static?

后端 未结 4 1130
予麋鹿
予麋鹿 2021-02-07 10:28

I\'m working with an existing project that produces a dynamic library (Cocoa API).

I\'d rather generate a static library, but if I change the [Linking|Mach-O Type] fiel

4条回答
  •  无人共我
    2021-02-07 11:07

    I managed to do this, with the help of this post and a bit of digging around. Additional changes I had to make were changing compiled.mach-o.dylib to archive.ar and changing various references in the project file (including inside comments, call me pedantic) from foo.dylib to libfoo.a.

    I also had to create a new 'scheme' before it would build, but that might be because I changed the name of the project, I'm not sure. Also, any frameworks referenced by the library need to be added to the application(s) that link against it when you move from .dylib to .a.

    It was well worth persevering though as it preserved all the subtleties of the original project (such as building a 32/64 fat binary for release but not for debugging). Result.

提交回复
热议问题