title: How to disable Facebook codeless events programmatically?
body: <h1>Problem</h1>
  
  <p>We've had a live app for months that worked fine, and then suddenly this code broke:</p>
  
  <p><strong>ViewController.swift</strong></p>
  
  <pre><code>self.tableView.delegate = self.viewModel.tableViewHandler
  </code></pre>
  
  <p>which used this code</p>
  
  <h3>Broken code</h3>
  
  <p><strong>component.swift</strong></p>
  
  <pre><code>public override weak var delegate: UITableViewDelegate? {
       get { return super.delegate }
       set {
           if let del = newValue as? TableViewDelegateProxy {
               super.delegate = del
           } else if let del = super.delegate as? TableViewDelegateProxy {
               del.targetDelegate = newValue
           } else {
               super.delegate = newValue
           }
       }
   }
  </code></pre>
  
  <p>We couldn't figure out why, but we fixed it with this code:</p>
  
  <h3>Fixed code</h3>
  
  <p><strong>ViewController.swift</strong></p>
  
  <pre><code>self.tableView.fixedDelegate = self.viewModel.tableViewHandler
  </code></pre>
  
  <p><strong>component.swift</strong></p>
  
  <pre><code>// IMPORTANT NOTE: That is the correct way to set a delegate,
  //                 otherwise overriding `delegate` property fails
  public var fixedDelegate: UITableViewDelegate? {
      get { return self.delegate }
      set {
          self.delegateProxy.targetDelegate = newValue
          self.delegate = self.delegateProxy
      }
  }
  </code></pre>
  
  <p>Initially we thought it was a problem from the backend (malformed JSON or something like that), but then we realized the following: </p>
  
  <ul>
  <li><em>broken code</em> works when compiled using <strong>debug configuration</strong>, but breaks when using <strong>release configuration</strong></li>
  <li><em>fixed code</em> works when compiled using <strong>debug configuration</strong> and also works when using <strong>release configuration</strong></li>
  </ul>
  
  <p>We jumped back many releases in our Git history, and the same was always true, which is making us believe that there may have been some change to our Xcode or Objc/Swift runtime libraries which is causing this weirdness.</p>
  
  <h1>Question</h1>
  
  <p>What can be changing in our Xcode IDE to explain this? Can it be something that is changing remotely or behind the scenes? How can we further debug this?</p>
  
  <h1>References</h1>
  
  <p>1) Xcode version: Version 10.1 (10B61)<br>
  2) Swift version:</p>
  
  <pre><code>xcrun swift -version
  Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
  Target: x86_64-apple-darwin18.2.0
  </code></pre>
  
  <p>3) obj-c libraries:</p>
  
  <pre><code> otool -L /usr/lib/libobjc.A.dylib
  /usr/lib/libobjc.A.dylib:
          /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
          /usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 400.17.0)
          /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
          /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
  </code></pre>
  
  <hr>
  
  <h1>Update</h1>
  
  <p>First see this <a href="https://stackoverflow.com/a/55402902/766570">answer</a>, we need to turn off <a href="https://github.com/facebook/facebook-objc-sdk/blob/master/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m#L965" rel="nofollow noreferrer">this</a> flag programmatically</p>
  
  <pre><code>_serverConfiguration.isCodelessEventsEnabled
  </code></pre>
  
  <p>not sure how from the sdk (Android or iOS)</p>
  
  <h2>What we have tried</h2>
  
  <p>1) we couldn't find any way of doing this through the FB SDKs, such as this one: <a href="https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/facebooksdk.html/" rel="nofollow noreferrer">https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/facebooksdk.html/</a></p>
  
  <p>2) we tried to reverse engineer contacting the FB APIs via curl, it worked for scenarios like email:</p>
  
  <pre><code>curl --header "Content-Type: application/json" \
    --request POST \
    --data '{"app_events_feature_bitmask":0}' \
    "https://graph.facebook.com/***?access_token=&lt;app_secret&gt;"
  </code></pre>
  
  <p>which returned this</p>
  
  <pre><code>{"success":true}
  </code></pre>
  
  <p>but for app events feature nothing changed:</p>
  
  <pre><code>curl -i -X GET "https://graph.facebook.com/***?fields=app_events_feature_bitmask&amp;access_token=&lt;app_secret&gt;"
  </code></pre>
  
  <p>it returns the old value:</p>
  
  <pre><code>{"app_events_feature_bitmask":37,"id":"***"}
  </code></pre>
  
  <p>3) <a href="https://developers.facebook.com/support/bugs/579114332584238" rel="nofollow noreferrer">ask FB tech support</a></p>