Git Product home page Git Product logo

pivotalcorekit's Introduction

PivotalCoreKit — Common library code for iOS projects.

Build Status

CHANGES

Why PivotalCoreKit

PivotalCoreKit lets you keep creating beautiful apps without having to rewrite the same boilerplate code in every project.

While it has useful functionality in a few different domains, it has a particular focus on helping developers test drive their iOS applications.

What can PivotalCoreKit help with

Highlights

  • Method swizzling
  • Collect/map an NSArray
  • Load nib-based views from other nibs with bindings and layout constraints intact Wiki link
  • Resize a UIImage with aspect fit or aspect fill
  • Simulate taps on UIButtons
  • Simulate UIGestureRecognizer recognition
  • Compare two UIImages for equality
  • Query and inspect current UIActionSheet and UIAlertView
  • Stub out NSOperationQueue and run its operations on demand
  • Stub out NSURLConnection to simulate network activity and callbacks
  • Stub out UIWebView's functionality

Full list

PivotalCoreKit is split along framework lines, with separate Xcode projects for the Foundation, UIKit, and CoreLocation frameworks. Each project is then separated again out into sub-sections: Core, SpecHelper, and SpecHelperStubs.

Core methods are meant to be used anywhere they're useful, whether in specs or in the primary application. SpecHelper extends built-in classes to make testing easier and more seamless. SpecHelperStubs stub out (and replace) a class's functionality to allow a developer to more easily inspect its state.

