Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
Adding builders to the pod. Creating target for objc code. (#194)
Browse files Browse the repository at this point in the history
Adding the builders to the LayoutKitObjC pod.
This required moving the objc enums to the header files, since objc builders cannot depend on Swift implementation.
Since the cross-language integration depends on header files that match the module name, creating a new LayoutKitObjC target for Xcode build to use to match the cocoa pods build.
Verified that build succeeds for Xcode and `pod lib lint`.
  • Loading branch information
staguer authored Mar 13, 2018
1 parent 65f40d6 commit 53b5f26
Show file tree
Hide file tree
Showing 25 changed files with 587 additions and 106 deletions.
26 changes: 26 additions & 0 deletions LayoutKit-iOS copy-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>7.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
411 changes: 337 additions & 74 deletions LayoutKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions LayoutKit.xcodeproj/xcshareddata/xcschemes/LayoutKitObjC-iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0BCB755E1D8720110065E02A"
BuildableName = "LayoutKit.framework"
BlueprintName = "LayoutKit-iOS"
ReferencedContainer = "container:LayoutKit.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0BCB75671D8720110065E02A"
BuildableName = "LayoutKit-iOSTests.xctest"
BlueprintName = "LayoutKit-iOSTests"
ReferencedContainer = "container:LayoutKit.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0BCB755E1D8720110065E02A"
BuildableName = "LayoutKit.framework"
BlueprintName = "LayoutKit-iOS"
ReferencedContainer = "container:LayoutKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0BCB755E1D8720110065E02A"
BuildableName = "LayoutKit.framework"
BlueprintName = "LayoutKit-iOS"
ReferencedContainer = "container:LayoutKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0BCB755E1D8720110065E02A"
BuildableName = "LayoutKit.framework"
BlueprintName = "LayoutKit-iOS"
ReferencedContainer = "container:LayoutKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
6 changes: 5 additions & 1 deletion LayoutKitObjC.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Pod::Spec.new do |spec|
spec.authors = 'LinkedIn'
spec.summary = 'LayoutKit is a fast view layout library for iOS, macOS, and tvOS. Now with Objective-C support.'
spec.source = { :git => 'https://github.com/linkedin/LayoutKit.git', :tag => spec.version }
spec.source_files = 'Sources/**/*.swift'
spec.source_files = 'Sources/**/*.{swift,h,m}'
spec.documentation_url = 'http://layoutkit.org'

spec.ios.deployment_target = '8.0'
Expand All @@ -22,6 +22,9 @@ Pod::Spec.new do |spec|
'Sources/Layouts/ButtonLayout.swift',
'Sources/Layouts/LabelLayout.swift',
'Sources/Layouts/TextViewLayout.swift',
'Sources/ObjCSupport/Builders/LOKButtonLayoutBuilder.*',
'Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.*',
'Sources/ObjCSupport/Builders/LOKTextViewLayoutBuilder.*',
'Sources/ObjCSupport/LOKBatchUpdates.swift',
'Sources/ObjCSupport/LOKButtonLayout.swift',
'Sources/ObjCSupport/LOKButtonLayoutType.swift',
Expand All @@ -41,6 +44,7 @@ Pod::Spec.new do |spec|
'Sources/AppKitSupport.swift',

# Excluded due to "'systemFontSize' is unavailable"
'Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.*',
'Sources/ObjCSupport/LOKLabelLayout.swift'
]

Expand Down
2 changes: 1 addition & 1 deletion LayoutKitObjCSampleApp/RotationLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

#import <UIKit/UIKit.h>
#import <LayoutKit/LayoutKit-Swift.h>
#import <LayoutKitObjC/LayoutKitObjC-Swift.h>

@interface RotationLayout: NSObject <LOKLayout>

Expand Down
12 changes: 6 additions & 6 deletions Sources/LayoutKit.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 2018 LinkedIn Corp.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// LayoutKit.h
// LayoutKit
//
// Created by Nick Snyder on 9/12/16.
//
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

#import <Foundation/Foundation.h>

Expand Down
31 changes: 31 additions & 0 deletions Sources/LayoutKitObjC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2018 LinkedIn Corp.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

#import <Foundation/Foundation.h>

//! Project version number for LayoutKitObjC.
FOUNDATION_EXPORT double LayoutKitObjCVersionNumber;

