Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Package the source code into a static library #66

Closed
wants to merge 3 commits into from

4 participants

@zoul

I think the sources are easier to use when packaged into an Xcode project with a library target. (My primary target is iOS. If there are people using JSONKit on desktop Macs, it should be trivial to add a framework target to the project.)

One benefit is that you can bundle the tests along with the library, which should make development easier. The tests are currently run whenever the library gets built for the Simulator. (I have added one example test to the project to make it clear how things work.)

Another plus is that you don’t have to monkey around with ARC settings. If you have a project that uses ARC, you can link against the library that uses manual memory management just fine.

And a third advantage – that made me fork your code in the first place – is deployment in projects where the JSONKit code is used more than once. I have two libraries that both bundle the naked JSONKit sources and obviously I get a linker complaining about duplicate symbols. This should be easier to solve with a static library.

There are no drawbacks for people who don’t need the Xcode project, they can grab the naked sources as usually.

@zoul

I have written two blog posts (one, two) about static libraries and code reuse in Xcode; these might argue in better detail why static libraries are more useful than naked source files.

@MSchmidt

+1 especially for compatibility with ARC and non-ARC projects!

@ghost

ARC is a satan's abomination, if you want a static lib just use your lazy tiny fingers and write a simple makefile, this kind of request, that's just insane.

@MSchmidt

Whatever your opinion is on ARC, it would be a good thing for JSONKit to support both kinds of projects.

@ghost

if you read carefully the documentation about ARC there is no issue mixing both until you do the right thing, tagging your code with insane qualifiers which the compiler will just parse to put it back the perfect way it was..., just an insane man could have invented this stupidity, moreover developers want memory control not garbage at large, they want to see it in their code, if you disagree you should move back to scripting languages such as java or c#, the toys for the kids.

@zoul

If you don’t find the feature useful, please feel free to ignore this pull request.

@jonsterling

I find @cucurbita's ramblings rather difficult to decipher, though I can at least determine that they're quite unproductive. Here's my take:

