Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 225
Eric Avatar asked Aug 28 '09 20:08

Eric


People also ask

What is difference between static and dynamic framework?

Static frameworks contain a static library packaged with its resources. Dynamic frameworks contain the dynamic library with its resources. In addition to that, dynamic frameworks may conveniently include different versions of the same dynamic library in the same framework!

Are Xcframeworks dynamic or static?

An XCFramework can be either static or dynamic and can include headers.

What is static library in xcode?

Static library - a unit of code linked at compile time, which does not change. However, iOS static libraries are not allowed to contain images/assets (only code).

What is static library and dynamic library in iOS?

statically linked modules are fastest to load (loading non-system dynamic frameworks is pretty expensive while system frameworks are optimized). When using static linking, all the symbols are within the same module, so the app start is fast. dynamically linked modules are slower to load, especially on iOS.


1 Answers

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"

like image 170
Ricky Lung Avatar answered Sep 23 '22 09:09

Ricky Lung