Skip to content

Commit

Permalink
Merge pull request #70 from line/feature/spm-support
Browse files Browse the repository at this point in the history
Swift Package Manager support
  • Loading branch information
onevcat authored Jul 19, 2019
2 parents f15adfe + 2079932 commit cea81a9
Show file tree
Hide file tree
Showing 49 changed files with 301 additions and 92 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleShortVersionString</key>
<string>5.2.0</string>
<key>CFBundleVersion</key>
<string>522</string>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
16 changes: 14 additions & 2 deletions LineSDK/LineSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
4B813C5A2101B1450091F78E /* RequestAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B813C592101B1450091F78E /* RequestAdapter.swift */; };
4B813C5C2101B65D0091F78E /* ParametersAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B813C5B2101B65D0091F78E /* ParametersAdapter.swift */; };
4B825623224CC36000D9F63E /* ShareTargetSearchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B825622224CC36000D9F63E /* ShareTargetSearchController.swift */; };
4B85BB6B22C4A8E600DFE299 /* ResourceLoading.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B85BB6A22C4A8E600DFE299 /* ResourceLoading.swift */; };
4B8A965721100A5800760219 /* LoginConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8A965621100A5800760219 /* LoginConfigurationTests.swift */; };
4B8FF4862105656500890AEF /* Delegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FF4852105656500890AEF /* Delegate.swift */; };
4B8FF48B21056B3800890AEF /* CallbackQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FF48A21056B3800890AEF /* CallbackQueue.swift */; };
Expand Down Expand Up @@ -408,6 +409,7 @@
4B813C592101B1450091F78E /* RequestAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestAdapter.swift; sourceTree = "<group>"; };
4B813C5B2101B65D0091F78E /* ParametersAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParametersAdapter.swift; sourceTree = "<group>"; };
4B825622224CC36000D9F63E /* ShareTargetSearchController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTargetSearchController.swift; sourceTree = "<group>"; };
4B85BB6A22C4A8E600DFE299 /* ResourceLoading.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourceLoading.swift; sourceTree = "<group>"; };
4B8A965621100A5800760219 /* LoginConfigurationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginConfigurationTests.swift; sourceTree = "<group>"; };
4B8FF4852105656500890AEF /* Delegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Delegate.swift; sourceTree = "<group>"; };
4B8FF48A21056B3800890AEF /* CallbackQueue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallbackQueue.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -828,6 +830,7 @@
4B90587A21006E5C004D717F /* LineSDK */ = {
isa = PBXGroup;
children = (
4BE7E81822C4A14A00362661 /* LineSDKUI */,
4BBAFC4A2101CE8100E7BFF6 /* Resource.bundle */,
4BBAFC432101BB8200E7BFF6 /* General */,
4B9058CE210072B9004D717F /* Login */,
Expand All @@ -836,7 +839,6 @@
D102A6992164650A00804C7C /* Friendship */,
4B9058CD210072B0004D717F /* Networking */,
4B25A811213684F000C74B87 /* Crypto */,
4B5B0EF12241DE4600BA59A0 /* SharingUI */,
4B9058CF210072C3004D717F /* Utils */,
3F75522E2123D214004AC047 /* Assets.xcassets */,
4B90587B21006E5C004D717F /* LineSDK.h */,
Expand Down Expand Up @@ -879,7 +881,6 @@
4B9058CE210072B9004D717F /* Login */ = {
isa = PBXGroup;
children = (
3F75523021244502004AC047 /* LoginButton.swift */,
4BF53534212A7A0700EA602A /* Request */,
4BF53533212A79FA00EA602A /* Model */,
4B9058D321007394004D717F /* LoginConfiguration.swift */,
Expand Down Expand Up @@ -1214,6 +1215,16 @@
path = Sharing;
sourceTree = "<group>";
};
4BE7E81822C4A14A00362661 /* LineSDKUI */ = {
isa = PBXGroup;
children = (
4B5B0EF12241DE4600BA59A0 /* SharingUI */,
3F75523021244502004AC047 /* LoginButton.swift */,
4B85BB6A22C4A8E600DFE299 /* ResourceLoading.swift */,
);
path = LineSDKUI;
sourceTree = "<group>";
};
4BF45A872137B27F00CCD28E /* Crypto */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1756,6 +1767,7 @@
4B1658052252EF3C0008E441 /* DownloadableImageView.swift in Sources */,
4BF5353B212A7DB200EA602A /* FlexBubbleContainer.swift in Sources */,
DBFBD43F224E7D0500A74D44 /* SelectedTargetPanelCell.swift in Sources */,
4B85BB6B22C4A8E600DFE299 /* ResourceLoading.swift in Sources */,
DB5035BB22571D3B003CD0B9 /* KeyboardObservable.swift in Sources */,
4B95F40221252D2F00AD3A81 /* PostMultisendMessagesRequest.swift in Sources */,
4B9B9AA72123C6E400325B9B /* PostSendMessagesRequest.swift in Sources */,
Expand Down
File renamed without changes.
82 changes: 82 additions & 0 deletions LineSDK/LineSDK/LineSDKUI/ResourceLoading.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// ResourceLoading.swift
//
// Copyright (c) 2016-present, LINE Corporation. All rights reserved.
//
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
// copy and distribute this software in source code or binary form for use
// in connection with the web services and APIs provided by LINE Corporation.
//
// As with any software that integrates with the LINE Corporation platform, your use of this software
// is subject to the LINE Developers Agreement [http://terms2.line.me/LINE_Developers_Agreement].
// This copyright notice shall be included in all copies or substantial portions of the software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

enum Localization {
static func string(_ key: String) -> String {
return NSLocalizedString(key, bundle: .frameworkResourceBundle, comment: "")
}
}

extension UIImage {

/// Creates a `UIImage` object in current framework bundle.
///
/// - Parameters:
/// - name: The image name.
/// - trait: The traits associated with the intended environment for the image.
convenience init?(bundleNamed name: String, compatibleWith trait: UITraitCollection? = nil) {
let bundle: Bundle
#if LineSDKCocoaPods
bundle = .sdkBundle
#else
bundle = .frameworkBundle
#endif
self.init(named: name, in: bundle, compatibleWith: trait)
}
}

extension Bundle {
static let frameworkResourceBundle: Bundle = {
let parentBundle: Bundle
#if LineSDKCocoaPods
parentBundle = sdkBundle
#else
parentBundle = frameworkBundle
#endif

guard let path = parentBundle.path(forResource: "Resource", ofType: "bundle"),
let bundle = Bundle(path: path) else
{
Log.fatalError("SDK resource bundle cannot be found, " +
"please verify your installation is not corrupted and try to reinstall LineSDK.")
}
return bundle
}()

#if LineSDKCocoaPods
// SDK Bundle is for CocoaPods: ( sp.resource_bundles = { 'LineSDK' => [ ... ] } )
static let sdkBundle: Bundle = {
guard let path = Bundle.frameworkBundle.path(forResource: "LineSDK", ofType: "bundle"),
let bundle = Bundle(path: path) else
{
Log.fatalError("LineSDK.bundle cannot be found, " +
"please verify your installation is not corrupted and try to reinstall LineSDK.")
}
return bundle
}()
#endif

static let frameworkBundle: Bundle = {
return Bundle(for: LoginManager.self)
}()
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
import UIKit

/// Represents the share target in a share action.
/// A target can be either a friend of current user, or a group of which the current user is a member.
Expand Down
2 changes: 1 addition & 1 deletion LineSDK/LineSDK/Login/LoginManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
import UIKit

/// Represents a login manager. You can set up the LINE SDK configuration, log in and log out the user with the
/// LINE authorization flow, and check the authorization status.
Expand Down
2 changes: 2 additions & 0 deletions LineSDK/LineSDK/Messaging/Model/AudioMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// LINE internal use only.
/// Represents a message containing an audio URL.
public struct AudioMessage: Codable, MessageTypeCompatible {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// LINE internal use only.
/// Represents an icon component. It is used to embed into a baseline layout and its flex is fixed to 0.
public struct FlexIconComponent: Codable, FlexMessageComponentTypeCompatible {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// LINE internal use only.
/// Represents an image component in a flex message.
public struct FlexImageComponent: Codable, FlexMessageComponentTypeCompatible, MessageActionContainer {
Expand Down
2 changes: 2 additions & 0 deletions LineSDK/LineSDK/Messaging/Model/ImageMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// LINE internal use only.
/// Represents a message containing an image URL and a preview image URL.
public struct ImageMessage: Codable, MessageTypeCompatible {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// LINE internal use only.
/// Represents a template payload with an image, title, text, and multiple action buttons.
/// The message bubble size is the same with a regular message. It may include an image at most.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// LINE internal use only.
/// Represents a template payload with multiple `Column`s which can be cycled like a carousel.
/// The columns will be shown in order by scrolling horizontally.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// LINE internal use only.
/// Represents a template payload with multiple `Column`s with image which can be cycled like a carousel.
/// The columns with image will be shown in order by scrolling horizontally.
Expand Down
2 changes: 2 additions & 0 deletions LineSDK/LineSDK/Messaging/Model/VideoMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// LINE internal use only.
/// Represents a message containing an video URL and a preview image URL.
public struct VideoMessage: Codable, MessageTypeCompatible {
Expand Down
2 changes: 1 addition & 1 deletion LineSDK/LineSDK/Networking/Client/RequestAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
import UIKit

/// Adapts a request to another request. Adapters modify an input `URLRequest` object.
public protocol RequestAdapter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
import UIKit

class DownloadableImageView: UIImageView {

Expand Down
2 changes: 1 addition & 1 deletion LineSDK/LineSDK/Networking/Images/ImageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
import UIKit

typealias ImageSettingResult = Result<UIImage, LineSDKError>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
import CoreGraphics
import UIKit

extension KeyedDecodingContainer {
func decodeLoginPermissions(forKey key: Key) throws -> [LoginPermission] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
import UIKit

/// Represents a color in hexadecimal notation. This type provides compatibility with the `Codable` protocol
/// for color objects.
Expand Down
44 changes: 1 addition & 43 deletions LineSDK/LineSDK/Utils/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,7 @@ import Foundation
public struct Constant {

/// The version of the current LINE SDK.
public static let SDKVersion: String = {
let bundle = Bundle.frameworkResourceBundle
guard let version = bundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else {
Log.fatalError("SDK resource bundle cannot be loaded, " +
"please verify your installation is not corrupted and try to reinstall LineSDK.")
}

return version
}()
public static let SDKVersion = "5.2.0"

static var SDKVersionString: String {
return "LINE SDK iOS v\(SDKVersion)"
Expand All @@ -54,37 +46,3 @@ public struct Constant {
return URL(string: "\(Constant.lineAuthV2Scheme)://authorize/")!
}
}

extension Bundle {
static let frameworkResourceBundle: Bundle = {
let parentBundle: Bundle
#if LineSDKCocoaPods
parentBundle = sdkBundle
#else
parentBundle = frameworkBundle
#endif

guard let path = parentBundle.path(forResource: "Resource", ofType: "bundle"),
let bundle = Bundle(path: path) else
{
Log.fatalError("SDK resource bundle cannot be found, " +
"please verify your installation is not corrupted and try to reinstall LineSDK.")
}
return bundle
}()

#if LineSDKCocoaPods
static let sdkBundle: Bundle = {
guard let path = Bundle.frameworkBundle.path(forResource: "LineSDK", ofType: "bundle"),
let bundle = Bundle(path: path) else {
Log.fatalError("LineSDK.bundle cannot be found, " +
"please verify your installation is not corrupted and try to reinstall LineSDK.")
}
return bundle
}()
#endif

static let frameworkBundle: Bundle = {
return Bundle(for: LoginManager.self)
}()
}
26 changes: 1 addition & 25 deletions LineSDK/LineSDK/Utils/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
import UIKit

struct Log {
static func assertionFailure(
Expand Down Expand Up @@ -144,30 +144,6 @@ func guardSharedProperty<T>(_ input: T?) -> T {
return shared
}

enum Localization {
static func string(_ key: String) -> String {
return NSLocalizedString(key, bundle: .frameworkResourceBundle, comment: "")
}
}

extension UIImage {

/// Creates a `UIImage` object in current framework bundle.
///
/// - Parameters:
/// - name: The image name.
/// - trait: The traits associated with the intended environment for the image.
convenience init?(bundleNamed name: String, compatibleWith trait: UITraitCollection? = nil) {
let bundle: Bundle
#if LineSDKCocoaPods
bundle = .sdkBundle
#else
bundle = .frameworkBundle
#endif
self.init(named: name, in: bundle, compatibleWith: trait)
}
}

extension UIColor {
func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
return UIGraphicsImageRenderer(size: size).image { rendererContext in
Expand Down
Loading

0 comments on commit cea81a9

Please sign in to comment.