Skip to content

Commit

Permalink
Update Firebase iOS quickstarts to Swift 3
Browse files Browse the repository at this point in the history
Change-Id: Ibc332ad4ce1bad8cc9b1b1602aa395c62304e18e
  • Loading branch information
ulukaya committed Oct 7, 2016
1 parent 3b8500d commit 814d439
Show file tree
Hide file tree
Showing 21 changed files with 176 additions and 164 deletions.
38 changes: 19 additions & 19 deletions analytics/AnalyticsExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
10CB980A1D9975E0008BB445 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 10CB98091D9975E0008BB445 /* GoogleService-Info.plist */; };
10CB980B1D9975E0008BB445 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 10CB98091D9975E0008BB445 /* GoogleService-Info.plist */; };
5F3B16801AFC453200860007 /* CircleImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F3B167F1AFC453200860007 /* CircleImageView.m */; };
5F3B16811AFC453200860007 /* CircleImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F3B167F1AFC453200860007 /* CircleImageView.m */; };
5F5A53521ADE670C00F81DF0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F5A53511ADE670C00F81DF0 /* main.m */; };
Expand Down Expand Up @@ -41,6 +43,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
10CB98091D9975E0008BB445 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; 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 Down Expand Up @@ -135,6 +138,7 @@
5F5A534F1ADE670C00F81DF0 /* Supporting Files */ = {
isa = PBXGroup;
children = (
10CB98091D9975E0008BB445 /* GoogleService-Info.plist */,
5F3B167E1AFC453200860007 /* CircleImageView.h */,
5F3B167F1AFC453200860007 /* CircleImageView.m */,
5F5A53511ADE670C00F81DF0 /* main.m */,
Expand Down Expand Up @@ -290,6 +294,7 @@
files = (
5F99610C1AE0CF4F0034F503 /* LaunchScreen.xib in Resources */,
5F99610A1AE0CF4F0034F503 /* Images.xcassets in Resources */,
10CB980A1D9975E0008BB445 /* GoogleService-Info.plist in Resources */,
EF01600C1BD07C1F00F8DA01 /* AnalyticsImages.xcassets in Resources */,
5F5A535B1ADE670C00F81DF0 /* Main.storyboard in Resources */,
);
Expand All @@ -301,6 +306,7 @@
files = (
5F99610D1AE0CF4F0034F503 /* LaunchScreen.xib in Resources */,
EF01600D1BD07C1F00F8DA01 /* AnalyticsImages.xcassets in Resources */,
10CB980B1D9975E0008BB445 /* GoogleService-Info.plist in Resources */,
5F5A539C1ADE69AA00F81DF0 /* Main.storyboard in Resources */,
5F99610B1AE0CF4F0034F503 /* Images.xcassets in Resources */,
);
Expand Down Expand Up @@ -372,6 +378,17 @@
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
1073F3B81DA830C500C3EDCB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
PRODUCT_NAME = AnalyticsExampleSwift;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
5F5A536D1ADE670C00F81DF0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -464,7 +481,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.analytics;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -479,25 +495,9 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.analytics;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
5F5A53951ADE67D500F81DF0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "$(SRCROOT)/AnalyticsExample/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.analytics;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 2.3;
};
name = Debug;
};
5F5A53961ADE67D500F81DF0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand All @@ -510,7 +510,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down Expand Up @@ -601,8 +601,8 @@
5F5A53991ADE67D500F81DF0 /* Build configuration list for PBXNativeTarget "AnalyticsExampleSwift" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5F5A53951ADE67D500F81DF0 /* Debug */,
5F5A53961ADE67D500F81DF0 /* Release */,
1073F3B81DA830C500C3EDCB /* Debug */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
Expand Down
4 changes: 2 additions & 2 deletions analytics/AnalyticsExampleSwift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ 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]
FIRApp.configure()
// [END tracker_swift]

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

return true
}
Expand Down
14 changes: 7 additions & 7 deletions analytics/AnalyticsExampleSwift/FoodPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ class FoodPickerViewController: UIViewController, UIPickerViewDelegate, UIPicker

let foodStuffs = ["Hot Dogs", "Hamburger", "Pizza"]

func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
let food = foodStuffs[row]
NSUserDefaults.standardUserDefaults().setValue(food, forKey: "favorite_food")
NSUserDefaults.standardUserDefaults().synchronize()
UserDefaults.standard.setValue(food, forKey: "favorite_food")
UserDefaults.standard.synchronize()