//! Project version string for LayoutKitObjC.
FOUNDATION_EXPORT const unsigned char LayoutKitObjCVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <LayoutKitObjC/PublicHeader.h>
#import "LOKBaseLayoutBuilder.h"
#if __has_include("LOKButtonLayoutBuilder.h")
#import "LOKButtonLayoutBuilder.h"
#endif
#import "LOKInsetLayoutBuilder.h"
#if __has_include("LOKLabelLayoutBuilder.h")
#import "LOKLabelLayoutBuilder.h"
#endif
#import "LOKOverlayLayoutBuilder.h"
#import "LOKSizeLayoutBuilder.h"
#import "LOKStackLayoutBuilder.h"
#if __has_include("LOKTextViewLayoutBuilder.h")
#import "LOKTextViewLayoutBuilder.h"
#endif
19 changes: 17 additions & 2 deletions Sources/ObjCSupport/Builders/LOKBaseLayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,30 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

#import <Foundation/Foundation.h>
#import <LayoutKit/LayoutKit-Swift.h>

#if __has_include(<UIKit/UIKit.h>)
// Importing the UI framework header. We could have just forward-declared `@class UIView` but `UIEdgeInsets` is a struct and cannot be forward-declared.
#import <UIKit/UIKit.h>
typedef UIEdgeInsets EdgeInsets;
typedef UIView View;
#else
#import <AppKit/AppKit.h>
typedef NSEdgeInsets EdgeInsets;
typedef NSView View;
#endif

// Forward-declaring
@class LOKAlignment;
@class LOKFlexibility;
@protocol LOKLayout;

@interface LOKBaseLayoutBuilder : NSObject

@property (nonatomic, nullable) LOKAlignment *alignment;
@property (nonatomic, nullable) LOKFlexibility *flexibility;
@property (nonatomic, nullable) NSString *viewReuseId;
@property (nonatomic, nullable) Class viewClass;
@property (nonatomic, nullable) void (^ configure)(UIView * _Nonnull);
@property (nonatomic, nullable) void (^ configure)(View * _Nonnull);

- (nonnull id<LOKLayout>)build;

Expand Down
4 changes: 4 additions & 0 deletions Sources/ObjCSupport/Builders/LOKBaseLayoutBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@

@implementation LOKBaseLayoutBuilder

- (id<LOKLayout>)build {
return nil;
}

@end
11 changes: 11 additions & 0 deletions Sources/ObjCSupport/Builders/LOKButtonLayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@

#import "LOKBaseLayoutBuilder.h"

@class LOKButtonLayout;

typedef NS_ENUM(NSInteger, LOKButtonLayoutType) {
LOKButtonLayoutTypeCustom,
LOKButtonLayoutTypeSystem,
LOKButtonLayoutTypeDetailDisclosure,
LOKButtonLayoutTypeInfoLight,
LOKButtonLayoutTypeInfoDark,
LOKButtonLayoutTypeContactAdd
};

@interface LOKButtonLayoutBuilder : LOKBaseLayoutBuilder

+ (nonnull instancetype)withTitle:(nullable NSString *)title;
Expand Down
2 changes: 2 additions & 0 deletions Sources/ObjCSupport/Builders/LOKButtonLayoutBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "LOKButtonLayoutBuilder.h"

#import <LayoutKitObjC/LayoutKitObjC-Swift.h>

@implementation LOKButtonLayoutBuilder

