Permalink
Browse files

Provide developers script they can use to get a static library versio…

…n of the

iOS SDK

Summary:
For developers who are building apps with Automatic Reference Counting
enabled using our current iOS SDK will produce errors. One solution is to
provide a static library version of our SDK that they can include in their
project. We could provide detailed documentation to do this but it is easier to
provide a script that they can run. This diff introduces this script. We
considered actually packaging the desired library with the SDK but that would
involve a process change on our end because the current SDK development flow
does not include building a library. So for now we will push this on the
developer and perhaps in the future look at a more streamlined way to provide
this library to the developer.

Additionally, needed to make sure deployment target was set to iOS 3 for the
project.

Test Plan:
In terms of testing the script just run it a few times from various initial
locations, e.g.
% sh
/Users/caabernathy/Facebook/Code/iOS/StaticScriptTest/facebook-ios-sdk/scripts/build_facebook_ios_sdk_static_lib.sh

Also run it twice to see the output library properly overwritten

Once the library was produced, tested it worked well by doing the following
Scenario 1: Use the library with an app that does not have ARC enabled
1/ Built a simple app with Facebook SSO and a news feed dialog
2/ Tested SSO works and that the dialog UI has all the relevant resources and
works

Scenario 2: Use the library with an app with ARC enabled
1/ Built a simple app with Facebook SSO and a news feed dialog. (When creating
this app, made sure ARC was turned on)
2/ Tested SSO works and that the dialog UI has all the relevant resources and
works

Scenario 3: Switch out the Facebook SDK in the Hackbook sample app with this
library
1/ Removed the FBConnect folder from the Hackbook sample app
2/ Dragged in the new library, chose to copy the contents over
3/ Ran the app and went through all the flows. Note: Found some cases that do
not work that also appear to be broken in the current app, namely video upload,
and recent check-ins listing. These can be addressed separately.

Reviewers: yariv, jacl

Reviewed By: jacl

CC: mmarucheck, vijaye, selekman, brent

Differential Revision: https://phabricator.fb.com/D415047

Revert Plan: OK
  • Loading branch information...
1 parent 8ed244a commit 9acf74345bb248d698966eac9a3057a4b4be1b0f Christine Abernathy committed Feb 24, 2012
Showing with 88 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +84 −0 scripts/build_facebook_ios_sdk_static_lib.sh
  3. +2 −0 src/facebook-ios-sdk.xcodeproj/project.pbxproj
View
@@ -14,6 +14,8 @@ sample/Hackbook/Hackbook.xcodeproj/project.xcworkspace
src/facebook-ios-sdk.xcodeproj/*.pbxuser
src/facebook-ios-sdk.xcodeproj/*.mode*
src/build/
+build/
+lib/
test/UnitTest/UnitTest.xcodeproj/*.pbxuser
test/UnitTest/UnitTest.xcodeproj/*.mode*
test/UnitTest/build/
@@ -0,0 +1,84 @@
+#!/bin/sh
+#
+# Copyright 2004-present Facebook. All Rights Reserved.
+#
+
+# This script will build a static library version of the Facebook iOS SDK.
+# You may want to use this script if you have a project that has the
+# Automatic Reference Counting feature turned on. Once you run this script
+# you will get a directory under the iOS SDK project home path:
+# lib/facebook-ios-sdk
+# You can drag the facebook-ios-sdk directory into your Xcode project and
+# copy the contents over or include it as a reference.
+
+# Function for handling errors
+die() {
+ echo ""
+ echo "$*" >&2
+ exit 1
+}
+
+# The Xcode bin path
+XCODEBUILD_PATH=/Developer/usr/bin
+XCODEBUILD=$XCODEBUILD_PATH/xcodebuild
+
+# Get the script path and set the relative directories used
+# for compilation
+cd $(dirname $0)
+SCRIPTPATH=`pwd`
+cd $SCRIPTPATH/../
+
+# The home directory where the SDK is installed
+PROJECT_HOME=`pwd`
+
+echo "Project Home: $PROJECT_HOME"
+
+# The facebook-ios-sdk src directory path
+SRCPATH=$PROJECT_HOME/src
+
+# The directory where the target is built
+BUILDDIR=$PROJECT_HOME/build
+
+# The directory where the library output will be placed
+LIBOUTPUTDIR=$PROJECT_HOME/lib/facebook-ios-sdk
+
+echo "Start Universal facebook-ios-sdk SDK Generation"
+
+echo "Step 1 : facebook-ios-sdk SDK Build Library for simulator and device architecture"
+
+cd $SRCPATH
+
+$XCODEBUILD -target "facebook-ios-sdk" -sdk "iphonesimulator" -configuration "Release" SYMROOT=$BUILDDIR clean build || die "iOS Simulator build failed"
+$XCODEBUILD -target "facebook-ios-sdk" -sdk "iphoneos" -configuration "Release" SYMROOT=$BUILDDIR clean build || die "iOS Device build failed"
+
+echo "Step 2 : Remove older SDK Directory"
+
+\rm -rf $LIBOUTPUTDIR
+
+echo "Step 3 : Create new SDK Directory Version"
+
+mkdir -p $LIBOUTPUTDIR
+
+echo "Step 4 : Create combine lib files for various platforms into one"
+
+# combine lib files for various platforms into one
+lipo -create $BUILDDIR/Release-iphonesimulator/libfacebook_ios_sdk.a $BUILDDIR/Release-iphoneos/libfacebook_ios_sdk.a -output $LIBOUTPUTDIR/libfacebook_ios_sdk.a || die "Could not create static output library"
+
+echo "Step 5 : Copy headers Needed"
+\cp $SRCPATH/*.h $LIBOUTPUTDIR/
+\cp $SRCPATH/JSON/*.h $LIBOUTPUTDIR/
+
+echo "Step 6 : Copy other file needed like bundle"
+\cp -r $SRCPATH/*.bundle $LIBOUTPUTDIR
+
+echo "Finished Universal facebook-ios-sdk SDK Generation"
+echo ""
+echo "You can now use the static library that can be found at:"
+echo ""
+echo $LIBOUTPUTDIR
+echo ""
+echo "Just drag the facebook-ios-sdk directory into your project to include the Facebook iOS SDK static library"
+echo ""
+echo ""
+
+exit 0
@@ -281,6 +281,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.0;
OTHER_LDFLAGS = "-ObjC";
SDKROOT = iphoneos;
};
@@ -293,6 +294,7 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.0;
OTHER_LDFLAGS = "-ObjC";
SDKROOT = iphoneos;
};

0 comments on commit 9acf743

Please sign in to comment.