Skip to content

Commit

Permalink
Merge pull request #9 from capacitor-community/shared-ios-pod
Browse files Browse the repository at this point in the history
AppCenterCapacitorShared ios pod
  • Loading branch information
johnborges authored May 20, 2021
2 parents 623707b + 8d9989a commit 63c702b
Show file tree
Hide file tree
Showing 210 changed files with 11,647 additions and 0 deletions.
37 changes: 37 additions & 0 deletions AppCenterCapacitorShared/ios/AppCenterCapacitorShared/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# OS X
.DS_Store

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.ipa

# Bundler
.bundle

# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml
#
# Pods/
14 changes: 14 additions & 0 deletions AppCenterCapacitorShared/ios/AppCenterCapacitorShared/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# references:
# * https://www.objc.io/issues/6-build-tools/travis-ci/
# * https://github.com/supermarin/xcpretty#usage

osx_image: xcode7.3
language: objective-c
# cache: cocoapods
# podfile: Example/Podfile
# before_install:
# - gem install cocoapods # Since Travis is not always on latest version
# - pod install --project-directory=Example
script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/AppCenterCapacitorShared.xcworkspace -scheme AppCenterCapacitorShared-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Pod::Spec.new do |s|
s.name = 'AppCenterCapacitorShared'
s.version = '0.1.0'
s.summary = 'Shared utility to assist with bootstrapping AppCenter for Capacitor plugin.'
s.homepage = 'https://github.com/capacitor-community/appcenter-sdk-capacitor'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'johnborges' => '[email protected]' }
s.source = { :http => 'https://github.com/capacitor-community/appcenter-sdk-capacitor/releases/download/0.1.0/AppCenter-SDK-Capacitor-iOS-Pod-0.1.0.zip' }
s.social_media_url = 'https://twitter.com/johnborges'
s.ios.deployment_target = '12.0'
s.swift_version = '5.1'
s.source_files = '*.swift'
s.dependency 'AppCenter/Core', '4.1.1'
s.static_framework = true
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import Foundation
import AppCenter

public class AppCenterCapacitorShared: NSObject {

static var startAutomatically: Bool = true
static var configuration: NSDictionary = [:]
static var appSecret: String?
static var wrapperSdk: WrapperSdk?
// plist keys
static var kAppCenterSecretKey = "AppSecret"
static var kAppCenterStartAutomaticallyKey = "StartAutomatically"
static var kAppCenterConfigResource = "AppCenter-Config"

public static func getConfiguration() -> NSDictionary {
return configuration
}

public static func setStartAutomatically (_ shouldStartAutomatically: Bool) {
startAutomatically = shouldStartAutomatically;
}

public static func configureWithSettings() {
if AppCenter.isConfigured {
return
}

let wrapperSdk = WrapperSdk(wrapperSdkVersion: "0.1.0", wrapperSdkName: "appcenter.capacitor", wrapperRuntimeVersion: nil, liveUpdateReleaseLabel: nil, liveUpdateDeploymentKey: nil, liveUpdatePackageHash: nil)

setWrapperSdk(wrapperSdk!)
getAppSecret()

if startAutomatically {
if appSecret!.count == 0 {
AppCenter.configure()
}
else {
AppCenter.configure(withAppSecret: appSecret)
}
}
}

public static func setAppSecret(_ secret: String) {
appSecret = secret
}

public static func getAppSecret() {
if appSecret == nil {
// get values from config plist
let plist = Bundle.main.path(forResource: AppCenterCapacitorShared.kAppCenterConfigResource, ofType: "plist")
configuration = NSDictionary(contentsOfFile: plist!)!
appSecret = configuration[AppCenterCapacitorShared.kAppCenterSecretKey] as? String

// start automatically flag true by default
if let rawStartAutomatically = configuration[AppCenterCapacitorShared.kAppCenterStartAutomaticallyKey] as? Bool {
startAutomatically = rawStartAutomatically
}
}
}

public static func getWrapperSdk() -> WrapperSdk? {
return wrapperSdk
}

public static func setWrapperSdk(_ sdk: WrapperSdk) {
wrapperSdk = sdk
AppCenter.wrapperSdk = sdk
}

}
Loading

0 comments on commit 63c702b

Please sign in to comment.