+ (instancetype)withTitle:(NSString *)title {
Expand Down
6 changes: 4 additions & 2 deletions Sources/ObjCSupport/Builders/LOKInsetLayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

#import "LOKBaseLayoutBuilder.h"

@class LOKInsetLayout;

@interface LOKInsetLayoutBuilder : LOKBaseLayoutBuilder

+ (nonnull instancetype)withInsets:(UIEdgeInsets)insets around:(nonnull id<LOKLayout>)sublayout;
+ (nonnull instancetype)withInsets:(EdgeInsets)insets around:(nonnull id<LOKLayout>)sublayout;

@property (nonatomic) UIEdgeInsets insets;
@property (nonatomic) EdgeInsets insets;
@property (nonatomic, nonnull) id<LOKLayout> sublayout;

- (nonnull LOKInsetLayout *)build;
Expand Down
4 changes: 3 additions & 1 deletion Sources/ObjCSupport/Builders/LOKInsetLayoutBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

#import "LOKInsetLayoutBuilder.h"

#import <LayoutKitObjC/LayoutKitObjC-Swift.h>

@implementation LOKInsetLayoutBuilder

+ (nonnull instancetype)withInsets:(UIEdgeInsets)insets around:(nonnull id<LOKLayout>)sublayout {
+ (nonnull instancetype)withInsets:(EdgeInsets)insets around:(nonnull id<LOKLayout>)sublayout {
LOKInsetLayoutBuilder *builder = [[self alloc] init];
if (builder) {
builder.insets = insets;
Expand Down
2 changes: 2 additions & 0 deletions Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "LOKBaseLayoutBuilder.h"

@class LOKLabelLayout;

@interface LOKLabelLayoutBuilder : LOKBaseLayoutBuilder

+ (nonnull instancetype)withString:(nullable NSString *)string;
Expand Down
2 changes: 2 additions & 0 deletions Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "LOKLabelLayoutBuilder.h"

#import <LayoutKitObjC/LayoutKitObjC-Swift.h>

@implementation LOKLabelLayoutBuilder

+ (nonnull instancetype)withString:(nullable NSString *)string {
Expand Down
2 changes: 2 additions & 0 deletions Sources/ObjCSupport/Builders/LOKOverlayLayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "LOKBaseLayoutBuilder.h"

@class LOKOverlayLayout;

@interface LOKOverlayLayoutBuilder : LOKBaseLayoutBuilder

+ (nonnull instancetype)withPrimaryLayout:(nonnull id<LOKLayout>)primaryLayout;
Expand Down
2 changes: 2 additions & 0 deletions Sources/ObjCSupport/Builders/LOKOverlayLayoutBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "LOKOverlayLayoutBuilder.h"

#import <LayoutKitObjC/LayoutKitObjC-Swift.h>

@implementation LOKOverlayLayoutBuilder

+ (instancetype)withPrimaryLayout:(id<LOKLayout>)primaryLayout {
Expand Down
2 changes: 2 additions & 0 deletions Sources/ObjCSupport/Builders/LOKSizeLayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "LOKBaseLayoutBuilder.h"

@class LOKSizeLayout;

@interface LOKSizeLayoutBuilder : LOKBaseLayoutBuilder

+ (nonnull instancetype)withSublayout:(nullable id<LOKLayout>)sublayout;
Expand Down
2 changes: 2 additions & 0 deletions Sources/ObjCSupport/Builders/LOKSizeLayoutBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "LOKSizeLayoutBuilder.h"

#import <LayoutKitObjC/LayoutKitObjC-Swift.h>

@implementation LOKSizeLayoutBuilder

+ (instancetype)withSublayout:(id<LOKLayout>)sublayout {
Expand Down
17 changes: 17 additions & 0 deletions Sources/ObjCSupport/Builders/LOKStackLayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@

#import "LOKBaseLayoutBuilder.h"

typedef NS_ENUM(NSInteger, LOKStackLayoutDistribution) {
LOKStackLayoutDistributionDefault,
LOKStackLayoutDistributionLeading,
LOKStackLayoutDistributionTrailing,
LOKStackLayoutDistributionCenter,
LOKStackLayoutDistributionFillEqualSpacing,
LOKStackLayoutDistributionFillEqualSize,
LOKStackLayoutDistributionFillFlexing
};

typedef NS_ENUM(NSInteger, LOKAxis) {
LOKAxisVertical,
LOKAxisHorizontal
};

@class LOKStackLayout;

@interface LOKStackLayoutBuilder : LOKBaseLayoutBuilder

+ (nonnull instancetype)withSublayouts:(nonnull NSArray< id<LOKLayout> > *)sublayouts;
Expand Down
2 changes: 2 additions & 0 deletions Sources/ObjCSupport/Builders/LOKStackLayoutBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "LOKStackLayoutBuilder.h"

#import <LayoutKitObjC/LayoutKitObjC-Swift.h>

@implementation LOKStackLayoutBuilder

+ (instancetype)withSublayouts:(NSArray<id<LOKLayout>> *)sublayouts {
Expand Down
Loading

0 comments on commit 53b5f26

Please sign in to comment.