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

Eric picture Eric · Aug 28, 2009 · Viewed 12.6k times · Source

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] field from "Dynamic Library" to "Static Library", both the Clean Project and Build Project complain that the target has an invalid MACH_O_TYPE value of 'staticlib'.

Is there a straightforward way to get the build to produce a static .a file?

Thanks,
Eric

Answer

Ricky Lung picture Ricky Lung · May 14, 2010

Opens up the project.pbxproj file in YourProjectName.xcodeproj folder using TextEdit, search for productType and change it's value from "com.apple.product-dynamic" to "com.apple.product-static"