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

Commit 53b5f26

Browse files
authored
Adding builders to the pod. Creating target for objc code. (#194)
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`.
1 parent 65f40d6 commit 53b5f26

25 files changed

+587
-106
lines changed

LayoutKit-iOS copy-Info.plist

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>FMWK</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>7.0.2</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
23+
<key>NSPrincipalClass</key>
24+
<string></string>
25+
</dict>
26+
</plist>

LayoutKit.xcodeproj/project.pbxproj

+337-74
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0900"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "0BCB755E1D8720110065E02A"
18+
BuildableName = "LayoutKit.framework"
19+
BlueprintName = "LayoutKit-iOS"
20+
ReferencedContainer = "container:LayoutKit.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
codeCoverageEnabled = "YES">
32+
<Testables>
33+
<TestableReference
34+
skipped = "NO">
35+
<BuildableReference
36+
BuildableIdentifier = "primary"
37+
BlueprintIdentifier = "0BCB75671D8720110065E02A"
38+
BuildableName = "LayoutKit-iOSTests.xctest"
39+
BlueprintName = "LayoutKit-iOSTests"
40+
ReferencedContainer = "container:LayoutKit.xcodeproj">
41+
</BuildableReference>
42+
</TestableReference>
43+
</Testables>
44+
<MacroExpansion>
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "0BCB755E1D8720110065E02A"
48+
BuildableName = "LayoutKit.framework"
49+
BlueprintName = "LayoutKit-iOS"
50+
ReferencedContainer = "container:LayoutKit.xcodeproj">
51+
</BuildableReference>
52+
</MacroExpansion>
53+
<AdditionalOptions>
54+
</AdditionalOptions>
55+
</TestAction>
56+
<LaunchAction
57+
buildConfiguration = "Debug"
58+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
59+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
60+
language = ""
61+
launchStyle = "0"
62+
useCustomWorkingDirectory = "NO"
63+
ignoresPersistentStateOnLaunch = "NO"
64+
debugDocumentVersioning = "YES"
65+
debugServiceExtension = "internal"
66+
allowLocationSimulation = "YES">
67+
<MacroExpansion>
68+
<BuildableReference
69+
BuildableIdentifier = "primary"
70+
BlueprintIdentifier = "0BCB755E1D8720110065E02A"
71+
BuildableName = "LayoutKit.framework"
72+
BlueprintName = "LayoutKit-iOS"
73+
ReferencedContainer = "container:LayoutKit.xcodeproj">
74+
</BuildableReference>
75+
</MacroExpansion>
76+
<AdditionalOptions>
77+
</AdditionalOptions>
78+
</LaunchAction>
79+
<ProfileAction
80+
buildConfiguration = "Release"
81+
shouldUseLaunchSchemeArgsEnv = "YES"
82+
savedToolIdentifier = ""
83+
useCustomWorkingDirectory = "NO"
84+
debugDocumentVersioning = "YES">
85+
<MacroExpansion>
86+
<BuildableReference
87+
BuildableIdentifier = "primary"
88+
BlueprintIdentifier = "0BCB755E1D8720110065E02A"
89+
BuildableName = "LayoutKit.framework"
90+
BlueprintName = "LayoutKit-iOS"
91+
ReferencedContainer = "container:LayoutKit.xcodeproj">
92+
</BuildableReference>
93+
</MacroExpansion>
94+
</ProfileAction>
95+
<AnalyzeAction
96+
buildConfiguration = "Debug">
97+
</AnalyzeAction>
98+
<ArchiveAction
99+
buildConfiguration = "Release"
100+
revealArchiveInOrganizer = "YES">
101+
</ArchiveAction>
102+
</Scheme>

LayoutKitObjC.podspec

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Pod::Spec.new do |spec|
66
spec.authors = 'LinkedIn'
77
spec.summary = 'LayoutKit is a fast view layout library for iOS, macOS, and tvOS. Now with Objective-C support.'
88
spec.source = { :git => 'https://github.com/linkedin/LayoutKit.git', :tag => spec.version }
9-
spec.source_files = 'Sources/**/*.swift'
9+
spec.source_files = 'Sources/**/*.{swift,h,m}'
1010
spec.documentation_url = 'http://layoutkit.org'
1111

1212
spec.ios.deployment_target = '8.0'
@@ -22,6 +22,9 @@ Pod::Spec.new do |spec|
2222
'Sources/Layouts/ButtonLayout.swift',
2323
'Sources/Layouts/LabelLayout.swift',
2424
'Sources/Layouts/TextViewLayout.swift',
25+
'Sources/ObjCSupport/Builders/LOKButtonLayoutBuilder.*',
26+
'Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.*',
27+
'Sources/ObjCSupport/Builders/LOKTextViewLayoutBuilder.*',
2528
'Sources/ObjCSupport/LOKBatchUpdates.swift',
2629
'Sources/ObjCSupport/LOKButtonLayout.swift',
2730
'Sources/ObjCSupport/LOKButtonLayoutType.swift',
@@ -41,6 +44,7 @@ Pod::Spec.new do |spec|
4144
'Sources/AppKitSupport.swift',
4245

4346
# Excluded due to "'systemFontSize' is unavailable"
47+
'Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.*',
4448
'Sources/ObjCSupport/LOKLabelLayout.swift'
4549
]
4650

LayoutKitObjCSampleApp/RotationLayout.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
88

99
#import <UIKit/UIKit.h>
10-
#import <LayoutKit/LayoutKit-Swift.h>
10+
#import <LayoutKitObjC/LayoutKitObjC-Swift.h>
1111

1212
@interface RotationLayout: NSObject <LOKLayout>
1313

Sources/LayoutKit.h

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

99
#import <Foundation/Foundation.h>
1010

Sources/LayoutKitObjC.h

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2018 LinkedIn Corp.
2+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4+
//
5+
// Unless required by applicable law or agreed to in writing,
6+
// software distributed under the License is distributed on an "AS IS" BASIS,
7+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8+
9+
#import <Foundation/Foundation.h>
10+
11+
//! Project version number for LayoutKitObjC.
12+
FOUNDATION_EXPORT double LayoutKitObjCVersionNumber;
13+
14+
//! Project version string for LayoutKitObjC.
15+
FOUNDATION_EXPORT const unsigned char LayoutKitObjCVersionString[];
16+
17+
// In this header, you should import all the public headers of your framework using statements like #import <LayoutKitObjC/PublicHeader.h>
18+
#import "LOKBaseLayoutBuilder.h"
19+
#if __has_include("LOKButtonLayoutBuilder.h")
20+
#import "LOKButtonLayoutBuilder.h"
21+
#endif
22+
#import "LOKInsetLayoutBuilder.h"
23+
#if __has_include("LOKLabelLayoutBuilder.h")
24+
#import "LOKLabelLayoutBuilder.h"
25+
#endif
26+
#import "LOKOverlayLayoutBuilder.h"
27+
#import "LOKSizeLayoutBuilder.h"
28+
#import "LOKStackLayoutBuilder.h"
29+
#if __has_include("LOKTextViewLayoutBuilder.h")
30+
#import "LOKTextViewLayoutBuilder.h"
31+
#endif

Sources/ObjCSupport/Builders/LOKBaseLayoutBuilder.h

+17-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,30 @@
77
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
88

99
#import <Foundation/Foundation.h>
10-
#import <LayoutKit/LayoutKit-Swift.h>
10+
11+
#if __has_include(<UIKit/UIKit.h>)
12+
// Importing the UI framework header. We could have just forward-declared `@class UIView` but `UIEdgeInsets` is a struct and cannot be forward-declared.
13+
#import <UIKit/UIKit.h>
14+
typedef UIEdgeInsets EdgeInsets;
15+
typedef UIView View;
16+
#else
17+
#import <AppKit/AppKit.h>
18+
typedef NSEdgeInsets EdgeInsets;
19+
typedef NSView View;
20+
#endif
21+
22+
// Forward-declaring
23+
@class LOKAlignment;
24+
@class LOKFlexibility;
25+
@protocol LOKLayout;
1126

1227
@interface LOKBaseLayoutBuilder : NSObject
1328

1429
@property (nonatomic, nullable) LOKAlignment *alignment;
1530
@property (nonatomic, nullable) LOKFlexibility *flexibility;
1631
@property (nonatomic, nullable) NSString *viewReuseId;
1732
@property (nonatomic, nullable) Class viewClass;
18-
@property (nonatomic, nullable) void (^ configure)(UIView * _Nonnull);
33+
@property (nonatomic, nullable) void (^ configure)(View * _Nonnull);
1934

2035
- (nonnull id<LOKLayout>)build;
2136

Sources/ObjCSupport/Builders/LOKBaseLayoutBuilder.m

+4
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010

1111
@implementation LOKBaseLayoutBuilder
1212

13+
- (id<LOKLayout>)build {
14+
return nil;
15+
}
16+
1317
@end

Sources/ObjCSupport/Builders/LOKButtonLayoutBuilder.h

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88

99
#import "LOKBaseLayoutBuilder.h"
1010

11+
@class LOKButtonLayout;
12+
13+
typedef NS_ENUM(NSInteger, LOKButtonLayoutType) {
14+
LOKButtonLayoutTypeCustom,
15+
LOKButtonLayoutTypeSystem,
16+
LOKButtonLayoutTypeDetailDisclosure,
17+
LOKButtonLayoutTypeInfoLight,
18+
LOKButtonLayoutTypeInfoDark,
19+
LOKButtonLayoutTypeContactAdd
20+
};
21+
1122
@interface LOKButtonLayoutBuilder : LOKBaseLayoutBuilder
1223

1324
+ (nonnull instancetype)withTitle:(nullable NSString *)title;

Sources/ObjCSupport/Builders/LOKButtonLayoutBuilder.m

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "LOKButtonLayoutBuilder.h"
1010

11+
#import <LayoutKitObjC/LayoutKitObjC-Swift.h>
12+
1113
@implementation LOKButtonLayoutBuilder
1214

1315
+ (instancetype)withTitle:(NSString *)title {

Sources/ObjCSupport/Builders/LOKInsetLayoutBuilder.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
#import "LOKBaseLayoutBuilder.h"
1010

11+
@class LOKInsetLayout;
12+
1113
@interface LOKInsetLayoutBuilder : LOKBaseLayoutBuilder
1214

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

15-
@property (nonatomic) UIEdgeInsets insets;
17+
@property (nonatomic) EdgeInsets insets;
1618
@property (nonatomic, nonnull) id<LOKLayout> sublayout;
1719

1820
- (nonnull LOKInsetLayout *)build;

Sources/ObjCSupport/Builders/LOKInsetLayoutBuilder.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
#import "LOKInsetLayoutBuilder.h"
1010

11+
#import <LayoutKitObjC/LayoutKitObjC-Swift.h>
12+
1113
@implementation LOKInsetLayoutBuilder
1214

13-
+ (nonnull instancetype)withInsets:(UIEdgeInsets)insets around:(nonnull id<LOKLayout>)sublayout {
15+
+ (nonnull instancetype)withInsets:(EdgeInsets)insets around:(nonnull id<LOKLayout>)sublayout {
1416
LOKInsetLayoutBuilder *builder = [[self alloc] init];
1517
if (builder) {
1618
builder.insets = insets;

Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.h

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "LOKBaseLayoutBuilder.h"
1010

11+
@class LOKLabelLayout;
12+
1113
@interface LOKLabelLayoutBuilder : LOKBaseLayoutBuilder
1214

1315
+ (nonnull instancetype)withString:(nullable NSString *)string;

Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.m

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "LOKLabelLayoutBuilder.h"
1010

11+
#import <LayoutKitObjC/LayoutKitObjC-Swift.h>
12+
1113
@implementation LOKLabelLayoutBuilder
1214

1315
+ (nonnull instancetype)withString:(nullable NSString *)string {

Sources/ObjCSupport/Builders/LOKOverlayLayoutBuilder.h

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "LOKBaseLayoutBuilder.h"
1010

11+
@class LOKOverlayLayout;
12+
1113
@interface LOKOverlayLayoutBuilder : LOKBaseLayoutBuilder
1214

1315
+ (nonnull instancetype)withPrimaryLayout:(nonnull id<LOKLayout>)primaryLayout;

Sources/ObjCSupport/Builders/LOKOverlayLayoutBuilder.m

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "LOKOverlayLayoutBuilder.h"
1010

11+
#import <LayoutKitObjC/LayoutKitObjC-Swift.h>
12+
1113
@implementation LOKOverlayLayoutBuilder
1214

1315
+ (instancetype)withPrimaryLayout:(id<LOKLayout>)primaryLayout {

Sources/ObjCSupport/Builders/LOKSizeLayoutBuilder.h

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "LOKBaseLayoutBuilder.h"
1010

11+
@class LOKSizeLayout;
12+
1113
@interface LOKSizeLayoutBuilder : LOKBaseLayoutBuilder
1214

1315
+ (nonnull instancetype)withSublayout:(nullable id<LOKLayout>)sublayout;

Sources/ObjCSupport/Builders/LOKSizeLayoutBuilder.m

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "LOKSizeLayoutBuilder.h"
1010

11+
#import <LayoutKitObjC/LayoutKitObjC-Swift.h>
12+
1113
@implementation LOKSizeLayoutBuilder
1214

1315
+ (instancetype)withSublayout:(id<LOKLayout>)sublayout {

Sources/ObjCSupport/Builders/LOKStackLayoutBuilder.h

+17
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@
88

99
#import "LOKBaseLayoutBuilder.h"
1010

11+
typedef NS_ENUM(NSInteger, LOKStackLayoutDistribution) {
12+
LOKStackLayoutDistributionDefault,
13+
LOKStackLayoutDistributionLeading,
14+
LOKStackLayoutDistributionTrailing,
15+
LOKStackLayoutDistributionCenter,
16+
LOKStackLayoutDistributionFillEqualSpacing,
17+
LOKStackLayoutDistributionFillEqualSize,
18+
LOKStackLayoutDistributionFillFlexing
19+
};
20+
21+
typedef NS_ENUM(NSInteger, LOKAxis) {
22+
LOKAxisVertical,
23+
LOKAxisHorizontal
24+
};
25+
26+
@class LOKStackLayout;
27+
1128
@interface LOKStackLayoutBuilder : LOKBaseLayoutBuilder
1229

1330
+ (nonnull instancetype)withSublayouts:(nonnull NSArray< id<LOKLayout> > *)sublayouts;

Sources/ObjCSupport/Builders/LOKStackLayoutBuilder.m

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "LOKStackLayoutBuilder.h"
1010

11+
#import <LayoutKitObjC/LayoutKitObjC-Swift.h>
12+
1113
@implementation LOKStackLayoutBuilder
1214

1315
+ (instancetype)withSublayouts:(NSArray<id<LOKLayout>> *)sublayouts {

0 commit comments

Comments
 (0)