Here is a (hopefully exhaustive but inevitably out of date) list of PivotalCoreKit functionality, separated by framework/section:

  • Foundation (iOS and OSX)
    • Core
      • Convert NSString into a SHA1 hash (as NSData)
      • Convert NSData into a hexadecimal string
      • Method redirection on NSObjects (also commonly called Swizzling)
      • Convert an NSString ("Hello world I am doing great today") into camel case ("HelloWorldIAmDoingGreatToday")
      • Check if an NSString is blank
      • Check if an NSString is a valid email address
      • Percent escape encode an NSString including characters the build-in percent escaping doesn't include.
      • Map an NSArray into another NSArray by collecting items through a block
      • Convert an NSDictionary into a string of query parameters
      • NSURLConnectionDelegate based networking service (PCKHTTPConnection and PCKHTTPInterface)
      • An event-driven XML parser (PCKParser)
    • SpecHelper
      • Break out query parameters of an NSURL into an NSDictionary
      • Fake out NSURLConnection to keep it from actually accessing network and fire success/failure responses on demand
      • Return the body of an NSURLRequest as a string
      • Fake out +[NSUUID UUID] to return consistent results
      • Fake out NSOperationQueue to execute blocks on demand
  • UIKit (iOS only)
    • Core
      • Produce a UIBarButtonItem from a UIButton
      • Load nib-based views from other nibs with bindings and layout constraints intact Wiki link
      • Resize a UIImage with aspect fill or aspect fit
      • Crop a UIImage or add rounded corners
      • Translating UIViews by deltas
      • Resizing UIViews with corner pinning
      • Calculate height from NSString and NSAttributedString drawing
    • SpecHelper
      • Simulate a tap on
        • UIButton
        • UITableViewCell
        • UICollectionViewCell
        • UIBarButtonItem
        • UITabBarController item
      • Simulate a tap, swipe, or pinch on a UIView (triggers attached gesture recognizers)
      • Simulate a tap, swipe left/right on a UIPageControl
      • Simulate a new value for a UISlider
      • Simulate recognition of specific gesture recognizer
      • Compare UIImages for equality
      • Query a UIWindow for the first responder
    • SpecHelperStubs
      • Query, inspect, and simulate taps on the current UIActionSheet
      • Query, inspect, and simulate taps on the current UIAlertView
      • Query, inspect, present and dismiss a UIPopoverController
      • Simulate availability states of UIImagePickerController (camera available/not available, et cetera)
      • Inspect arguments (duration, delay, options) on last UIView animation
      • Determine if the UIView is shown completely (not translucent, height, width or clipped) on screen
      • Fake out UIWebView to inspect requests, simulate back/forward state, and simulate web loads
  • CoreLocation (iOS only)
    • SpecHelper
      • Simulate Geocoding success or failure
  • WatchKit (iOS only)
    • WatchKit
      • An interface-identical stand-in framework for Apple's entire WatchKit framework
      • Used to write tests for your WatchKit apps (currently impossible if using Apple's framework classes directly)

PivotalCoreKit is test-driven and includes Specs in each project.

That sounds great, give me some examples

Maybe you have a bunch of quarterly reports and want to collect all the finances from the first week for each report. After linking to Foundation+PivotalCore

#import "NSArray+PivotalCore.h"
/* ... */
Week week = FirstWeek;
NSArray *firstWeekFinances = [reports collect:^id(PLReport *report) {
    return [report financesForWeek:week];
}];

Or maybe you're testing that tapping a button properly fires off a network request After linking to UIKit+PivotalSpecHelper

#import "UIControl+Spec.h"
/* ... */
describe(@"when the button is tapped", ^{
    beforeEach(^{
        [button tap];
    });

    it(@"fires a network request", ^{
        apiClient should have_received(@selector(requestNewestRecipes));
    });
});

Say you want to check what URL a webview was asked to load. After linking to UIKit+PivotalSpecHelperStubs

#import "UIWebView+Spec.h"
/* ... */
it(@"webview should load example.com", ^{
    controller.webView.request.URL.absoluteString should equal(@"http://example.com");
});

Without PivotalCoreKit's UIWebView stubs, the webView's NSURLRequest will be nil because the real UIWebView hasn't started actually making the request. A stubbed UIWebView updates the request property immediately.

How do I install PivotalCoreKit

Via CocoaPods

  1. Install CocoaPods with gem install cocoapods.
  2. Create a file in your Xcode project called Podfile and add the following line:
pod 'PivotalCoreKit'

The PivotalCoreKit cocoapod is split into multiple sub pods to allow users to pick-and-choose what parts of the library they want to use. so examine the podspec to choose what pieces you want. An example of a more complicated PodFile would look like this:

target 'ImplementationTarget' do
  pod 'PivotalCoreKit'
end

target 'Specs' do
  pod 'PivotalCoreKit'
  pod 'PivotalCoreKit/UIKit/SpecHelper/Extensions'
  pod 'PivotalCoreKit/Foundation/SpecHelper/Fakes'
end

For OSX Projects - since Foundation is the only OSX-compatible framework, just add the Foundation sub pod to your Podfile.

pod 'PivotalCoreKit/Foundation'
  1. Run pod install in your xcode project directory. CocoaPods should download and install the correct portions of the PivotalCoreKit library, and create a new Xcode workspace. Open up this workspace in Xcode.

Via Git Submodules

  • In a shell in the root of your project run: git submodule add https://github.com/pivotal/PivotalCoreKit.git Externals/PivotalCoreKit
  • Add the PivotalCoreKit project(s) (Foundation.xcodeproj, UIKit.xcodeproj, or CoreLocation.xcodeproj) you need into your project for the appropriate target
  • In your application's Project Settings, under Build Phases, add the desired StaticLib to "Target Dependencies"
  • Add the corresponding binary to the Link Binary With Libraries section
  • If you are using PivotalCoreKit+Foundation, add libxml2.2.dylib to the Link Binary With Libraries section
  • Switch to Build Settings and update your Header Search Paths to include the path to folder containing the added subproject. Make it recursive.
  • e.g. "$(SRCROOT)/Externals/PivotalCoreKit/path/to/specific/projectfolder/".

Example, adding -[UIButton tap] to a spec target

  • git submodule add https://github.com/pivotal/PivotalCoreKit.git Externals/PivotalCoreKit
  • Right-click Specs folder in Xcode -> Add Files
  • Navigate into PivotalCoreKit/UIKit folder, select UIKit.xcodeproj and add.
  • In root project file, choose Specs target
  • Under the "Build Phases" tab along the top of the project settings, add UIKit+PivotalSpecHelper-StaticLib to "Target Dependencies"
  • Add libUIKit+PivotalSpecHelper-StaticLib.a to the "Link Binary With Library" section. (Also add CoreGraphics.framework).
  • Switch to the "Build Settings" tab Add "$(SRCROOT)/Externals/PivotalCoreKit/UIKit/" to "Header Search Paths" and make it recursive
  • In the desired spec file, add #import "UIControl+Spec.h" and freely use [button tap];

Library Documentation

Documentation for specific methods and functionality can be found at http://cocoadocs.org/docsets/PivotalCoreKit/

MIT License

Copyright (c) 2014-2018 Pivotal Labs (http://pivotal.io) Contact email: [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission 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.

pivotalcorekit's People

Contributors

akitchen avatar alexbasson avatar briancroom avatar cbguder avatar codeman9 avatar codeword avatar erictsiliacos avatar evanhughes3 avatar gudatcomputers avatar idoru avatar jeffh avatar jeis2497052 avatar jfuchs avatar joemasilotti avatar kseebaldt avatar lazerwalker avatar medmonds avatar mtviewdave avatar onsi avatar pivotalcommon avatar pivotalworkstation avatar pjk25 avatar readmecritic avatar samzhang111 avatar stansey avatar tjarratt avatar tooluser avatar wileykestner avatar xtreme-steven-wu avatar younata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pivotalcorekit's Issues

UIAlertController dismissWith.... methods should dismiss the view controller

One of the actions taken by UIAlertController on click of any block is to dismiss itself. (Apple's docs don't state this explicitly, but it is observed behavior, viz:

Typically the alert controller is dismissed automatically when the user selects an action. It can also be dismissed programmatically, if required, like any other view controller.

(from UseYourLoaf.)

The current utility methods:

- (void)dismissByTappingCancelButton {
    UIAlertAction *cancelAction = [self cancelAction];
    if (cancelAction.handler) {
        cancelAction.handler(cancelAction);
    }
}

- (void)dismissByTappingButtonWithTitle:(NSString *)title {
    UIAlertAction *action = [self actionWithButtonTitle:title];
    if (action.handler) {
        action.handler(action);
    }
}

Don't dismiss the VC, so don't mimic the real-world behavior and make testing tough; it's not possible to verify that the alert VC was dismissed.

PCKInterfaceControllerLoader doesn't initialize/binds IBOutlets and IBActions in XCode 8.3.2

PCKInterfaceControllerLoader doesn't initialize/binds IBOutlets and IBActions from watch storyboard in XCode 8.3.2

My target setup for testing watchOS > 2.0 is the same as in:
https://content.pivotal.io/blog/apple-watch-2-0-with-tdd-setup

When callling:

 - (id)interfaceControllerWithStoryboardName:(NSString *)storyboardName
                                 identifier:(NSString *)objectID
                                     bundle:(NSBundle *)bundle

from PCKInterfaceControllerLoader, it returns the correct WKInterfaceController, but all WKInterfaceObjects in this scene are not initialized.

This issue doesn't occur in XCode < 8.3.2

Build fails with newest code

With the newest code from Friday our build started failing:

[12:12:58][Step 3/3] CompileC /Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/Objects-normal/i386/UICollectionViewCell+Spec.o PivotalCoreKit/UIKit/SpecHelper/Extensions/UICollectionViewCell+Spec.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
[12:12:58][Step 3/3]     cd /Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods
[12:12:58][Step 3/3]     export LANG=en_US.US-ASCII
[12:12:58][Step 3/3]     export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/pivotal/.rvm/gems/ruby-2.1.2/bin:/Users/pivotal/.rvm/gems/ruby-2.1.2@global/bin:/Users/pivotal/.rvm/rubies/ruby-2.1.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/X11/bin:/Users/pivotal/.rvm/bin"
[12:12:58][Step 3/3]     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fmodules -fmodules-cache-path=/Users/pivotal/Library/Developer/Xcode/DerivedData/ModuleCache -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -DCOCOAPODS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -fexceptions -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -Wno-sign-conversion -fobjc-abi-version=2 -fobjc-legacy-dispatch -mios-simulator-version-min=7.0 -iquote /Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/Pods-Specs-PivotalCoreKit-generated-files.hmap -I/Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/Pods-Specs-PivotalCoreKit-own-target-headers.hmap -I/Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/Pods-Specs-PivotalCoreKit-all-target-headers.hmap -iquote /Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/Pods-Specs-PivotalCoreKit-project-headers.hmap -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/build/Debug-iphonesimulator/include -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/BuildHeaders -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/BuildHeaders/PivotalCoreKit -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/Headers -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/Headers/Blindside -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/Headers/Cedar -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/Headers/JKVValue -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/Headers/MBProgressHUD -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/Headers/PLCrashReporter -I/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/Headers/PivotalCoreKit -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/include/libxml2 -I/Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/DerivedSources/i386 -I/Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/DerivedSources -F/Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/build/Debug-iphonesimulator -include /Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/PrecompiledHeaders/Pods-Specs-PivotalCoreKit-prefix-clrxfesyldgizefaodzhxjjzyzth/Pods-Specs-PivotalCoreKit-prefix.pch -MMD -MT dependencies -MF /Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/Objects-normal/i386/UICollectionViewCell+Spec.d --serialize-diagnostics /Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/Objects-normal/i386/UICollectionViewCell+Spec.dia -c /Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/PivotalCoreKit/UIKit/SpecHelper/Extensions/UICollectionViewCell+Spec.m -o /Users/pivotal/Library/Developer/Xcode/DerivedData/CareCompanion-dqesrubdghsljbggkeblqunlgoqo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-Specs-PivotalCoreKit.build/Objects-normal/i386/UICollectionViewCell+Spec.o
[12:12:58][Step 3/3] /Users/pivotal/TeamCity/buildAgent/work/f614516a96301853/Pods/PivotalCoreKit/UIKit/SpecHelper/Extensions/UICollectionViewCell+Spec.m:3:9: fatal error: '../Helpers/PCKPrototypeCellInstantiatingDataSource.h' file not found
[12:12:58][Step 3/3] #import "../Helpers/PCKPrototypeCellInstantiatingDataSource.h"
[12:12:58][Step 3/3]         ^
[12:12:58][Step 3/3] 1 error generated.

Missing import referenced in:
UICollectionReusableView+Spec.h

Thanks,
Justin and Stephan

Remove static frameworks?

We have dynamic frameworks for (as far as I can tell) every subproject in PCK. Anyone using iOS 7 or earlier (i.e. before dynamic frameworks are supported on iOS) can just use cocoapods.

This would ease the burden of maintaining this significantly.

Thanks.

CocoaPods 1.0.1 break

screen shot 2016-06-03 at 1 34 39 pm
screen shot 2016-06-03 at 1 34 56 pm
screen shot 2016-06-03 at 1 35 16 pm

Pod installs have worked for us using CocoaPods .39. Lately we tried updating to CocoaPods 1.0.1 and encountered an issue trying to do a pod install. Appears a pivotal core kit reference creates too long of a path causing an "ERRNO:ENAMETOOLONG" error as shown in bottom of picture 'Screen Shot 2016-06-03 at 1.34.56 PM'

How to expose script handlers for WKUserContentController without swizzling?

This continues the discussion from an open Cedar issue related to Xcode 7.

When working with WKWebView you can create a JavaScript "bridge" via the WKUserContentController. Via -addScriptMessageHandler: you can create a hook that gets calls when special JavaScript methods are fired. Unfortunately, there is no way to read back these handlers once they are set, essentially making the property "write-only." (Yay, Apple!)

To get around this I swizzled the method and exposed the parameters in my own dictionary. Testing with Cedar under Xcode 6 on iOS 8.X this works great, no issues. However, when updating to Xcode 7 and iOS 9 the swizzling creates all sorts of issues for WKWebView.

So, I ask the community, how can one expose these "write-only" properties without swizzling?

Validating for App Store submission raises a warning.

Linking to PCK's Foundation project will raise a warning when validating for App Store submission under iOS7.

The app references non-public selectors in <app_name>: basePath

basePath is referenced in PCKHTTPInterface.m

Not all schemes are building with Carthage

@jfoley and I are trying to use PCK (on master) with Carthage. We've got to the point where PCK appears to build without an error (by using the fix in PR #175), however we only see the following schemes being built:

± ms+jf |master ✗| → carthage update --no-use-binaries --platform ios
...
*** Building scheme "CoreLocation+PivotalSpecHelper-iOS" in PivotalCoreKit.xcworkspace
*** Building scheme "UIKit+PivotalCore-iOS" in PivotalCoreKit.xcworkspace
*** Building scheme "WatchKit" in PivotalCoreKit.xcworkspace
*** Building scheme "Cedar-iOS" in PivotalCoreKit.xcworkspace
...

There's a number of schemes missing (notable for us are the spec helpers and stubs). Having spoken with @younata, it appears that this could be a bug in Carthage, but we're filing an issue here to track this on the PCK side.

Cannot find objc/objc-runtime.h

I have a project with PivotalCoreKit that's complying that 'objc/objc-runtime.h' file not found.

I have this setting on my Podfile:

target 'Specs' do
    pod 'Cedar', '~> 0.10.0'

    PCK = {git: 'https://github.com/pivotal/PivotalCoreKit.git', commit: '6905ec0'}
    pod 'PivotalCoreKit/Core', PCK
    pod 'PivotalCoreKit/Foundation/SpecHelper', PCK
    pod 'PivotalCoreKit/UIKit/SpecHelper', PCK
end

Please add semantic version tags.

I’ve recently added PivotalCoreKit to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, PivotalCoreKit doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:

$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags

Using PivotalCoreKit in a project with code in objC and swift

We are trying to integrate swift into our project.
When we try to use fakes such as PSHKFakeHTTPURLResponse in our tests we get an error while installing the bundle to the simulator:

"Failed to load test bundle from file: Symbol not found: OBJC_CLASS$_PSHKFakeHTTPURLResponse"

It seems to be looking for the symbols inside the App symbols, instead of the Spec symbols.

Here is our Podfile:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'app' do
pod 'Blindside'
pod 'Flurry-iOS-SDK'
pod 'MBProgressHUD', :git => 'https://github.com/gudatcomputers/MBProgressHUD.git'
pod 'KSDeferred'
pod 'PivotalCoreKit', :git => 'https://github.com/pivotal/PivotalCoreKit.git'
pod 'TrustKit'
end

target 'Specs' do
pod 'Blindside'
pod 'MBProgressHUD', :git => 'https://github.com/gudatcomputers/MBProgressHUD.git'
pod 'KSDeferred'
pod 'Cedar'
pod 'Nimble', '3.2.0'
pod 'PivotalCoreKit/Foundation', :git => 'https://github.com/pivotal/PivotalCoreKit.git'
pod 'PivotalCoreKit/UIKit', :git => 'https://github.com/pivotal/PivotalCoreKit.git'
pod 'TrustKit'
end

Does PivotalCoreKit support a project with objC & swift code and tests together?

Need PivotalSpecHelperKit.h and UIcontrol+Spec.h in framework

I've PivotalSpecHelperKit.h and UIcontrol+Spec.h imported in one project. Unfortunately the build was not successful due to "Lexical/preprocessor error and the mentioned files are not found" I've downloaded the PivotalCoreKit zip file and placed in the path but there is no "PivotalSpecHelperKit.h" file in the folders.
Please guide me how to include.

Thanks & Regards,
Aswini

PCK stub for modal presentation doesn't really respect all these lifecycle calls

While writing a test in Cedar I'm trying to validate specific behavior in viewWillDisappear -- The context is simply that my subject view controller presents another view controller modally after tapping a UIButton and executes important logic in viewWillDisappear.

After rendering the view in test, and invoking the tap method from UIControl+Spec.h on the UIButton, the viewWillDisappear method is never called on my subject.

Any insights or a suggestion on how to test what occurs in viewWillDisappear?

WatchKit specs fail to run in Xcode 8.3.2 / Xcode fails to run other specs thereafter

In Xcode 8.3.2, the WatchKit specs fail with the following:

dyld: Symbol not found: _SPHoldCompanionExtensionProcessAssertion
  Referenced from: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DVTInstrumentsFoundation
  Expected in: /Users/akitchen/Library/Developer/Xcode/DerivedData/PivotalCoreKit-bwbtwtidhjdzglafroxsporifhot/Build/Products/Debug-iphonesimulator/WatchKit.framework/WatchKit
 in /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DVTInstrumentsFoundation
2017-05-19 20:01:25.273 xcodebuild[36015:478160] Error Domain=IDETestOperationsObserverErrorDomain Code=6 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}

Testing failed:
	Test target Specs encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
** TEST FAILED **

... and then the shared build output is unusable for testing the other non-WatchKit targets in the project, causing the tests to fail to bootstrap in the same way. Anyone working with the project will need to remove their DerivedData folder or "Clean Build Folder" in Xcode after running the WatchKit specs in Xcode 8.3 before any other test bundles from the project can be run again.

This means we're stuck on Xcode 8.2 on Travis for a while, and we'll need to figure out what's going on. This is worth filing a radar over, I think.

watchOS storyboards do not support target device type "iphone".

Trying to run specs with PCK watchKit, but when I add the storyboard in the specs target i get this error. Xcode 7 seems to add some sort of setting that makes it so that PCK cannot load the storyboard and instantiate the interface controller. We are trying to run specs as a separate specs target since running them with the test bundle seems to fail.

iOS5 PCKHTTPConnection Issue

In iOS beta 5 there appears to be an issue with PCKHTTPConnections which causes the connection to be made however no network requests go out and no callbacks are ever made to the delegate. This seems to be an issue with NSURLConnection attempting to make the connection immediately upon initialization and before the new PCKHTTPConnection has time to set its connection delegate.

popoverPresentationController is always nil in iOS 11

Hello, and thanks for making an awesome tool! I'm running Cedar with PCK, and I'm trying to pin down an issue I had when running my specs on iOS 11. When running my specs on iOS 11, all the tests related a "presentedViewController's" "popoverPresentationController" started failing.

Here is a test that passes on iOS 10.3, and fails on iOS 11.

ViewControllerSpec.mm

#import <Cedar/Cedar.h>
#import "ViewController.h"

using namespace Cedar::Matchers;
using namespace Cedar::Doubles;

SPEC_BEGIN(ViewControllerSpec)

describe(@"ViewController", ^{
    __block ViewController *subject;

    beforeEach(^{
        subject = [[ViewController alloc] init];
    });

    describe(@"-viewDidLoad", ^{
        beforeEach(^{
            [subject loadViewIfNeeded];
        });
 
        it(@"should present a popover controller", ^{
            UIViewController *presentedViewController = subject.presentedViewController;
            presentedViewController.popoverPresentationController should_not be_nil;
        });
    });
});

SPEC_END

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@end

ViewController.m

#import "ViewController.h"


@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIViewController *popoverController = [[UIViewController alloc] init];
    popoverController.modalPresentationStyle = UIModalPresentationPopover;

    [self presentViewController:popoverController animated:YES completion:nil];
}

@end

Everything seems to work fine when running the actual app, meaning self.presentedViewController.popoverPresentationController is a real instance. This is only an issue in specs.

Any help would be much appreciated!

Support "flat index" lookups on tables and collection views

Recently I have been noticing that many of my specs around table views and collection views are looking for cells at particular locations, however the full (row/item)+section pair is an implementation detail, causing the tests to break horribly if choose to refactor the way that the view controller is using sections internally. I have started using a category that allows looking up cells by an integer "flat index" instead, treating all cells as if they were part of a simple list.

Does this sound like a useful thing to add to PCK as a spec helper? I'd be glad to open a PR if there is any interest.

NSString+PivotalCore falls afoul of new designated initializer requirement in ios8

A convenience method to generate an NSString from data doesn't invoke the designated initializer and so generates a build error in Xcode 6, viz:

https://developer.apple.com/library/ios/documentation/general/conceptual/CocoaEncyclopedia/Initialization/Initialization.html#//apple_ref/doc/uid/TP40010810-CH6-SW3

- (id)initWithBase64EncodedData:(NSData *)data DEPRECATED_ATTRIBUTE {
    if ([data respondsToSelector:@selector(base64EncodedStringWithOptions:)]) {
        return [[data base64EncodedStringWithOptions:0] retain];
    } else {
        return [[data base64Encoding] retain];
    }
}

The method is identical to the static version directly above it, and used in only one place (a test). It's a bit of an odd construction, and already marked deprecated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.