Skip to content

Commit

Permalink
update googlesamples ios
Browse files Browse the repository at this point in the history
Change-Id: I5beec8210e1a6edda00af1f103fc12cc5f9c7fdc
  • Loading branch information
ulukaya committed Dec 14, 2016
1 parent b44cf7f commit 6465129
Show file tree
Hide file tree
Showing 23 changed files with 1,291 additions and 2,562 deletions.
32 changes: 27 additions & 5 deletions ios/analytics/AnalyticsExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
10B02EF01E01C7BA00BCE191 /* BridgingHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = "<group>"; };
5F3B167E1AFC453200860007 /* CircleImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircleImageView.h; sourceTree = "<group>"; };
5F3B167F1AFC453200860007 /* CircleImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CircleImageView.m; sourceTree = "<group>"; };
5F5A534C1ADE670C00F81DF0 /* AnalyticsExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AnalyticsExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -52,7 +53,6 @@
5F5A53791ADE67D500F81DF0 /* AnalyticsExampleSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AnalyticsExampleSwift.app; sourceTree = BUILT_PRODUCTS_DIR; };
5F5A537D1ADE67D500F81DF0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
5F5A537F1ADE67D500F81DF0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
5F5A539B1ADE695B00F81DF0 /* BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = "<group>"; };
5F9961061AE0CF4F0034F503 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
5F9961071AE0CF4F0034F503 /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = "<group>"; };
5FC04A7D1AF1DCAA00F787CA /* PatternTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PatternTabBarController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -152,7 +152,7 @@
5F5A537B1ADE67D500F81DF0 /* Supporting Files */ = {
isa = PBXGroup;
children = (
5F5A539B1ADE695B00F81DF0 /* BridgingHeader.h */,
10B02EF01E01C7BA00BCE191 /* BridgingHeader.h */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -247,17 +247,22 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0810;
ORGANIZATIONNAME = "Google Inc.";
TargetAttributes = {
5F5A534B1ADE670C00F81DF0 = {
CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0820;
ProvisioningStyle = Manual;
};
5F5A53781ADE67D500F81DF0 = {
CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0820;
ProvisioningStyle = Manual;
};
5FC7AD811B0D4106004E3100 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 0820;
TestTargetID = 5F5A534B1ADE670C00F81DF0;
};
};
Expand Down Expand Up @@ -382,8 +387,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -405,10 +412,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -426,8 +434,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -442,9 +452,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -455,10 +467,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = AnalyticsExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.google.samples.quickstart.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -467,10 +481,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = AnalyticsExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.google.samples.quickstart.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -479,12 +495,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/AnalyticsExample/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.google.samples.quickstart.AnalyticsExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = AnalyticsExampleSwift/BridgingHeader.h;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -493,11 +511,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/AnalyticsExample/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.google.samples.quickstart.AnalyticsExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = AnalyticsExampleSwift/BridgingHeader.h;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down Expand Up @@ -530,6 +550,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.google.samples.quickstart.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AnalyticsExample.app/AnalyticsExample";
};
name = Debug;
Expand Down Expand Up @@ -560,6 +581,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.google.samples.quickstart.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AnalyticsExample.app/AnalyticsExample";
};
name = Release;
Expand Down
8 changes: 4 additions & 4 deletions ios/analytics/AnalyticsExample/CircleImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder {
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super initWithCoder:aDecoder])) {
[self sharedInit];
}
Expand All @@ -34,12 +34,12 @@ - (id)initWithCoder:(NSCoder *)aDecoder {

- (void)sharedInit {
self.backgroundColor = [UIColor whiteColor];
[super setContentMode:UIViewContentModeCenter];
super.contentMode = UIViewContentModeCenter;

CALayer *layer = [super layer];
CALayer *layer = super.layer;
layer.shadowOffset = CGSizeMake(0, 2);
layer.shadowOpacity = 0.25;
layer.shadowColor = [[UIColor grayColor] CGColor];
layer.shadowColor = [UIColor grayColor].CGColor;
layer.shadowRadius = 4.0;
layer.shadowOffset = CGSizeMake(0, 2);
}
Expand Down
2 changes: 1 addition & 1 deletion ios/analytics/AnalyticsExample/PatternTabBarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @implementation PatternTabBarController

- (void)didTapShare:(id)sender {
// [START custom_event_objc]
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
id<GAITracker> tracker = [GAI sharedInstance].defaultTracker;
NSMutableDictionary *event =
[[GAIDictionaryBuilder createEventWithCategory:@"Action"
action:@"Share"
Expand Down
2 changes: 1 addition & 1 deletion ios/analytics/AnalyticsExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (void)viewWillAppear:(BOOL)animated {
// If you're copying this to an app just using Analytics, you'll
// need to configure your tracking ID here.
// [START screen_view_hit_objc]
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
id<GAITracker> tracker = [GAI sharedInstance].defaultTracker;
[tracker set:kGAIScreenName value:name];
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
// [END screen_view_hit_objc]
Expand Down
13 changes: 7 additions & 6 deletions ios/analytics/AnalyticsExampleSwift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

// [START tracker_swift]
// Configure tracker from GoogleService-Info.plist.
var configureError:NSError?
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")

// Optional: configure GAI options.
let gai = GAI.sharedInstance()
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.trackUncaughtExceptions = true // report uncaught exceptions
gai.logger.logLevel = GAILogLevel.Verbose // remove before app release
gai.logger.logLevel = GAILogLevel.verbose // remove before app release
// [END tracker_swift]

// Set a white background so that patterns are showcased.
window?.backgroundColor = UIColor.whiteColor()
window?.backgroundColor = UIColor.white

return true
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import Foundation
@objc(PatternTabBarController) // match the ObjC symbol name inside Storyboard
class PatternTabBarController: UITabBarController {

@IBAction func didTapShare(sender: AnyObject) {
@IBAction func didTapShare(_ sender: AnyObject) {
// [START custom_event_swift]
let tracker = GAI.sharedInstance().defaultTracker
let event = GAIDictionaryBuilder.createEventWithCategory("Action", action: "Share", label: nil, value: nil)
guard let tracker = GAI.sharedInstance().defaultTracker else { return }
guard let event = GAIDictionaryBuilder.createEvent(withCategory: "Action", action: "Share", label: nil, value: nil) else { return }
tracker.send(event.build() as [NSObject : AnyObject])
// [END custom_event_swift]

Expand All @@ -37,4 +37,4 @@ class PatternTabBarController: UITabBarController {
alert.show()
}

}
}
6 changes: 3 additions & 3 deletions ios/analytics/AnalyticsExampleSwift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import UIKit
@objc(ViewController) // match the ObjC symbol name inside Storyboard
class ViewController: UIViewController {

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)

let name = "Pattern~\(self.title!)"
Expand All @@ -29,10 +29,10 @@ class ViewController: UIViewController {
// If you're copying this to an app just using Analytics, you'll
// need to configure your tracking ID here.
// [START screen_view_hit_swift]
let tracker = GAI.sharedInstance().defaultTracker
guard let tracker = GAI.sharedInstance().defaultTracker else { return }
tracker.set(kGAIScreenName, value: name)

let builder = GAIDictionaryBuilder.createScreenView()
guard let builder = GAIDictionaryBuilder.createScreenView() else { return }
tracker.send(builder.build() as [NSObject : AnyObject])
// [END screen_view_hit_swift]
}
Expand Down
2 changes: 1 addition & 1 deletion ios/analytics/AnalyticsExampleTests/LogWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Returns any lines (as NSString instances) written since LogWrapper was created, or the last
* call to this method. This may return a nil/empty array if nothing was written.
*/
- (NSArray *)lines;
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *lines;

@end

2 changes: 1 addition & 1 deletion ios/analytics/AnalyticsExampleTests/LogWrapper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ - (NSArray *)lines {
return nil;
}

NSString *allData = [NSString stringWithUTF8String:(const char *)[data bytes]];
NSString *allData = @((const char *)data.bytes);
return [allData componentsSeparatedByString:@"\n"];
}

Expand Down
2 changes: 2 additions & 0 deletions ios/analytics/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# AnalyticsExample

use_frameworks!
platform :ios, '7.0'
pod 'Google/Analytics'

Expand Down
Loading

0 comments on commit 6465129

Please sign in to comment.