From 3bb29bb591a34cdec67dc23263475f84889ad567 Mon Sep 17 00:00:00 2001 From: Frank Schmitt Date: Thu, 15 Sep 2016 16:14:23 -0700 Subject: [PATCH] Use preprocessor macro to set distributionName for static library builds --- ApptentiveConnect/source/Apptentive.m | 19 ++++++++++++++++++- etc/bin/build_distribution.py | 14 +------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ApptentiveConnect/source/Apptentive.m b/ApptentiveConnect/source/Apptentive.m index bca8f3c17..80fed79ca 100644 --- a/ApptentiveConnect/source/Apptentive.m +++ b/ApptentiveConnect/source/Apptentive.m @@ -110,6 +110,10 @@ - (void)setAPIKey:(NSString *)APIKey { NSString *distributionName = @"source"; NSString *distributionVersion = kApptentiveVersionString; +#if APPTENTIVE_BINARY + distributionName = @"binary"; +#endif + #if APPTENTIVE_COCOAPODS distributionName = @"CocoaPods-Source"; #endif @@ -583,7 +587,20 @@ + (UIStoryboard *)storyboard { #pragma mark - Debugging and diagnostics - (void)setAPIKey:(NSString *)APIKey baseURL:(NSURL *)baseURL { - if (![APIKey isEqualToString:self.webClient.APIKey] || ![baseURL isEqual:self.webClient.baseURL]) { + NSString *distributionName = @"source"; + NSString *distributionVersion = kApptentiveVersionString; + +#if APPTENTIVE_BINARY + distributionName = @"binary"; +#endif + +#if APPTENTIVE_COCOAPODS + distributionName = @"CocoaPods-Source"; +#endif + + _distributionName = distributionName; + _distributionVersion = distributionVersion; +if (![APIKey isEqualToString:self.webClient.APIKey] || ![baseURL isEqual:self.webClient.baseURL]) { _webClient = [[ApptentiveWebClient alloc] initWithBaseURL:baseURL APIKey:APIKey]; _backend = [[ApptentiveBackend alloc] init]; diff --git a/etc/bin/build_distribution.py b/etc/bin/build_distribution.py index 504584e47..16cd9c23d 100755 --- a/etc/bin/build_distribution.py +++ b/etc/bin/build_distribution.py @@ -110,19 +110,6 @@ def build(self): bundle_source = os.path.join(self._products_dir(), "ApptentiveResources.bundle") bundle_dest = os.path.join(self._output_dir(), "ApptentiveResources.bundle") (status, output) = self._ditto_file(bundle_source, bundle_dest) - # Update the Info.plist in the ApptentiveResources.bundle. - bundle_plist_path = os.path.join(bundle_dest, "Info.plist") - if not os.path.exists(bundle_plist_path): - log("Unable to find bundle Info.plist at %s" % bundle_plist_path) - return False - plist = biplist.readPlist(bundle_plist_path) - plist_key = "ATInfoDistributionKey" - if self.dist_type == self.BINARY_DIST: - plist[plist_key] = "binary" - else: - log("Unknown dist_type") - return False - biplist.writePlist(plist, bundle_plist_path) # Try to get the version. version = None @@ -165,6 +152,7 @@ def _xcode_options(self, is_simulator=False, is_64bit=False): options = "CONFIGURATION_BUILD_DIR=%s SYMROOT=%s TARGET_TEMP_DIR=%s" % (escape_arg(products_dir), escape_arg(symroot), escape_arg(temp_dir)) if self.enable_bitcode: options += " ENABLE_BITCODE=YES OTHER_CFLAGS='-fembed-bitcode'" + options += " GCC_PREPROCESSOR_DEFINITIONS='APPTENTIVE_BINARY=1'" return options def _lipo_command(self):