Skip to content

Commit

Permalink
Use preprocessor macro to set distributionName for static library builds
Browse files Browse the repository at this point in the history
  • Loading branch information
frankus committed Sep 15, 2016
1 parent 2003ff0 commit 3bb29bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
19 changes: 18 additions & 1 deletion ApptentiveConnect/source/Apptentive.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down
14 changes: 1 addition & 13 deletions etc/bin/build_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 3bb29bb

Please sign in to comment.