IOS SDK from development to release
Recently, I have been doing the work of packaging SDK (Framework). This article will record the specific process and experience summary of iOS SDK from development to release. This article is mainly in the form of images, after all, images are king, the code can be downloaded on Github link.
First, this section describes the specific process of creating the SDK project and corresponding Demo project.
Create SDK project
Create a workspace to manage the SDK and Demo project
Create the Cocoa Touch Framework and add it to the workspace you created earlier
Changing Project Settings
-
Change Info -> Development Target to target system version
-
Confirm that Target -> Build Settings -> Mach -o Type is Dynamic
-
Change Target -> Build Settings -> Build Active Architchture Only to NO
-
Change Target -> Build Settings -> Bitcode to NO
-
Change the Edit Scheme -> Run -> Build Configuration to Release
Configure the public header file
-
Adding test code
-
Set the test class header file.h to public
-
Introduce all public header files in the mframework.h file
Creating a Demo Project
Create the MDemo Project and join the workspace you created earlier.
Change MDemo project Settings
Integrate SDK testing
-
Configure Linked Framework and Embeded Binaries as MFramework in Target -> General
-
Call MFramework’s test code, and console prints as expected
Local packaging manual publishing
Create the Aggregate of cross-platform, execute the build script, and synthesize the SDK products of the simulator architecture previously built and the SDK products of the real machine into the SDK products suitable for the real machine and the simulator through lipo command
-
Create an Aggregate for cross-platform
-
Modify Configuration, add Dependency and Build Script
-
Script code
TARGET_NAME=${PROJECT_NAME} OUTPUT_DIR=${SRCROOT}/Products/${TARGET_NAME}.framework DEVICE_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphoneos/${TARGET_NAME}.framework SIMULATOR_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework if [ -d "${OUTPUT_DIR}" ] then rm -rf "${OUTPUT_DIR}" fi mkdir -p "${OUTPUT_DIR}" cp -R "${DEVICE_DIR}/" "${OUTPUT_DIR}/" lipo -create "${DEVICE_DIR}/${TARGET_NAME}" "${SIMULATOR_DIR}/${TARGET_NAME}" -output "${OUTPUT_DIR}/${TARGET_NAME}" open "${SRCROOT}/Products" Copy the code
-
Emulator artifacts for building the MFramework
-
A real machine product of building the MFramework
-
Build MFrameworkCommon, which generates SDK artifacts that support simulators and real machines through Build scripts.
-
The MDemo project integrates the SDK product MFramework. Framework, adding Embedded Binaries and Linked Frameworks.
Continue to build automated publishing
Manual packaging for every release is cumbersome, labor-intensive, and prone to omissions and errors. Here’s how to achieve continuous build and automated release. Create the build script build.sh in the workspace root directory and run the script sudo./build.sh on the command line to create the result folder in the workspace root directory and generate the target artifacts. With the help of blue Shield and other continuous build platforms, the perfect operation of continuous build, automatic release and automatic archiving can be achieved.
-
Target product preview
-
Script code
# Environment variables
#version=$MajorVersion"."$MinorVersion"."$FixVersion"."$BuildNo
#shortVersion=$MajorVersion"."$MinorVersion"."$FixVersionVersion = 2.3.4.5 shortVersion = 2.3.4 xcworkspace ="DevFramework"
scheme="MFramework"
configuration="Release"
WORKSPACE=`pwd`
RESULT_DIR=$WORKSPACE/result
# Clean workspace
rm -r ~/Library/Developer/Xcode/Archives/`date +%Y-%m-%d`/$scheme\ *.xcarchive
xcodebuild clean -workspace $xcworkspace.xcworkspace -scheme $scheme -configuration $configuration
# Update version number
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $version" $scheme/$scheme/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $shortVersion" $scheme/$scheme/Info.plist
Build the framework of the real machine and emulator separately
xcodebuild -workspace $xcworkspace.xcworkspace -scheme $scheme -configuration $configuration ONLY_ACTIVE_ARCH=NO -sdk iphoneos BUILD_DIR="$RESULT_DIR" BUILD_ROOT="${BUILD_ROOT}" clean build
if! [$? = 0];then
echo "xcodebuild iphoneos fail"
exit 1
fi
xcodebuild -workspace $xcworkspace.xcworkspace -scheme $scheme -configuration $configuration ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator BUILD_DIR="$RESULT_DIR" BUILD_ROOT="${BUILD_ROOT}" clean build
if! [$? = 0];then
echo "xcodebuild iphonesimulator fail"
exit 1
fi
Output the framework applicable to both real and emulator to the result directory
cp -R "$RESULT_DIR/${configuration}-iphoneos/${scheme}.framework/" "$RESULT_DIR/${scheme}_${version}.framework/"
lipo -create "$RESULT_DIR/$configuration-iphonesimulator/${scheme}.framework/${scheme}" "$RESULT_DIR/${configuration}-iphoneos/${scheme}.framework/${scheme}" -output "$RESULT_DIR/${scheme}_${version}.framework/${scheme}"
if! [$? = 0];then
echo "lipo create framework fail"
exit 1
fi
Copy the code
Version Number Setting
The Framework must be configured with the version number, so that it is convenient for users (SDK users) to access the appropriate target version, but also conducive to the later problem location and development and maintenance. It is recommended that the version number be a major version. Feature version Modified version. Continuous build number. For details on how to configure this number, see Automatic Release of Continuous Build above.
conclusion
As you can see here, the basic process from iOS SDK development to release has been completed. Of course, the SDK development work is far more than these, more pit and experience depends on the big guy summary and share, HHHH, first here ~