Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for OSX #33

Merged
merged 3 commits into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ConsistencyManager.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ Pod::Spec.new do |spec|
spec.summary = 'Manages the consistency of immutable models.'
spec.source = { :git => 'https://github.com/linkedin/ConsistencyManager-iOS.git', :tag => spec.version }
spec.source_files = 'ConsistencyManager/**/*.swift'
spec.platform = :ios, '8.0'
spec.frameworks = 'Foundation', 'UIKit'

spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'Foundation', 'UIKit'

spec.osx.deployment_target = '10.9'
spec.osx.frameworks = 'Foundation'
end

20 changes: 18 additions & 2 deletions ConsistencyManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
45C78FC31B3004E30032F592 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 45C78FC21B3004E30032F592 /* UIKit.framework */; };
613704301CCA90D3008D0EBB /* WeakListenerArrayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6137042F1CCA90D3008D0EBB /* WeakListenerArrayTests.swift */; };
6144A7FA1CB6DED300025127 /* ConsistencyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6144A7E81CB6DED300025127 /* ConsistencyManager.swift */; };
6144A7FB1CB6DED300025127 /* BatchListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6144A7EA1CB6DED300025127 /* BatchListener.swift */; };
Expand Down Expand Up @@ -111,7 +110,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
45C78FC31B3004E30032F592 /* UIKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -510,6 +508,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -518,17 +517,22 @@
INFOPLIST_FILE = ConsistencyManager/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "LinkedIn.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos9.3;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64";
};
name = Debug;
};
61DBAA6C19FFF64200A23A60 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -537,35 +541,47 @@
INFOPLIST_FILE = ConsistencyManager/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "LinkedIn.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos9.3;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx";
VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64";
};
name = Release;
};
61DBAA6E19FFF64200A23A60 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = ConsistencyManagerTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "LinkedIn.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ConsistencyManagerDemo.app/ConsistencyManagerDemo";
VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64";
};
name = Debug;
};
61DBAA6F19FFF64200A23A60 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
INFOPLIST_FILE = ConsistencyManagerTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "LinkedIn.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ConsistencyManagerDemo.app/ConsistencyManagerDemo";
VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64";
};
name = Release;
};
Expand Down

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

2 changes: 1 addition & 1 deletion ConsistencyManager/ConsistencyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

//! Project version number for ConsistencyManager.
FOUNDATION_EXPORT double ConsistencyManagerVersionNumber;
Expand Down
9 changes: 7 additions & 2 deletions ConsistencyManager/ConsistencyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

import Foundation
import UIKit
#if os(iOS)
import UIKit
#endif

/**
This is the main class for the library and contains most of the logic. For a detailed overview, please check the docs.
Expand Down Expand Up @@ -774,7 +776,10 @@ public class ConsistencyManager {

override init() {
super.init()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(UIApplicationDelegate.applicationDidReceiveMemoryWarning(_:)), name: UIApplicationDidReceiveMemoryWarningNotification, object: nil)
#if os(iOS)
// On OSX, we don't need this since there are no memory warnings.
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(MemoryWarningListener.applicationDidReceiveMemoryWarning(_:)), name: UIApplicationDidReceiveMemoryWarningNotification, object: nil)
#endif
}

deinit {
Expand Down
2 changes: 2 additions & 0 deletions ConsistencyManagerTests/MemoryWarningTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MemoryWarningTests: ConsistencyManagerTestCase {
var cleanMemoryFinishedTimes = [NSDate]()


#if os(iOS)
func testMemoryWarning() {
let testStart = NSDate()

Expand Down Expand Up @@ -63,4 +64,5 @@ class MemoryWarningTests: ConsistencyManagerTestCase {
XCTAssertTrue(cleanMemoryStartedTimes[0].timeIntervalSince1970 <= cleanMemoryFinishedTimes[0].timeIntervalSince1970)
XCTAssertTrue(testStart.timeIntervalSince1970 <= cleanMemoryStartedTimes[0].timeIntervalSince1970)
}
#endif
}
20 changes: 18 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/bin/sh
# Builds all targets and runs tests.

DERIVED_DATA=${1:-/tmp/ConsistencyManager}
echo "Derived data location: $DERIVED_DATA";

set -o pipefail &&
rm -rf $DERIVED_DATA &&
time xcodebuild clean test \
-project ConsistencyManager.xcodeproj \
-scheme ConsistencyManager \
-sdk macosx10.11 \
-derivedDataPath $DERIVED_DATA \
| tee build.log \
| xcpretty &&
rm -rf $DERIVED_DATA &&
time xcodebuild clean build \
-project ConsistencyManager.xcodeproj \
-scheme ConsistencyManager \
-sdk iphonesimulator9.3 \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \
-derivedDataPath $DERIVED_DATA \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=8.4' \
| xcpretty
-destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \
| tee build.log \
| xcpretty &&
cat build.log