4

I'm trying to exclude the IDFA from my final binary using Countly so I can answer no to the Export Compliance question "Does your app use the IDFA?".

Adding COUNTLY_EXCLUDE_IDFA=1 to Build Settings > Preprocessor Macros as mentioned here doesn't work.

I've narrowed it down to #ifndef not behaving as expected. This is what I've tried:

With COUNTLY_EXCLUDE_IDFA=1 added in Build Settings > Preprocessor Macros:

#ifndef COUNTLY_EXCLUDE_IDFA
    printf("!EXCLUDED\n");
#else
    printf("EXCLUDED\n");
#endif

>> prints !EXCLUDED

With COUNTLY_EXCLUDE_IDFA not defined in Build Settings > Preprocessor Macros:

#ifndef COUNTLY_EXCLUDE_IDFA
    printf("!EXCLUDED\n");
#else
    printf("EXCLUDED\n");
#endif

>> prints !EXCLUDED

I expect #ifndef to include a block if the Macro is not defined. Now the #ifndef block is included wether or not I have the Macro defined in Build Settings > Preprocessor Macros.

erkanyildiz
  • 13,044
  • 6
  • 50
  • 73
Elusyve
  • 41
  • 2
  • 1
    When you set this macro in your `Preprocessor Macros`, I presume you're setting it under release builds only, right? In that case, are these tests you show coming from a release build, or a debug build? – Alexander May 22 '19 at 07:01
  • I've set the ```Preprocessor Macros``` for all build configurations, so that the IDFA is never included. I've tested this in a debug build. When I upload a release binary to AppStoreConnect I get a warning that the IDFA is included in the binary as well. – Elusyve May 22 '19 at 07:29

2 Answers2

1

Please make sure you set COUNTLY_EXCLUDE_IDFA for the correct target and build configuration.

If you are adding Countly iOS SDK source files directly to your project, make sure the flag is added to your app target.

If you are adding it as a framework, make sure the flag is added to framework target.

erkanyildiz
  • 13,044
  • 6
  • 50
  • 73
0

I have this in Podfile, and it works fine.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "Countly"
      target.build_configurations.each do |config|
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'COUNTLY_EXCLUDE_IDFA=1']
      end
    end
  end
end
ChikabuZ
  • 10,031
  • 5
  • 63
  • 86