How to enable "Weak References" in Xcode via post build script?

Hi,

I have a need to flip the switch on “Weak References in Manual Retain Release” in Xcode build settings. It defaults to “no” for me and I need to change it to “yes.” I do this for other settings, such as turning off bitcode, using the following pattern:

proj.AddBuildProperty(target, "ENABLE_BITCODE", "NO");

I don’t know the string for weak references though. Does anyone know, and is there any reference for this stuff somewhere? I couldn’t find it in the docs.

Thank you!

After much frustrated googling, I found a great reference doc buried on github - The Xcode Build Settings Reference in a searchable document, as of Xcode 8.3.2 · GitHub

The specific answer to the question is “CLANG_ENABLE_OBJC_WEAK” which is completely unguessable.

Hopefully this info helps someone else googling around in the future.

I have the same problem. I trying to set “SetBuildProperty” for “Weak References in Manual Retain Release” but the build settings create a new type “User-Defined”.

Code demo:

//ARC
string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
string projSetting = proj.TargetGuidByName ("Unity-iPhone");
proj.SetBuildProperty (projSetting, "ENABLE_BITCODE", "NO");
proj.SetBuildProperty (projSetting, "Weak References in Manual Retain Release", "Yes");
proj.WriteToFile (projPath);
File.WriteAllText(projPath, proj.WriteToString());

3729211--308917--upload_2018-9-28_14-46-44.png

The problem was solved, thanks Kathode

proj.SetBuildProperty (projSetting, "CLANG_ENABLE_OBJC_WEAK", "YES");