Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Buck to save iOS project build time

Qing-Cheng Li
September 22, 2019

Using Buck to save iOS project build time

This is slides for presentation of "Using Buck to save iOS project build time" on iPlayground 2019.

Buck is a fast build tool from Facebook, this slides goes through what is buck and how to write minimal settings and build file to build an iOS project.

Qing-Cheng Li

September 22, 2019
Tweet

More Decks by Qing-Cheng Li

Other Decks in Programming

Transcript

  1. • • Cmd + Shift + K • • ⏲

    • • $ rm -rf ~/Library/Developer/Xcode/DerivedData • • ⏲ •
  2. [cxx] default_platform = iphonesimulator-x86_64 cflags = -g -fmodules -fobjc-arc cxxflags

    = -fobjc-arc -std=c++14 combind_preprecess_and_compile = true pch_enabled = false [swift] compiler_flags = -whole-module-optimization use_filelist = true
  3. [apple] use_swift_delegate = false use_header_maps_in_xcode = false generate_missing_umbrella_headers = true

    iphonesimulator_target_sdk_version = 11.0 iphoneos_target_sdk_version = 11.0 provisioning_profile_read_command = security cms -Di xctool_default_destination_specifier = platform=iOS Simulator,OS=latest xctool_path = tools/xctool/bin/xctool
  4. • • • • ◦ //App: $project_root/App apple_asset_catelog( name =

    “QCourseAssets”, visibility = [ “//App:”, ], app_icon = “AppIcon”, dirs = [ “Assets.xcassets” ] )
  5. • • glob apple_resource( name = “QCourseResource”, visibility = [“

    “//App:”, ”], files = glob([“**/*.storyboard”]) )
  6. • • srcs • • • apple_binary( name = “QCourseAppBinary”,

    visibility: [ “//App:”, “//App/...” ], swift_version = “5”, configs = app_binary_config(“QCourse”), srcs = [ “AppDelegate.swift”, “ViewController.swift”, ], deps: [ “:QCourseAppResource”, “:QCourseAssets” ] )
  7. • def app_binary_config(name): conifg = { IPHONEOS_DEPLOYMENT_TARGET : “11.0”, PRODUCT_BUNDLE_IDENTIFIER:

    bundle_identifier(name), ... } # do something return { “Debug”: config, “Profile”: config, “Release”: config }
  8. • srcs • headers • bridging_header apple_binary( ... srcs =

    [ "GeoUtils.m", ], bridging_header = "QCourse-Bridging-Header.h", headers = [ "GeoUtils.h" ], ... )
  9. • • info.plist apple_bundle( name = "QCourse", visibility = ["//App:"],

    extension = "app", binary = ":QCourseAppBinary", product_name = "QCourseApp", info_plist = "Info.plist", info_plist_substitutions = info_plist_substitutions("QCourseApp"), )
  10. • $ buck build //App:QCourse • $ buck build //App:QCoursePackage

    • $ buck install //App:QCourse --run --simulator-name ‘iPhone Xs’ • /buck-out
  11. • • integerate_targets false • BUCK platform :ios, '11.0' install!

    'cocoapods', integrate_targets: false target 'QCourse' do pod 'AppDevKit/AppDevCommonKit' end
  12. • apple_libiary() • modular True • exported_headers • srcs •

    apple_library( name = “AppDevKit”, visibility = [“PUBLIC”], modular = True, exported_headers = glob([“AppDevKit/**/*.h”]), srcs = glob([“AppDevKit/**/*.m”]), configs = library_configs(), )
  13. • BCUK • BUCK apple_binary( name = “QCourseAppBinary”, deps: [

    “:QCourseAppResource”, “:QCourseAssets”, # Pods “//Pods:AppDevKit”, ] )
  14. • • apple_bundle( ... test: [ “:QCourseUnitTest”, ]. ) apple_test(

    name = “QCourseUnitTest”, visibility = [“PUBLIC”], info_plist = “UnitTests/Info.plist”, info_plist_substitutions = { … }, is_ui_test = False, frameworks = [ “$PLATFORM_DIR/Developer/Library/Fram eworks/XCTest.framework" ], srcs = [“UnitTests/QCourseTests.swift”] )
  15. • • src_target $ buck project //App:QCourseWorkspace xcode_workspace_config( name =

    "QCourseWorkspace", workspace_name = "QCourse", src_target = ":QCourse", )