Repository: mattt/SkyLab
Branch: master
Commit: 9b71b26ce1ce
Files: 17
Total size: 50.0 KB
Directory structure:
gitextract_sqd19qz7/
├── Example/
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Info.plist
│ ├── Prefix.pch
│ ├── SkyLab Example.xcodeproj/
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace/
│ │ └── contents.xcworkspacedata
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── en.lproj/
│ │ ├── InfoPlist.strings
│ │ └── ViewController.xib
│ └── main.m
├── LICENSE
├── README.md
├── SkyLab/
│ ├── SkyLab.h
│ └── SkyLab.m
├── SkyLab.podspec
└── SkyLab.xcworkspace/
└── contents.xcworkspacedata
================================================
FILE CONTENTS
================================================
================================================
FILE: Example/AppDelegate.h
================================================
// AppDelegate.h
//
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
//
// 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.
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
================================================
FILE: Example/AppDelegate.m
================================================
// AppDelegate.m
//
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
//
// 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.
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
================================================
FILE: Example/Info.plist
================================================
<?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>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.mattt.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
================================================
FILE: Example/Prefix.pch
================================================
#import <Availability.h>
#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
================================================
FILE: Example/SkyLab Example.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
F82DFAB916B835A20095ECA8 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F82DFAB816B835A20095ECA8 /* Default-568h@2x.png */; };
F83687B515F7C0190018A10F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8F78AAB15F55EAD00608A10 /* UIKit.framework */; };
F83687B615F7C0190018A10F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8F78AAD15F55EAD00608A10 /* Foundation.framework */; };
F83687B715F7C0190018A10F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8F78AAF15F55EAD00608A10 /* CoreGraphics.framework */; };
F83687D915F7C04D0018A10F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F83687D115F7C04D0018A10F /* InfoPlist.strings */; };
F83687DA15F7C04D0018A10F /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F83687D315F7C04D0018A10F /* ViewController.xib */; };
F83687DB15F7C04D0018A10F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F83687D515F7C04D0018A10F /* AppDelegate.m */; };
F83687DC15F7C04D0018A10F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F83687D615F7C04D0018A10F /* main.m */; };
F83687DD15F7C04D0018A10F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F83687D715F7C04D0018A10F /* ViewController.m */; };
F83687E115F7C1070018A10F /* SkyLab.m in Sources */ = {isa = PBXBuildFile; fileRef = F8F78ACD15F55EDF00608A10 /* SkyLab.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
F82DFAB816B835A20095ECA8 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
F83687B315F7C0190018A10F /* SkyLab.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SkyLab.app; sourceTree = BUILT_PRODUCTS_DIR; };
F83687CD15F7C04D0018A10F /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; };
F83687CE15F7C04D0018A10F /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = SOURCE_ROOT; };
F83687CF15F7C04D0018A10F /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; };
F83687D215F7C04D0018A10F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = InfoPlist.strings; sourceTree = "<group>"; };
F83687D415F7C04D0018A10F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = ViewController.xib; sourceTree = "<group>"; };
F83687D515F7C04D0018A10F /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; };
F83687D615F7C04D0018A10F /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; };
F83687D715F7C04D0018A10F /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = SOURCE_ROOT; };
F83687D815F7C04D0018A10F /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
F8F78AAB15F55EAD00608A10 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
F8F78AAD15F55EAD00608A10 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
F8F78AAF15F55EAD00608A10 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
F8F78ACC15F55EDF00608A10 /* SkyLab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkyLab.h; path = ../SkyLab/SkyLab.h; sourceTree = "<group>"; };
F8F78ACD15F55EDF00608A10 /* SkyLab.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SkyLab.m; path = ../SkyLab/SkyLab.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F83687B015F7C0190018A10F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F83687B515F7C0190018A10F /* UIKit.framework in Frameworks */,
F83687B615F7C0190018A10F /* Foundation.framework in Frameworks */,
F83687B715F7C0190018A10F /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
F83687B815F7C0190018A10F /* SkyLab Example */ = {
isa = PBXGroup;
children = (
F83687CD15F7C04D0018A10F /* AppDelegate.h */,
F83687D515F7C04D0018A10F /* AppDelegate.m */,
F83687CE15F7C04D0018A10F /* ViewController.h */,
F83687D715F7C04D0018A10F /* ViewController.m */,
F83687DF15F7C0DE0018A10F /* Supporting Files */,
);
path = "SkyLab Example";
sourceTree = "<group>";
};
F83687D015F7C04D0018A10F /* en.lproj */ = {
isa = PBXGroup;
children = (
F83687D115F7C04D0018A10F /* InfoPlist.strings */,
F83687D315F7C04D0018A10F /* ViewController.xib */,
);
path = en.lproj;
sourceTree = SOURCE_ROOT;
};
F83687DF15F7C0DE0018A10F /* Supporting Files */ = {
isa = PBXGroup;
children = (
F83687CF15F7C04D0018A10F /* Prefix.pch */,
F83687D615F7C04D0018A10F /* main.m */,
F83687D815F7C04D0018A10F /* Info.plist */,
F83687D015F7C04D0018A10F /* en.lproj */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
F8F78A9C15F55EAD00608A10 = {
isa = PBXGroup;
children = (
F82DFAB816B835A20095ECA8 /* Default-568h@2x.png */,
F83687B815F7C0190018A10F /* SkyLab Example */,
F8F78AAA15F55EAD00608A10 /* Frameworks */,
F8F78AA815F55EAD00608A10 /* Products */,
F8F78AD015F55EE900608A10 /* Vendor */,
);
sourceTree = "<group>";
};
F8F78AA815F55EAD00608A10 /* Products */ = {
isa = PBXGroup;
children = (
F83687B315F7C0190018A10F /* SkyLab.app */,
);
name = Products;
sourceTree = "<group>";
};
F8F78AAA15F55EAD00608A10 /* Frameworks */ = {
isa = PBXGroup;
children = (
F8F78AAB15F55EAD00608A10 /* UIKit.framework */,
F8F78AAD15F55EAD00608A10 /* Foundation.framework */,
F8F78AAF15F55EAD00608A10 /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
F8F78AD015F55EE900608A10 /* Vendor */ = {
isa = PBXGroup;
children = (
F8F78AE515F7B82E00608A10 /* SkyLab */,
);
name = Vendor;
sourceTree = "<group>";
};
F8F78AE515F7B82E00608A10 /* SkyLab */ = {
isa = PBXGroup;
children = (
F8F78ACC15F55EDF00608A10 /* SkyLab.h */,
F8F78ACD15F55EDF00608A10 /* SkyLab.m */,
);
name = SkyLab;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
F83687B215F7C0190018A10F /* SkyLab */ = {
isa = PBXNativeTarget;
buildConfigurationList = F83687CA15F7C0190018A10F /* Build configuration list for PBXNativeTarget "SkyLab" */;
buildPhases = (
F83687AF15F7C0190018A10F /* Sources */,
F83687B015F7C0190018A10F /* Frameworks */,
F83687B115F7C0190018A10F /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = SkyLab;
productName = "SkyLab Example";
productReference = F83687B315F7C0190018A10F /* SkyLab.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
F8F78A9E15F55EAD00608A10 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
ORGANIZATIONNAME = "Mattt Thompson";
};
buildConfigurationList = F8F78AA115F55EAD00608A10 /* Build configuration list for PBXProject "SkyLab Example" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = F8F78A9C15F55EAD00608A10;
productRefGroup = F8F78AA815F55EAD00608A10 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
F83687B215F7C0190018A10F /* SkyLab */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
F83687B115F7C0190018A10F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F83687D915F7C04D0018A10F /* InfoPlist.strings in Resources */,
F83687DA15F7C04D0018A10F /* ViewController.xib in Resources */,
F82DFAB916B835A20095ECA8 /* Default-568h@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
F83687AF15F7C0190018A10F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F83687DB15F7C04D0018A10F /* AppDelegate.m in Sources */,
F83687DC15F7C04D0018A10F /* main.m in Sources */,
F83687DD15F7C04D0018A10F /* ViewController.m in Sources */,
F83687E115F7C1070018A10F /* SkyLab.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
F83687D115F7C04D0018A10F /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
F83687D215F7C04D0018A10F /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
F83687D315F7C04D0018A10F /* ViewController.xib */ = {
isa = PBXVariantGroup;
children = (
F83687D415F7C04D0018A10F /* en */,
);
name = ViewController.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
F83687CB15F7C0190018A10F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch;
INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = "$(TARGET_NAME)";
WARNING_CFLAGS = "";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
F83687CC15F7C0190018A10F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch;
INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = "$(TARGET_NAME)";
WARNING_CFLAGS = "";
WRAPPER_EXTENSION = app;
};
name = Release;
};
F8F78AC315F55EAD00608A10 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
F8F78AC415F55EAD00608A10 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
F83687CA15F7C0190018A10F /* Build configuration list for PBXNativeTarget "SkyLab" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F83687CB15F7C0190018A10F /* Debug */,
F83687CC15F7C0190018A10F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F8F78AA115F55EAD00608A10 /* Build configuration list for PBXProject "SkyLab Example" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F8F78AC315F55EAD00608A10 /* Debug */,
F8F78AC415F55EAD00608A10 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = F8F78A9E15F55EAD00608A10 /* Project object */;
}
================================================
FILE: Example/SkyLab Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:SkyLab Example.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: Example/ViewController.h
================================================
// ViewController.h
//
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
//
// 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.
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *subtitleLabel;
@property (weak, nonatomic) IBOutlet UISwitch *leftSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *centerSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *rightSwitch;
- (IBAction)resetTests:(id)sender;
@end
================================================
FILE: Example/ViewController.m
================================================
// ViewController.m
//
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
//
// 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.
#import "ViewController.h"
#import "SkyLab.h"
@implementation ViewController
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Simple A/B Test
[SkyLab abTestWithName:@"Title" A:^{
self.titleLabel.text = NSLocalizedString(@"Hello, World!", nil);
} B:^{
self.titleLabel.text = NSLocalizedString(@"Greetings, Planet!", nil);
}];
// Split Test with Weighted Probabilities
[SkyLab splitTestWithName:@"Subtitle" conditions:@{
@"Red" : @(0.15),
@"Green" : @(0.10),
@"Blue" : @(0.50),
@"Purple" : @(0.25)
} block:^(id choice) {
self.subtitleLabel.text = NSLocalizedString(@"Please Enjoy This Colorful Message", nil);
if ([choice isEqualToString:@"Red"]) {
self.subtitleLabel.textColor = [UIColor redColor];
} else if ([choice isEqualToString:@"Green"]) {
self.subtitleLabel.textColor = [UIColor greenColor];
} else if ([choice isEqualToString:@"Blue"]) {
self.subtitleLabel.textColor = [UIColor blueColor];
} else if ([choice isEqualToString:@"Purple"]) {
self.subtitleLabel.textColor = [UIColor purpleColor];
}
}];
// Multivariate Test
[SkyLab multivariateTestWithName:@"Switches" variables:@{
@"Left" : @(0.5),
@"Center" : @(0.5),
@"Right" : @(0.5)
} block:^(NSSet *activeVariables) {
self.leftSwitch.on = [activeVariables containsObject:@"Left"];
self.centerSwitch.on = [activeVariables containsObject:@"Center"];
self.rightSwitch.on = [activeVariables containsObject:@"Right"];
}];
}
#pragma mark - IBAction
- (IBAction)resetTests:(id)sender {
[SkyLab resetTestNamed:@"Title"];
[SkyLab resetTestNamed:@"Subtitle"];
[SkyLab resetTestNamed:@"Switches"];
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Tests Reset", nil) message:NSLocalizedString(@"Segmentation will be re-run on next launch", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil, nil] show];
}
@end
================================================
FILE: Example/en.lproj/InfoPlist.strings
================================================
/* Localized versions of Info.plist keys */
================================================
FILE: Example/en.lproj/ViewController.xib
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment defaultVersion="1296" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ViewController">
<connections>
<outlet property="centerSwitch" destination="16" id="19"/>
<outlet property="leftSwitch" destination="17" id="18"/>
<outlet property="rightSwitch" destination="15" id="20"/>
<outlet property="subtitleLabel" destination="9" id="12"/>
<outlet property="titleLabel" destination="8" id="11"/>
<outlet property="view" destination="6" id="7"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="6">
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Title" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="8">
<rect key="frame" x="18" y="69" width="280" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="32"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Subtitle" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="9">
<rect key="frame" x="18" y="114" width="280" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="13">
<rect key="frame" x="18" y="374" width="280" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Reset Tests">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="resetTests:" destination="-1" eventType="touchUpInside" id="24"/>
</connections>
</button>
<switch opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="15">
<rect key="frame" x="239" y="208" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</switch>
<switch opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="16">
<rect key="frame" x="139" y="207" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</switch>
<switch opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="17">
<rect key="frame" x="35" y="208" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</switch>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Left" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" adjustsFontSizeToFit="NO" id="21">
<rect key="frame" x="20" y="243" width="79" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.29803922770000002" green="0.29803922770000002" blue="0.29803922770000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Center" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" adjustsFontSizeToFit="NO" id="22">
<rect key="frame" x="127" y="243" width="79" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.29803922770000002" green="0.29803922770000002" blue="0.29803922770000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Right" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" adjustsFontSizeToFit="NO" id="23">
<rect key="frame" x="224" y="243" width="79" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.29803922770000002" green="0.29803922770000002" blue="0.29803922770000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
</view>
</objects>
</document>
================================================
FILE: Example/main.m
================================================
//
// main.m
// SkyLab Example
//
// Created by Mattt Thompson on 2012/09/05.
// Copyright (c) 2012年 Mattt Thompson. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
================================================
FILE: LICENSE
================================================
Copyright (c) 2012 – 2021 Mattt (https://mat.tt)
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.
================================================
FILE: README.md
================================================
> This library is no longer being maintained.
> You can continue to use SkyLab in your projects,
> but we recommend switching another solution whenever you have the opportunity.
# SkyLab
**Multivariate & A/B Testing for iOS and Mac**
SkyLab is a backend-agnostic framework for [multivariate](http://en.wikipedia.org/wiki/Multivariate_testing) and [A/B testing](http://en.wikipedia.org/wiki/A/B_testing).
Test conditions are persisted across sessions and launches using `NSUserDefaults`, ensuring that every user will have a consistent experience, no matter which testing bucket they end up in.
SkyLab integrates easily into any existing statistics web service. Depending on your particular needs, this may include posting to an endpoint in test blocks, or perhaps setting an HTTP header for a shared API client.
**Requests for integration with any particular backend are heartily encouraged.**
> This project is part of a series of open source libraries covering the mission-critical aspects of an iOS app's infrastructure. Be sure to check out its sister projects: [GroundControl](https://github.com/mattt/GroundControl), [CargoBay](https://github.com/mattt/CargoBay), [houston](https://github.com/mattt/houston), and [Orbiter](https://github.com/mattt/Orbiter).
## Usage
Check out the included example project to see everything in action.
### Simple A/B Test
```objective-c
[SkyLab abTestWithName:@"Title" A:^{
self.titleLabel.text = NSLocalizedString(@"Hello, World!", nil);
} B:^{
self.titleLabel.text = NSLocalizedString(@"Greetings, Planet!", nil);
}];
```
### Split Test with Weighted Probabilities
You can pass either an `NSDictionary` (with values representing the weighted probability of their corresponding key) or an `NSArray` (with each value having an equal chance of being chosen) into the `choices` parameter.
```objective-c
[SkyLab splitTestWithName:@"Subtitle" conditions:@{
@"Red" : @(0.15),
@"Green" : @(0.10),
@"Blue" : @(0.50),
@"Purple" : @(0.25)
} block:^(id choice) {
self.subtitleLabel.text = NSLocalizedString(@"Please Enjoy This Colorful Message", nil);
if ([choice isEqualToString:@"Red"]) {
self.subtitleLabel.textColor = [UIColor redColor];
} else if ([choice isEqualToString:@"Green"]) {
self.subtitleLabel.textColor = [UIColor greenColor];
} else if ([choice isEqualToString:@"Blue"]) {
self.subtitleLabel.textColor = [UIColor blueColor];
} else if ([choice isEqualToString:@"Purple"]) {
self.subtitleLabel.textColor = [UIColor purpleColor];
}
}];
```
### Multivariate Test
```objective-c
[SkyLab multivariateTestWithName:@"Switches" variables:@{
@"Left" : @(0.5),
@"Center" : @(0.5),
@"Right" : @(0.5)
} block:^(NSSet *activeVariables) {
self.leftSwitch.on = [activeVariables containsObject:@"Left"];
self.centerSwitch.on = [activeVariables containsObject:@"Center"];
self.rightSwitch.on = [activeVariables containsObject:@"Right"];
}];
```
## License
SkyLab is available under the MIT license. See the LICENSE file for more info.
================================================
FILE: SkyLab/SkyLab.h
================================================
// SkyLab.h
//
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
//
// 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.
#import <Foundation/Foundation.h>
/**
SkyLab is a backend-agnostic framework for multivariate and A/B testing.
The first time a test is run, the user will be randomly assigned to one of the specified conditions. These assignments are persisted across sessions and launches using `NSUserDefaults`, ensuring that each user will have a consistent experience.
*/
@interface SkyLab : NSObject
/**
Run an A/B test in which the user is randomly assigned to execute `A` or `B`.
@param name A unique identifier for the test.
@param A A block to be executed for users assigned to the A condition. The block has no return value and takes no arguments.
@param B A block to be executed for users assigned to the B condition. The block has no return value and takes no arguments.
*/
+ (void)abTestWithName:(NSString *)name
A:(void (^)())A
B:(void (^)())B;
/**
Run a split test in which the user is randomly assigned to one of the specified conditions.
@param name A unique identifier for the test.
@param conditions The possible conditions for the user to be assigned. If this parameter is an `NSDictionary`, a weighted probability can be set as an `NSNumber` value for each condition. Otherwise, each condition will have the same probability of being assigned.
@param block A block to be executed when the test is run. The block has no return value and takes a single argument: the assigned condition.
*/
+ (void)splitTestWithName:(NSString *)name
conditions:(id <NSFastEnumeration>)conditions
block:(void (^)(id condition))block;
/**
@warning This method has been deprecated in favor of `splitTestWithName:conditions:block:`
*/
+ (void)splitTestWithName:(NSString *)name
choices:(id)choices
block:(void (^)(id choice))block DEPRECATED_ATTRIBUTE;
/**
Run a multivariate test in which the user is randomly assigned to a combination of specified variables.
@param name A unique identifier for the test.
@param variables The possible variables for the user to be assigned. If this parameter is an `NSDictionary`, a weighted probability can be set as an `NSNumber` value for each variable. Otherwise, each variable will have an even chance (`p = 0.5`) of being assigned.
@param block A block to be executed when the test is run. The block has no return value and takes a single argument: the variables assigned to the user.
*/
+ (void)multivariateTestWithName:(NSString *)name
variables:(id <NSFastEnumeration>)variables
block:(void (^)(NSSet *assignedVariables))block;
/**
Reset a particular test, by clearing any previous assignments for the user.
@param name A unique identifier for the test.
*/
+ (void)resetTestNamed:(NSString *)name;
@end
///--------------------
/// @name Notifications
///--------------------
/**
`SkyLabWillRunTestNotification`
Posted before a SkyLab test is run. The object is the test name, and `userInfo` contains either the condition at `SkyLabConditionKey` for a split test or active variables at `SkyLabActiveVariablesKey` for a multivariate test.
`SkyLabDidRunTestNotification`
Posted after a SkyLab test is run. The object is the test name, and `userInfo` contains either the condition at `SkyLabConditionKey` for a split test or active variables at `SkyLabActiveVariablesKey` for a multivariate test.
`SkyLabDidResetTestNotification`
Posted when a test is reset. The object is the test name.
*/
extern NSString * const SkyLabWillRunTestNotification;
extern NSString * const SkyLabDidRunTestNotification;
extern NSString * const SkyLabDidResetTestNotification;
///----------------
/// @name Constants
///----------------
/**
`SkyLabConditionKey`
The `userInfo` key associated with the assigned condition for `SkyLabWillRunTestNotification` or `SkyLabDidRunTestNotification` notifications posted by a split test.
`SkyLabConditionKey`
The `userInfo` key associated with the active variables for `SkyLabWillRunTestNotification` or `SkyLabDidRunTestNotification` notifications posted by a multivariate test.
*/
extern NSString * const SkyLabChoiceKey DEPRECATED_ATTRIBUTE;
extern NSString * const SkyLabConditionKey;
extern NSString * const SkyLabActiveVariablesKey;
================================================
FILE: SkyLab/SkyLab.m
================================================
// SkyLab.m
//
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
//
// 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.
#import "SkyLab.h"
#include <stdlib.h>
NSString * const SkyLabWillRunTestNotification = @"SkyLabWillRunTestNotification";
NSString * const SkyLabDidRunTestNotification = @"SkyLabDidRunTestNotification";
NSString * const SkyLabDidResetTestNotification = @"SkyLabDidResetTestNotification";
NSString * const SkyLabConditionKey = @"com.skylab.condition";
NSString * const SkyLabActiveVariablesKey = @"com.skylab.active-variables";
#define SkyLabChoiceKey SkyLabConditionKey
static NSString * SLUserDefaultsKeyForTestName(NSString *name) {
static NSString * const kSLUserDefaultsKeyFormat = @"SkyLab-%@";
return [NSString stringWithFormat:kSLUserDefaultsKeyFormat, name];
}
static id SLRandomValueFromArray(NSArray *array) {
if ([array count] == 0) {
return nil;
}
return [array objectAtIndex:(NSUInteger)arc4random_uniform([array count])];
}
static dispatch_once_t srand48OnceToken;
static id SLRandomKeyFromDictionaryWithWeightedValues(NSDictionary *dictionary) {
if ([dictionary count] == 0) {
return nil;
}
NSArray *keys = [dictionary allKeys];
NSMutableArray *mutableWeightedSums = [NSMutableArray arrayWithCapacity:[keys count]];
double total = 0.0;
for (id key in keys) {
total += [dictionary[key] doubleValue];
[mutableWeightedSums addObject:@(total)];
}
dispatch_once(&srand48OnceToken, ^{
srand48(time(0));
});
double r = drand48() * total;
__block id randomObject = nil;
[mutableWeightedSums enumerateObjectsUsingBlock:^(NSNumber *cumulativeWeightedSum, NSUInteger idx, BOOL *stop) {
if (r <= [cumulativeWeightedSum doubleValue]) {
randomObject = keys[idx];
*stop = YES;
}
}];
return randomObject;
}
static BOOL SLRandomBinaryChoiceWithProbability(double p) {
dispatch_once(&srand48OnceToken, ^{
srand48(time(0));
});
return drand48() <= p;
}
static BOOL SLRandomBinaryChoice() {
return SLRandomBinaryChoiceWithProbability(0.5);
}
@implementation SkyLab
+ (void)abTestWithName:(NSString *)name
A:(void (^)())A
B:(void (^)())B
{
[self splitTestWithName:name conditions:[NSArray arrayWithObjects:@"A", @"B", nil] block:^(NSString *choice) {
if ([choice isEqualToString:@"A"] && A) {
A();
} else if ([choice isEqualToString:@"B"] && B) {
B();
}
}];
}
+ (void)splitTestWithName:(NSString *)name
choices:(id)choices
block:(void (^)(id choice))block
{
[self splitTestWithName:name conditions:(id <NSFastEnumeration>)choices block:block];
}
+ (void)splitTestWithName:(NSString *)name
conditions:(id <NSFastEnumeration>)conditions
block:(void (^)(id))block;
{
id condition = [[NSUserDefaults standardUserDefaults] objectForKey:SLUserDefaultsKeyForTestName(name)];
if ([(id <NSObject>)conditions isKindOfClass:[NSDictionary class]]) {
if (!condition || ![[(NSDictionary *)conditions allKeys] containsObject:condition]) {
condition = SLRandomKeyFromDictionaryWithWeightedValues((NSDictionary *)conditions);
}
} else {
BOOL containsCondition = NO;
NSMutableArray *mutableCandidates = [NSMutableArray array];
for (id candidate in conditions) {
[mutableCandidates addObject:candidate];
containsCondition = containsCondition || [condition isEqual:candidate];
}
if (!condition || !containsCondition) {
condition = SLRandomValueFromArray(mutableCandidates);
}
}
BOOL needsSynchronization = ![condition isEqual:[[NSUserDefaults standardUserDefaults] objectForKey:SLUserDefaultsKeyForTestName(name)]];
[[NSUserDefaults standardUserDefaults] setObject:condition forKey:SLUserDefaultsKeyForTestName(name)];
if (needsSynchronization) {
[[NSUserDefaults standardUserDefaults] synchronize];
}
if (block) {
NSDictionary *userInfo = @{SkyLabConditionKey: condition};
[[NSNotificationCenter defaultCenter] postNotificationName:SkyLabWillRunTestNotification object:name userInfo:userInfo];
block(condition);
[[NSNotificationCenter defaultCenter] postNotificationName:SkyLabDidRunTestNotification object:name userInfo:userInfo];
}
}
+ (void)multivariateTestWithName:(NSString *)name
variables:(id <NSFastEnumeration>)variables
block:(void (^)(NSSet *assignedVariables))block
{
NSSet *activeVariables = [NSSet setWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:SLUserDefaultsKeyForTestName(name)]];
if ([(id <NSObject>)variables isKindOfClass:[NSDictionary class]]) {
if (!activeVariables || ![activeVariables isKindOfClass:[NSSet class]] || ![activeVariables intersectsSet:[NSSet setWithArray:[(NSDictionary *)variables allKeys]]]) {
NSMutableSet *mutableActiveVariables = [NSMutableSet setWithCapacity:[(NSDictionary *)variables count]];
[(NSDictionary *)variables enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if (SLRandomBinaryChoiceWithProbability([obj doubleValue])) {
[mutableActiveVariables addObject:key];
}
}];
activeVariables = mutableActiveVariables;
}
} else {
NSMutableSet *mutableActiveVariables = [NSMutableSet set];
for (id variable in variables) {
if ([activeVariables containsObject:variable] || SLRandomBinaryChoice()) {
[mutableActiveVariables addObject:variable];
}
}
activeVariables = mutableActiveVariables;
}
BOOL needsSynchronization = ![activeVariables isEqualToSet:[NSSet setWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:SLUserDefaultsKeyForTestName(name)]]];
[[NSUserDefaults standardUserDefaults] setObject:[activeVariables allObjects] forKey:SLUserDefaultsKeyForTestName(name)];
if (needsSynchronization) {
[[NSUserDefaults standardUserDefaults] synchronize];
}
if (block) {
NSDictionary *userInfo = @{SkyLabActiveVariablesKey: activeVariables};
[[NSNotificationCenter defaultCenter] postNotificationName:SkyLabWillRunTestNotification object:name userInfo:userInfo];
block(activeVariables);
[[NSNotificationCenter defaultCenter] postNotificationName:SkyLabDidRunTestNotification object:name userInfo:userInfo];
}
}
+ (void)resetTestNamed:(NSString *)name {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:SLUserDefaultsKeyForTestName(name)];
[[NSUserDefaults standardUserDefaults] synchronize];
[[NSNotificationCenter defaultCenter] postNotificationName:SkyLabDidResetTestNotification object:name];
}
@end
================================================
FILE: SkyLab.podspec
================================================
Pod::Spec.new do |s|
s.name = 'SkyLab'
s.version = '1.0.0'
s.license = 'MIT'
s.summary = 'Multivariate & A/B Testing for iOS and Mac.'
s.homepage = 'https://github.com/mattt/SkyLab'
s.social_media_url = 'https://twitter.com/mattt'
s.authors = { 'Mattt' => 'mattt@me.com' }
s.source = { :git => 'https://github.com/mattt/SkyLab.git', :tag => '1.0.0' }
s.source_files = 'SkyLab/*.{h,m}'
s.requires_arc = true
s.ios.deployment_target = '5.1'
end
================================================
FILE: SkyLab.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<Group
location = "group:SkyLab"
name = "SkyLab">
<FileRef
location = "group:SkyLab.h">
</FileRef>
<FileRef
location = "group:SkyLab.m">
</FileRef>
</Group>
<FileRef
location = "group:Example/SkyLab Example.xcodeproj">
</FileRef>
</Workspace>
gitextract_sqd19qz7/
├── Example/
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Info.plist
│ ├── Prefix.pch
│ ├── SkyLab Example.xcodeproj/
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace/
│ │ └── contents.xcworkspacedata
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── en.lproj/
│ │ ├── InfoPlist.strings
│ │ └── ViewController.xib
│ └── main.m
├── LICENSE
├── README.md
├── SkyLab/
│ ├── SkyLab.h
│ └── SkyLab.m
├── SkyLab.podspec
└── SkyLab.xcworkspace/
└── contents.xcworkspacedata
Condensed preview — 17 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (55K chars).
[
{
"path": "Example/AppDelegate.h",
"chars": 1380,
"preview": "// AppDelegate.h\n//\n// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)\n//\n// Permission is hereby granted, free of "
},
{
"path": "Example/AppDelegate.m",
"chars": 3258,
"preview": "// AppDelegate.m\n//\n// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)\n//\n// Permission is hereby granted, free of "
},
{
"path": "Example/Info.plist",
"chars": 1166,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "Example/Prefix.pch",
"chars": 223,
"preview": "#import <Availability.h>\n\n#ifndef __IPHONE_4_0\n#warning \"This project uses features only available in iOS SDK 4.0 and la"
},
{
"path": "Example/SkyLab Example.xcodeproj/project.pbxproj",
"chars": 14077,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "Example/SkyLab Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
"chars": 159,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"self:SkyLab Example."
},
{
"path": "Example/ViewController.h",
"chars": 1568,
"preview": "// ViewController.h\n//\n// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)\n//\n// Permission is hereby granted, free "
},
{
"path": "Example/ViewController.m",
"chars": 3289,
"preview": "// ViewController.m\n//\n// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)\n//\n// Permission is hereby granted, free "
},
{
"path": "Example/en.lproj/InfoPlist.strings",
"chars": 45,
"preview": "/* Localized versions of Info.plist keys */\n\n"
},
{
"path": "Example/en.lproj/ViewController.xib",
"chars": 7177,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\" versi"
},
{
"path": "Example/main.m",
"chars": 353,
"preview": "//\n// main.m\n// SkyLab Example\n//\n// Created by Mattt Thompson on 2012/09/05.\n// Copyright (c) 2012年 Mattt Thompson."
},
{
"path": "LICENSE",
"chars": 1073,
"preview": "Copyright (c) 2012 – 2021 Mattt (https://mat.tt)\n\nPermission is hereby granted, free of charge, to any person obtaining "
},
{
"path": "README.md",
"chars": 3091,
"preview": "> This library is no longer being maintained.\n> You can continue to use SkyLab in your projects,\n> but we recommend swit"
},
{
"path": "SkyLab/SkyLab.h",
"chars": 5451,
"preview": "// SkyLab.h\n//\n// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)\n//\n// Permission is hereby granted, free of charg"
},
{
"path": "SkyLab/SkyLab.m",
"chars": 8066,
"preview": "// SkyLab.m\n//\n// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)\n//\n// Permission is hereby granted, free of charg"
},
{
"path": "SkyLab.podspec",
"chars": 475,
"preview": "Pod::Spec.new do |s|\n s.name = 'SkyLab'\n s.version = '1.0.0'\n s.license = 'MIT'\n s.summary = 'Multivariate & "
},
{
"path": "SkyLab.xcworkspace/contents.xcworkspacedata",
"chars": 385,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <Group\n location = \"group:SkyLab\"\n na"
}
]
About this extraction
This page contains the full source code of the mattt/SkyLab GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 17 files (50.0 KB), approximately 13.7k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.