// [START user_property]
FIRAnalytics.setUserPropertyString(food, forName: "favorite_food")
// [END user_property]

performSegueWithIdentifier("unwindToHome", sender: self)
performSegue(withIdentifier: "unwindToHome", sender: self)
}

func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return foodStuffs.count
}

func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}

func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return foodStuffs[row];
}

Expand Down
18 changes: 9 additions & 9 deletions analytics/AnalyticsExampleSwift/PatternTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ import FirebaseAnalytics
@objc(PatternTabBarController) // match the ObjC symbol name inside Storyboard
class PatternTabBarController: UITabBarController {

override func viewDidAppear(animated: Bool) {
override func viewDidAppear(_ animated: Bool) {
if (getUserFavoriteFood() == nil) {
askForFavoriteFood()
}
}

@IBAction func didTapShare(sender: AnyObject) {
@IBAction func didTapShare(_ sender: AnyObject) {
// [START custom_event_swift]
FIRAnalytics.logEventWithName(kFIREventSelectContent, parameters: [
kFIRParameterContentType:"cont",
kFIRParameterItemID:"1"
FIRAnalytics.logEvent(withName: kFIREventSelectContent, parameters: [
kFIRParameterContentType:"cont" as NSObject,
kFIRParameterItemID:"1" as NSObject
])
// [END custom_event_swift]

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

@IBAction func unwindToHome (segue: UIStoryboardSegue?) {
@IBAction func unwindToHome (_ segue: UIStoryboardSegue?) {

}

func getUserFavoriteFood() -> String? {
return NSUserDefaults.standardUserDefaults().valueForKey("favorite_food") as! String?
return UserDefaults.standard.value(forKey: "favorite_food") as! String?
}

func askForFavoriteFood() {
performSegueWithIdentifier("pickFavoriteFood", sender: self)
performSegue(withIdentifier: "pickFavoriteFood", sender: self)
}

}
}
8 changes: 4 additions & 4 deletions analytics/AnalyticsExampleSwift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import FirebaseAnalytics
@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~\(title!)",
text = "I'd love you to hear about\(name)"

// [START custom_event_swift]
FIRAnalytics.logEventWithName("share_image", parameters: [
"name": name,
"full_text": text
FIRAnalytics.logEvent(withName: "share_image", parameters: [
"name": name as NSObject,
"full_text": text as NSObject
])
// [END custom_event_swift]
}
Expand Down
4 changes: 2 additions & 2 deletions crash/CrashReporter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.CrashReporter;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -469,7 +469,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.CrashReporter;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion crash/CrashReporterSwift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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 {
// Initialize Firebase service.
FIRApp.configure()
return true
Expand Down
2 changes: 1 addition & 1 deletion crash/CrashReporterSwift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ViewController: UIViewController {
FIRCrashMessage("View loaded")
}

@IBAction func initiateCrash(sender: AnyObject) {
@IBAction func initiateCrash(_ sender: AnyObject) {
// [START log_and_crash_swift]
FIRCrashMessage("Cause Crash button clicked")
fatalError()
Expand Down
17 changes: 12 additions & 5 deletions dynamiclinks/DynamicLinksExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,16 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Google Inc.";
TargetAttributes = {
5F5A534B1ADE670C00F81DF0 = {
CreatedOnToolsVersion = 6.3;
DevelopmentTeam = EQHXZ8M8AV;
};
5F5A53781ADE67D500F81DF0 = {
CreatedOnToolsVersion = 6.3;
DevelopmentTeam = EQHXZ8M8AV;
LastSwiftMigration = 0800;
};
5FDE05571B0DAA090037B82F = {
Expand Down Expand Up @@ -327,8 +329,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 @@ -351,7 +355,7 @@
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;
Expand All @@ -372,8 +376,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 @@ -389,9 +395,10 @@
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";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand Down Expand Up @@ -443,7 +450,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.google.sample.firebase.dynamiclinks;
PRODUCT_NAME = DynamicLinksExample;
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -459,7 +466,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.google.sample.firebase.dynamiclinks;
PRODUCT_NAME = DynamicLinksExample;
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Loading

0 comments on commit 814d439

Please sign in to comment.