ios – How do I declare an extern variable in a Cocoapods framework?


I am making a Cocoapod framework that needs to declare an extern variable such that the integrator defines the constant value. This is a requirement by our client. In the past, we used a static library (without Cocoapods), and we could declare variables as extern, use them in the code, and send the library to the client who would define the variables in their project.

However, when we migrated to creating a Cocoapods framework, the same code no longer works. The variables are declared as extern, but if I try to build the framework, I get linker errors saying “Undefined symbols for architecture arm64”. I am also using a Cocoapods example project which has the definitions for the variables, but I can’t build and run the target because the framework still fails to compile. I can define the variables in the Cocoapod itself and the app will build and run, but this defeats the purpose (and, for the record, the values that are actually used are those that I define in the pod, not in the example app).

How can I go about doing what I had done previously with a static library, but with a Cocoapods framework?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img