How to build a release version of an iOS framework in Xcode?

后端 未结 4 1794
离开以前
离开以前 2021-01-31 09:05

Let\'s say I do the following:

  1. Open Xcode 7
  2. File | New | Project | Cocoa Touch Framework
  3. Create \"TestFramework\" with the Swift language
4条回答
  •  忘了有多久
    2021-01-31 09:51

    An alternative to building a framework via the Xcode IDE is to build it from the command line.

    You can produce a release build of your framework for iphoneos devices with the following command:

    xcodebuild -workspace TestSDK.xcworkspace -scheme TestSDK -configuration Release -sdk iphoneos
    

    You can change the value of the -configuration argument from Release to Debug in order to produce a debug build, or change the value of the -sdk argument from iphoneos to iphonesimulator in order to produce a build for Simulator devices.

    Note that you may need to provide the -project argument instead of -workspace if your target is part of an Xcode project only and not part of an Xcode workspace. Run the xcodebuild -help command for the full list of xcodebuild options.

    If you prefer to archive, you can do that from the command line also, as follows:

    xcodebuild archive -workspace TestSDK.xcworkspace -scheme TestSDK -configuration Release -sdk iphoneos -archivePath "TestSDK_Release_iphoneos.xcarchive" SKIP_INSTALL=NO
    

    Note that you can specify SKIP_INSTALL=NO as part of your project or target's Build Settings instead if you prefer.

    Lastly, if you want to join up your iphoneos and iphonesimulator builds into a single binary, you can do that with the xcodebuild -create-xcframework command as follows:

    xcodebuild -create-xcframework \
        -framework "TestSDK_Release_iphoneos.xcarchive/Products/Library/Frameworks/TestSDK.framework" \
        -framework "TestSDK_Release_iphonesimulator.xcarchive/Products/Library/Frameworks/TestSDK.framework" \
        -output "TestSDK.xcframework"
    

    See here for the official guide to creating an XCFramework.

提交回复
热议问题