From ab0edf4da978cfe110c84bf247f596a89167170d Mon Sep 17 00:00:00 2001 From: Andrew Tian Date: Mon, 30 Sep 2019 11:22:39 -0700 Subject: [PATCH] demoapp/swift_initial_implementation (#4) * Project setup * WIP * Add SdkKey in info.plist * Update ALAppDelegate.swift * Fix black screen * More fixes * Storyboard * Update Main.storyboard * Parallel objc demo app changes * Remove test ad unit id * Remove sdk key * Delete IDEWorkspaceChecks.plist * Delete IDEWorkspaceChecks.plist * Pod deintegrate pbxproj file * Update .gitignore * Force unwrap SDK in AppDelegate * Inline initialization of ad objects, remove if let checks --- .gitignore | 2 +- .../DemoApp-ObjC/ALHomeViewController.h | 2 +- .../Ads/ALAutoLayoutBannerAdViewController.m | 7 +- .../Base.lproj/Main.storyboard | 30 +- .../DemoApp-ObjC/Supporting Files/Info.plist | 4 +- .../DemoApp-Swift.xcodeproj/project.pbxproj | 401 ++++++++++++++++++ .../DemoApp-Swift/ALAppDelegate.swift | 28 ++ .../DemoApp-Swift/ALHomeViewController.swift | 18 + .../ALAutoLayoutBannerAdViewController.swift | 66 +++ .../ALFrameLayoutBannerAdViewController.swift | 60 +++ ...terfaceBuilderBannerAdViewController.swift | 50 +++ .../Ads/ALInterstitialAdViewController.swift | 69 +++ .../Ads/ALRewardedAdViewController.swift | 76 ++++ .../AppIcon.appiconset/Contents.json | 98 +++++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../Base.lproj/Main.storyboard | 274 ++++++++++++ .../DemoApp-Swift/Supporting Files/Info.plist | 47 ++ .../DemoApp-Swift/Supporting Files/main.swift | 12 + DemoApp-Swift/Podfile | 6 + 20 files changed, 1258 insertions(+), 23 deletions(-) create mode 100644 DemoApp-Swift/DemoApp-Swift.xcodeproj/project.pbxproj create mode 100644 DemoApp-Swift/DemoApp-Swift/ALAppDelegate.swift create mode 100644 DemoApp-Swift/DemoApp-Swift/ALHomeViewController.swift create mode 100644 DemoApp-Swift/DemoApp-Swift/Ads/ALAutoLayoutBannerAdViewController.swift create mode 100644 DemoApp-Swift/DemoApp-Swift/Ads/ALFrameLayoutBannerAdViewController.swift create mode 100644 DemoApp-Swift/DemoApp-Swift/Ads/ALInterfaceBuilderBannerAdViewController.swift create mode 100644 DemoApp-Swift/DemoApp-Swift/Ads/ALInterstitialAdViewController.swift create mode 100644 DemoApp-Swift/DemoApp-Swift/Ads/ALRewardedAdViewController.swift create mode 100644 DemoApp-Swift/DemoApp-Swift/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 DemoApp-Swift/DemoApp-Swift/Supporting Files/Assets.xcassets/Contents.json create mode 100644 DemoApp-Swift/DemoApp-Swift/Supporting Files/Base.lproj/LaunchScreen.storyboard create mode 100644 DemoApp-Swift/DemoApp-Swift/Supporting Files/Base.lproj/Main.storyboard create mode 100644 DemoApp-Swift/DemoApp-Swift/Supporting Files/Info.plist create mode 100644 DemoApp-Swift/DemoApp-Swift/Supporting Files/main.swift create mode 100644 DemoApp-Swift/Podfile diff --git a/.gitignore b/.gitignore index 2be37c9cf5..cbdf38071e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ DerivedData/ xcuserdata/ xcworkspace/ *.xcworkspacedata -DemoApp-ObjC/DemoApp-ObjC.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +*IDEWorkspaceChecks.plist ## Other *.moved-aside diff --git a/DemoApp-ObjC/DemoApp-ObjC/ALHomeViewController.h b/DemoApp-ObjC/DemoApp-ObjC/ALHomeViewController.h index 9e2b05257e..1db057be58 100644 --- a/DemoApp-ObjC/DemoApp-ObjC/ALHomeViewController.h +++ b/DemoApp-ObjC/DemoApp-ObjC/ALHomeViewController.h @@ -8,6 +8,6 @@ #import -@interface ALHomeViewController : UIViewController +@interface ALHomeViewController : UITableViewController @end diff --git a/DemoApp-ObjC/DemoApp-ObjC/Ads/ALAutoLayoutBannerAdViewController.m b/DemoApp-ObjC/DemoApp-ObjC/Ads/ALAutoLayoutBannerAdViewController.m index ba1dfe2930..5b365d2dc2 100644 --- a/DemoApp-ObjC/DemoApp-ObjC/Ads/ALAutoLayoutBannerAdViewController.m +++ b/DemoApp-ObjC/DemoApp-ObjC/Ads/ALAutoLayoutBannerAdViewController.m @@ -21,13 +21,15 @@ - (void)viewDidLoad { [super viewDidLoad]; - self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"BANNER_AD_UNIT_ID"]; + self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"YOUR_AD_UNIT_ID"]; self.adView.delegate = self; self.adView.translatesAutoresizingMaskIntoConstraints = NO; // Set background or background color for banners to be fully functional self.adView.backgroundColor = UIColor.blackColor; + [self.view addSubview: self.adView]; + // Center the banner and anchor it to the top of the screen. CGFloat height = (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) ? 90 : 50; // Banner height on iPhone and iPad is 50 and 90, respectively [self.view addConstraints: @[[self constraintWithAdView: self.adView andAttribute: NSLayoutAttributeLeading], @@ -40,7 +42,6 @@ - (void)viewDidLoad attribute: NSLayoutAttributeNotAnAttribute multiplier: 1.0 constant: height]]]; - [self.view addSubview: self.adView]; // Load the first ad [self.adView loadAd]; @@ -48,7 +49,7 @@ - (void)viewDidLoad - (NSLayoutConstraint *)constraintWithAdView:(MAAdView *)adView andAttribute:(NSLayoutAttribute)attribute { - return [NSLayoutConstraint constraintWithItem: self.adView + return [NSLayoutConstraint constraintWithItem: adView attribute: attribute relatedBy: NSLayoutRelationEqual toItem: self.view diff --git a/DemoApp-ObjC/DemoApp-ObjC/Supporting Files/Base.lproj/Main.storyboard b/DemoApp-ObjC/DemoApp-ObjC/Supporting Files/Base.lproj/Main.storyboard index 56265b689d..071e862269 100644 --- a/DemoApp-ObjC/DemoApp-ObjC/Supporting Files/Base.lproj/Main.storyboard +++ b/DemoApp-ObjC/DemoApp-ObjC/Supporting Files/Base.lproj/Main.storyboard @@ -1,11 +1,9 @@ - - - - + + - + @@ -13,7 +11,7 @@ - + @@ -26,11 +24,11 @@ - +