If your project uses ARC, either package your own static library or specify that those particular files should not built with ARC (this is possible in Xcode's Build Phases).

In general, I prefer all my dependencies in static libraries, so I definitely see where you are coming from. However, I also happen to think it's really cool that JSONKit is distributed as minimally as it is. In fact, I think that's one of its more attractive attributes.

@escoz

+1 for static library. Clear separation between library code and application code makes it much easier to keep track of changes while still making it easy for people to stay in sync with project changes.

Congrats to @jonsterling for being so professional regarding @cucurbita's comment.

@ghost

@jonsterling shame is always a good motivation for redemption

@zoul zoul referenced this pull request in B-Sides/ELCImagePickerController
Closed

Convert project to static library #18

@zoul

OK, there’s obviously little motivation to merge.

@zoul zoul closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
371 JSONKit.xcodeproj/project.pbxproj
@@ -0,0 +1,371 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 0D70980C148772B4009D57EF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D70980B148772B4009D57EF /* Foundation.framework */; };
+ 0D70981A148772B4009D57EF /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D709819148772B4009D57EF /* SenTestingKit.framework */; };
+ 0D70981D148772B4009D57EF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D70980B148772B4009D57EF /* Foundation.framework */; };
+ 0D70983814877337009D57EF /* JSONKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D70983614877337009D57EF /* JSONKit.h */; };
+ 0D70983914877337009D57EF /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D70983714877337009D57EF /* JSONKit.m */; };
+ 0D70983A14877337009D57EF /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D70983714877337009D57EF /* JSONKit.m */; };
+ 0D70983C1487733C009D57EF /* Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 0D70983B1487733C009D57EF /* Prefix.pch */; };
+ 0D709842148774BE009D57EF /* SanityTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D709841148774BE009D57EF /* SanityTest.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 0D709843148775A3009D57EF /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 0D7097FF148772B4009D57EF /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 0D709817148772B4009D57EF;
+ remoteInfo = JSONKitTests;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+ 0D709808148772B4009D57EF /* libJSONKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJSONKit.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ 0D70980B148772B4009D57EF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 0D709818148772B4009D57EF /* JSONKitTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JSONKitTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 0D709819148772B4009D57EF /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
+ 0D70983614877337009D57EF /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSONKit.h; path = Source/JSONKit.h; sourceTree = SOURCE_ROOT; };
+ 0D70983714877337009D57EF /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JSONKit.m; path = Source/JSONKit.m; sourceTree = SOURCE_ROOT; };
+ 0D70983B1487733C009D57EF /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Prefix.pch; path = Source/Prefix.pch; sourceTree = SOURCE_ROOT; };
+ 0D70983D14877345009D57EF /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Prefix.pch; path = Tests/Prefix.pch; sourceTree = SOURCE_ROOT; };
+ 0D709841148774BE009D57EF /* SanityTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SanityTest.m; path = Tests/SanityTest.m; sourceTree = SOURCE_ROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 0D709805148772B4009D57EF /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 0D70980C148772B4009D57EF /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 0D709814148772B4009D57EF /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 0D70981A148772B4009D57EF /* SenTestingKit.framework in Frameworks */,
+ 0D70981D148772B4009D57EF /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 0D7097FD148772B4009D57EF = {
+ isa = PBXGroup;
+ children = (
+ 0D70980D148772B4009D57EF /* Source */,
+ 0D709821148772B4009D57EF /* Tests */,
+ 0D70980A148772B4009D57EF /* Frameworks */,
+ 0D709809148772B4009D57EF /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 0D709809148772B4009D57EF /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 0D709808148772B4009D57EF /* libJSONKit.a */,
+ 0D709818148772B4009D57EF /* JSONKitTests.octest */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 0D70980A148772B4009D57EF /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 0D70980B148772B4009D57EF /* Foundation.framework */,
+ 0D709819148772B4009D57EF /* SenTestingKit.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 0D70980D148772B4009D57EF /* Source */ = {
+ isa = PBXGroup;
+ children = (
+ 0D70983614877337009D57EF /* JSONKit.h */,
+ 0D70983714877337009D57EF /* JSONKit.m */,
+ 0D70983B1487733C009D57EF /* Prefix.pch */,
+ );
+ name = Source;
+ path = JSONKit;
+ sourceTree = "<group>";
+ };
+ 0D709821148772B4009D57EF /* Tests */ = {
+ isa = PBXGroup;
+ children = (
+ 0D709841148774BE009D57EF /* SanityTest.m */,
+ 0D70983D14877345009D57EF /* Prefix.pch */,
+ );
+ name = Tests;
+ path = JSONKitTests;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+ 0D709806148772B4009D57EF /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 0D70983814877337009D57EF /* JSONKit.h in Headers */,
+ 0D70983C1487733C009D57EF /* Prefix.pch in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+ 0D709807148772B4009D57EF /* JSONKit */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 0D70982C148772B4009D57EF /* Build configuration list for PBXNativeTarget "JSONKit" */;
+ buildPhases = (
+ 0D709804148772B4009D57EF /* Sources */,
+ 0D709805148772B4009D57EF /* Frameworks */,
+ 0D709806148772B4009D57EF /* Headers */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 0D709844148775A3009D57EF /* PBXTargetDependency */,
+ );
+ name = JSONKit;
+ productName = JSONKit;
+ productReference = 0D709808148772B4009D57EF /* libJSONKit.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+ 0D709817148772B4009D57EF /* JSONKitTests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 0D70982F148772B4009D57EF /* Build configuration list for PBXNativeTarget "JSONKitTests" */;
+ buildPhases = (
+ 0D709813148772B4009D57EF /* Sources */,
+ 0D709814148772B4009D57EF /* Frameworks */,
+ 0D709815148772B4009D57EF /* Resources */,
+ 0D709816148772B4009D57EF /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = JSONKitTests;
+ productName = JSONKitTests;
+ productReference = 0D709818148772B4009D57EF /* JSONKitTests.octest */;
+ productType = "com.apple.product-type.bundle";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 0D7097FF148772B4009D57EF /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
+ buildConfigurationList = 0D709802148772B4009D57EF /* Build configuration list for PBXProject "JSONKit" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 0D7097FD148772B4009D57EF;
+ productRefGroup = 0D709809148772B4009D57EF /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 0D709807148772B4009D57EF /* JSONKit */,
+ 0D709817148772B4009D57EF /* JSONKitTests */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 0D709815148772B4009D57EF /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 0D709816148772B4009D57EF /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 0D709804148772B4009D57EF /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 0D70983914877337009D57EF /* JSONKit.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 0D709813148772B4009D57EF /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 0D70983A14877337009D57EF /* JSONKit.m in Sources */,
+ 0D709842148774BE009D57EF /* SanityTest.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 0D709844148775A3009D57EF /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 0D709817148772B4009D57EF /* JSONKitTests */;
+ targetProxy = 0D709843148775A3009D57EF /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+ 0D70982A148772B4009D57EF /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ 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_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ 0D70982B148772B4009D57EF /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 0D70982D148772B4009D57EF /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DSTROOT = /tmp/JSONKit.dst;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = Source/Prefix.pch;
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ 0D70982E148772B4009D57EF /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DSTROOT = /tmp/JSONKit.dst;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = Source/Prefix.pch;
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+ 0D709830148772B4009D57EF /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(SDKROOT)/Developer/Library/Frameworks",
+ "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
+ );
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = Tests/Prefix.pch;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TEST_AFTER_BUILD = YES;
+ WRAPPER_EXTENSION = octest;
+ };
+ name = Debug;
+ };
+ 0D709831148772B4009D57EF /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(SDKROOT)/Developer/Library/Frameworks",
+ "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
+ );
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = Tests/Prefix.pch;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TEST_AFTER_BUILD = YES;
+ WRAPPER_EXTENSION = octest;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 0D709802148772B4009D57EF /* Build configuration list for PBXProject "JSONKit" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 0D70982A148772B4009D57EF /* Debug */,
+ 0D70982B148772B4009D57EF /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 0D70982C148772B4009D57EF /* Build configuration list for PBXNativeTarget "JSONKit" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 0D70982D148772B4009D57EF /* Debug */,
+ 0D70982E148772B4009D57EF /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 0D70982F148772B4009D57EF /* Build configuration list for PBXNativeTarget "JSONKitTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 0D709830148772B4009D57EF /* Debug */,
+ 0D709831148772B4009D57EF /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 0D7097FF148772B4009D57EF /* Project object */;
+}
View
7 JSONKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:JSONKit.xcodeproj">
+ </FileRef>
+</Workspace>
View
0  JSONKit.h → Source/JSONKit.h
File renamed without changes
View
0  JSONKit.m → Source/JSONKit.m
File renamed without changes
View
3  Source/Prefix.pch
@@ -0,0 +1,3 @@
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+#endif
View
4 Tests/Prefix.pch
@@ -0,0 +1,4 @@
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+ #import <SenTestingKit/SenTestingKit.h>
+#endif
View
16 Tests/SanityTest.m
@@ -0,0 +1,16 @@
+#import "JSONKit.h"
+
+@interface SanityTest : SenTestCase
+@end
+
+@implementation SanityTest
+
+- (void) testBasicJSONParsing
+{
+ id result = [@"{\"foo\": \"bar\"}" objectFromJSONString];
+ STAssertEqualObjects(result,
+ [NSDictionary dictionaryWithObject:@"bar" forKey:@"foo"],
+ @"Basic JSON parsing works.");
+}
+
+@end
Something went wrong with that request. Please try again.