Skip to content

Commit

Permalink
Fixes IOS-88 Send CP suffix on client version for cocoa pod versions
Browse files Browse the repository at this point in the history
Now sends a distribution type with the client record, which for now is one of source, binary, or CocoaPods.
  • Loading branch information
wooster committed Jan 31, 2013
1 parent c0807d2 commit 6f97f15
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 12 deletions.
13 changes: 13 additions & 0 deletions ApptentiveConnect/ApptentiveConnect.xcodeproj/project.pbxproj
Expand Up @@ -97,6 +97,7 @@
49509E1C135840A000793EEC /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49B3D96A133E6D6400B5A5CD /* UIKit.framework */; };
4960E154134A578F00F6311F /* generated in Resources */ = {isa = PBXBuildFile; fileRef = 4960E153134A578F00F6311F /* generated */; };
4967278216B9D9CB00C679B8 /* ATConnect_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4967278116B9D9CB00C679B8 /* ATConnect_Private.h */; };
4967278416B9FE6400C679B8 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4967278316B9FE6400C679B8 /* Info.plist */; };
496DC3831333D35600743F65 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 496DC3821333D35600743F65 /* Foundation.framework */; };
496DC38F1333D35600743F65 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 496DC3821333D35600743F65 /* Foundation.framework */; };
496DC3941333D35600743F65 /* libApptentiveConnect.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 496DC37F1333D35600743F65 /* libApptentiveConnect.a */; };
Expand Down Expand Up @@ -251,6 +252,7 @@
49509DFA13583FB800793EEC /* ATUtilitiesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ATUtilitiesTests.m; sourceTree = "<group>"; };
4960E153134A578F00F6311F /* generated */ = {isa = PBXFileReference; lastKnownFileType = folder; name = generated; path = art/generated; sourceTree = SOURCE_ROOT; };
4967278116B9D9CB00C679B8 /* ATConnect_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATConnect_Private.h; sourceTree = "<group>"; };
4967278316B9FE6400C679B8 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = resources/ApptentiveResources/Info.plist; sourceTree = SOURCE_ROOT; };
496DC37F1333D35600743F65 /* libApptentiveConnect.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libApptentiveConnect.a; sourceTree = BUILT_PRODUCTS_DIR; };
496DC3821333D35600743F65 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
496DC38C1333D35600743F65 /* ApptentiveConnectTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ApptentiveConnectTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -492,13 +494,23 @@
name = Reachability;
sourceTree = "<group>";
};
4967278516B9FE7000C679B8 /* ApptentiveResources */ = {
isa = PBXGroup;
children = (
4967278316B9FE6400C679B8 /* Info.plist */,
);
name = ApptentiveResources;
path = xibs;
sourceTree = "<group>";
};
496DC3741333D35600743F65 = {
isa = PBXGroup;
children = (
49D1123913359BA000603373 /* ext */,
49C00295133413BB0071F088 /* source */,
4960E153134A578F00F6311F /* generated */,
49C00290133413AA0071F088 /* xibs */,
4967278516B9FE7000C679B8 /* ApptentiveResources */,
49C002861334137E0071F088 /* tests */,
496DC3811333D35600743F65 /* Frameworks */,
496DC3801333D35600743F65 /* Products */,
Expand Down Expand Up @@ -859,6 +871,7 @@
49352B3F138DB3AA000E464A /* ATTaskProgressCell.xib in Resources */,
490B816C14427A95009801E9 /* ATFeedbackController.xib in Resources */,
496F29E014496711005B7C01 /* ATSimpleImageViewController.xib in Resources */,
4967278416B9FE6400C679B8 /* Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
8 changes: 8 additions & 0 deletions ApptentiveConnect/resources/ApptentiveResources/Info.plist
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ATInfoDistributionKey</key>
<string>source</string>
</dict>
</plist>
2 changes: 2 additions & 0 deletions ApptentiveConnect/source/Persistence/ATBackend.h
Expand Up @@ -53,4 +53,6 @@ NSString *const ATBackendNewAPIKeyNotification;

- (NSURL *)apptentiveHomepageURL;
- (NSURL *)apptentivePrivacyPolicyURL;

- (NSString *)distributionName;
@end
10 changes: 10 additions & 0 deletions ApptentiveConnect/source/Persistence/ATBackend.m
Expand Up @@ -21,6 +21,7 @@

NSString *const ATBackendNewAPIKeyNotification = @"ATBackendNewAPIKeyNotification";
NSString *const ATUUIDPreferenceKey = @"ATUUIDPreferenceKey";
NSString *const ATInfoDistributionKey = @"ATInfoDistributionKey";

static ATBackend *sharedBackend = nil;

Expand Down Expand Up @@ -278,6 +279,15 @@ - (NSURL *)apptentiveHomepageURL {
- (NSURL *)apptentivePrivacyPolicyURL {
return [NSURL URLWithString:@"http://www.apptentive.com/privacy"];
}

- (NSString *)distributionName {
static NSString *cachedDistributionName = nil;
static dispatch_once_t onceToken = 0;
dispatch_once(&onceToken, ^{
cachedDistributionName = [(NSString *)[[ATConnect resourceBundle] objectForInfoDictionaryKey:ATInfoDistributionKey] retain];
});
return cachedDistributionName;
}
@end

@implementation ATBackend (Private)
Expand Down
8 changes: 8 additions & 0 deletions ApptentiveConnect/source/Persistence/ATRecord.m
Expand Up @@ -111,6 +111,10 @@ - (NSDictionary *)apiJSON {
[client setObject:kATConnectVersionString forKey:@"version"];
[client setObject:kATConnectPlatformString forKey:@"os"];
[client setObject:@"Apptentive, Inc." forKey:@"author"];
NSString *distribution = [[ATBackend sharedBackend] distributionName];
if (distribution) {
[client setObject:distribution forKey:@"distribution"];
}
[record setObject:client forKey:@"client"];
[d setObject:record forKey:@"record"];

Expand Down Expand Up @@ -140,6 +144,10 @@ - (NSDictionary *)apiDictionary {
[d setObject:kATConnectVersionString forKey:@"record[client][version]"];
[d setObject:kATConnectPlatformString forKey:@"record[client][os]"];
[d setObject:@"Apptentive, Inc." forKey:@"record[client][author]"];
NSString *distribution = [[ATBackend sharedBackend] distributionName];
if (distribution) {
[d setObject:distribution forKey:@"record[client][distribution]"];
}

// Add some app information.
[d setObject:[ATUtilities appVersionString] forKey:@"record[app_version][version]"];
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@ In progress wooster v0.4.8
* Fixes IOS-96 Text cut off in screenshot view in landscape
* Fixes IOS-94 Right side of feedback UI doesn't work on iPhone app running on iPad (in landscape)
* Fixes IOS-97 Sending file attachments is writing files to disk a lot
* Fixes IOS-88 Send CP suffix on client version for cocoa pod versions

2012-09-27 wooster v0.4.7
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion FeedbackDemo/FeedbackDemo/FeedbackDemo-Info.plist
Expand Up @@ -23,7 +23,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>15</string>
<string>16</string>
<key>LSRequiresIPhoneOS</key>
<false/>
<key>NSMainNibFile</key>
Expand Down
59 changes: 48 additions & 11 deletions etc/bin/build_distribution.py
@@ -1,7 +1,9 @@
#!/usr/bin/env python
from contextlib import contextmanager
import os
import biplist
import re
import shutil
import subprocess
import sys

Expand Down Expand Up @@ -44,9 +46,18 @@ def run_command(command, verbose=False):
return (p.returncode, output)

class Builder(object):
COCOAPODS_DIST = "COCOAPODS_DIST"
BINARY_DIST = "BINARY_DIST"
build_root = "/tmp/apptentive_connect_build"
def __init__(self, verbose=False):
dist_type = None
def __init__(self, verbose=False, dist_type=None):
if not dist_type:
dist_type = self.BINARY_DIST
self.verbose = verbose
self.dist_type = dist_type
if dist_type not in [self.COCOAPODS_DIST, self.BINARY_DIST]:
log("Unknown dist_type: %s" % dist_type)
sys.exit(1)

def build(self):
# First, build the simulator target.
Expand All @@ -65,10 +76,12 @@ def build(self):
return False
library_dir = self._output_dir()
try:
os.rmtree(library_dir)
if os.path.exists(library_dir):
shutil.rmtree(library_dir)
os.makedirs(library_dir)
os.makedirs(os.path.join(library_dir, 'include'))
except:
except Exception as e:
log("Exception %s" % e)
pass
if not os.path.exists(library_dir):
log("Unable to create output directory at: %s" % library_dir)
Expand All @@ -87,6 +100,26 @@ def build(self):
log("Unable to ditto project path: %s" % full_project_path)
log(output)
return False
# Copy the ApptentiveResources.bundle.
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.COCOAPODS_DIST:
plist[plist_key] = "CocoaPods"
elif 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
header_contents = open(os.path.join(self._project_dir(), "source", "ATConnect.h")).read()
Expand All @@ -96,7 +129,10 @@ def build(self):
with chdir(self._output_dir()):
filename = 'apptentive_ios_sdk.tar.gz'
if version:
filename = 'apptentive_ios_sdk-%s.tar.gz' % version
if self.dist_type == self.BINARY_DIST:
filename = 'apptentive_ios_sdk-%s.tar.gz' % version
elif self.dist_type == self.COCOAPODS_DIST:
filename = 'apptentive_ios_sdk-cocoapods-%s.tar.gz' % version
tar_command = "tar -zcvf ../%s ." % filename
(status, output) = run_command(tar_command, verbose=self.verbose)
if status != 0:
Expand Down Expand Up @@ -147,10 +183,11 @@ def _ditto_file(self, path_from, path_to):
return run_command(command, verbose=self.verbose)

if __name__ == "__main__":
builder = Builder()
result = builder.build()
if result == True:
log("Build suceeded")
else:
log("Build failed!")

for dist_type in [Builder.BINARY_DIST, Builder.COCOAPODS_DIST]:
builder = Builder(dist_type=dist_type)
result = builder.build()
if result == True:
log("Build suceeded")
else:
log("Build failed!")
break

0 comments on commit 6f97f15

Please sign in to comment.