Skip to content

Commit

Permalink
Adds support for Carthage (#173)
Browse files Browse the repository at this point in the history
* Updates project settings suggested after running `pod install`

Running `pod install` with CocoaPods 1.3.0 caused some project settings
to be updated.

* Fixes build errors from command line by importing the right headers

For some reason `carthage build --no-skip-current` (and later xcodebuild)
complaint about not being able to import UIKit in PiwikTracker.h.

* Fixes platform names for supported SDK.

`tvos` has been replaced by `appletvos`.

* Updates .gitignore to ignore Carthage build products

* Adds a Rake task checking that the project builds with Carthage
  • Loading branch information
elitalon authored and brototyp committed Sep 10, 2017
1 parent 81145e5 commit f88b24f
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Exclude the build directory
build/*
DerivedData

# Exclude temp nibs and swap files
*~.nib
Expand All @@ -19,6 +20,8 @@ xcuserdata

# Exclude generate documentation
Doc/

# Exclude build products from dependency managers
Pods
DerivedData
/Podfile.lock
Carthage/
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ language: objective-c
before_install:
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- brew install carthage
- cd $TRAVIS_BUILD_DIR
- pod install || pod install --repo-update
script: rake test
script:
- rake test
- rake build_with_package_manager
osx_image: xcode8.3
cache: cocoapods
8 changes: 7 additions & 1 deletion Example/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,12 @@
files = (
);
inputPaths = (
"${SRCROOT}/../../Pods/Target Support Files/Pods-example-ios/Pods-example-ios-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/PiwikTracker-iOS/PiwikTracker.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PiwikTracker.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -346,13 +349,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-example-ios-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
CDC3360217B97B190098386C /* Build appledoc */ = {
Expand Down
8 changes: 7 additions & 1 deletion Example/macos/macos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-example-macos-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
50DAC7215CB8D45774949E1F /* [CP] Embed Pods Frameworks */ = {
Expand All @@ -176,9 +179,12 @@
files = (
);
inputPaths = (
"${SRCROOT}/../../Pods/Target Support Files/Pods-example-macos/Pods-example-macos-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/PiwikTracker-macOS/PiwikTracker.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PiwikTracker.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
8 changes: 7 additions & 1 deletion Example/tvos/tvos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@
files = (
);
inputPaths = (
"${SRCROOT}/../../Pods/Target Support Files/Pods-example-tvos/Pods-example-tvos-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/PiwikTracker-tvOS/PiwikTracker.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PiwikTracker.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -191,13 +194,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-example-tvos-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down
14 changes: 11 additions & 3 deletions PiwikTracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,14 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-PiwikTrackerTests/Pods-PiwikTrackerTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework",
"${BUILT_PRODUCTS_DIR}/Quick/Quick.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -326,13 +331,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-PiwikTrackerTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
F440219733D7385F192471AC /* [CP] Copy Pods Resources */ = {
Expand Down Expand Up @@ -516,7 +524,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.piwik.PiwikTracker;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx tvos";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvos macosx";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
Expand All @@ -538,7 +546,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.piwik.PiwikTracker;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx tvos";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvos macosx";
SWIFT_VERSION = 3.0;
};
name = Release;
Expand Down
1 change: 1 addition & 0 deletions PiwikTracker/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ internal struct Device {

}
#if os(OSX)
import AppKit
extension Device {
/// Reaturns the version number of the current OS as String i.e. "1.2" or "9.4"
internal static func osVersionForCurrentDevice() -> String {
Expand Down
1 change: 1 addition & 0 deletions PiwikTracker/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import CoreGraphics

/// Represents an event of any kind.
///
Expand Down
2 changes: 1 addition & 1 deletion PiwikTracker/PiwikTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2016 PIWIK. All rights reserved.
//

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

//! Project version number for PiwikTracker.
FOUNDATION_EXPORT double PiwikTrackerVersionNumber;
Expand Down
24 changes: 24 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ namespace :test do
end
end

namespace :package_manager do
desc 'Prepare tests'
task :prepare do
end

desc 'Builds the project with Carthage'
task carthage: :prepare do
sh("carthage build --no-skip-current") rescue nil
package_manager_failed('Carthage integration') unless $?.success?
end
end


desc 'Run the PiwikTracker tests for iOS & Mac OS X'
task :test do
Rake::Task['test:ios'].invoke
Expand All @@ -40,8 +53,14 @@ task :test do
Rake::Task['test:tvos_demo'].invoke
end

desc 'Check the integration of PiwikTracker with package managers'
task :build_with_package_manager do
Rake::Task['package_manager:carthage'].invoke
end

task default: 'test'


private

def run_build(scheme, sdk, destination = 'platform=iOS Simulator,name=iPhone 6,OS=10.3.1')
Expand All @@ -67,6 +86,11 @@ def tests_failed(platform)
exit $?.exitstatus
end

def package_manager_failed(package_manager)
puts red("Integration with #{package_manager} failed")
exit $?.exitstatus
end

def red(string)
"\033[0;31m! #{string}"
end

0 comments on commit f88b24f

Please sign in to comment.