Subscribed unsubscribe Subscribe Subscribe

JPMartha's Pancake

This blog is the way to brush up my poor English.

Xcode でのビルドと xcodebuild コマンドでのビルドの違い 👐

Xcode OS X iOS

こちらの記事 で書きましたが、xcodebuild コマンドでビルドしたときプロジェクトフォルダ直下に build フォルダが生成されるのが気になった ので Xcode でのビルドログと比較しました。

前提

  • 作成中の 自作ツール での話です。(進捗なし 🙈)
  • diff コマンドで比較すると順序の違いなども多く検出されるため目で比較しました。👀
  • 見やすくするため実際のフォーマットから少し変更しました。
  • すべてを比較するのは大変なので 大きく異なる部分と検索しやすい PancakeKit.framework.dSYM を対象 にしました。
  • コマンドオプションの説明は雑です。

github.com

フレームワークのビルド

Xcode

  • xcconfig を中身ごと(-r)有無を言わさず(-f)削除します。(rm
  • .gitignore を中身ごと(-r)有無を言わさず(-f)削除します。(rm
Build target PancakeKit of project Pancake with configuration Release

Remove stale build products

    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Test.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Profile.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/iOS-Base.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/iOS-Framework.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Release.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Common.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Mac-Framework.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/iOS-StaticLibrary.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Mac-Base.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Debug.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Mac-StaticLibrary.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Mac-Application.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Mac-DynamicLibrary.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Application.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/.gitignore
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/iOS-Application.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/Framework.xcconfig
    /bin/rm -rf /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/Resources/StaticLibrary.xcconfig

xcodebuild コマンド

  • "Write auxiliary files" を雑に訳すと「補助ファイル書き込み」です。
  • ディレクトリを階層ごと(-p)作成します。(mkdir
  • シンボリックリンクを(-s)強制的に(-f)(-h*1)作成します。(ln
=== BUILD TARGET PancakeKit OF PROJECT Pancake WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
/bin/mkdir -p /.../Pancake/build/Pancake.build/Release/PancakeKit.build/DerivedSources
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/DerivedSources/PancakeKit_vers.c
write-file /.../Pancake/build/Pancake.build/all-product-headers.yaml
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/swift-overrides.hmap
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/module.modulemap
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/PancakeKit-generated-files.hmap
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/PancakeKit-all-target-headers.hmap
/bin/mkdir -p /.../Pancake/build/Pancake.build/Release/PancakeKit.build/Objects-normal/x86_64
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/Objects-normal/x86_64/PancakeKit.LinkFileList
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/PancakeKit.hmap
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/PancakeKit-all-non-framework-target-headers.hmap
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/PancakeKit-own-target-headers.hmap
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/PancakeKit-project-headers.hmap
write-file /.../Pancake/build/Pancake.build/Release/PancakeKit.build/Objects-normal/x86_64/PancakeKit-OutputFileMap.json

Create product structure
/bin/mkdir -p /.../Pancake/build/Release/PancakeKit.framework/Versions/A/Modules
/bin/ln -sfh Versions/Current/Modules /.../Pancake/build/Release/PancakeKit.framework/Modules
/bin/mkdir -p /.../Pancake/build/Release/PancakeKit.framework/Versions/A/Headers
/bin/mkdir -p /.../Pancake/build/Release/PancakeKit.framework/Versions/A/Resources
/bin/ln -sfh A /.../Pancake/build/Release/PancakeKit.framework/Versions/Current
/bin/ln -sfh Versions/Current/Resources /.../Pancake/build/Release/PancakeKit.framework/Resources
/bin/ln -sfh Versions/Current/Headers /.../Pancake/build/Release/PancakeKit.framework/Headers
/bin/ln -sfh Versions/Current/PancakeKit /.../Pancake/build/Release/PancakeKit.framework/PancakeKit

PancakeKit.framework.dSYM の生成

  • それぞれパスが異なります。
  • ⚠️ -o はわかりません。🙈(そろそろ try! Swift の準備を💨)

Xcode

GenerateDSYMFile
    /.../DerivedData/.../Build/Products/Release/PancakeKit.framework.dSYM
    /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/PancakeKit

    cd /.../Pancake
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil
    /.../DerivedData/.../Build/Products/Release/PancakeKit.framework/Versions/A/PancakeKit
    -o
    /.../DerivedData/.../Build/Products/Release/PancakeKit.framework.dSYM

xcodebuild コマンド

GenerateDSYMFile
    build/Release/PancakeKit.framework.dSYM
    build/Release/PancakeKit.framework/Versions/A/PancakeKit

    cd /.../Pancake
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil
    /.../Pancake/build/Release/PancakeKit.framework/Versions/A/PancakeKit
    -o
    /.../Pancake/build/Release/PancakeKit.framework.dSYM

コマンドラインツールのビルド

Xcode

  • ディレクトリを階層ごと(-p)作成します。(mkdir
Build target pancake of project Pancake with configuration Release

Create product structure

/bin/mkdir -p /.../DerivedData/.../Build/Products/Release/pancake.app/Contents
/bin/mkdir -p /.../DerivedData/.../Build/Products/Release/pancake.app/Contents/MacOS

xcodebuild コマンド

  • "Write auxiliary files" を雑に訳すと「補助ファイル書き込み」です。
  • 読み込みと実行は全員で書き込みは所有者のみに(0755)アクセス権を変更します。(chmod
  • ディレクトリを階層ごと(-p)作成します。(mkdir
=== BUILD TARGET pancake OF PROJECT Pancake WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files

write-file /.../Pancake/build/Pancake.build/Release/pancake.build/swift-overrides.hmap
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/pancake.hmap
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/Script-2E5026581C6192B6004AE29B.sh
chmod 0755 /.../Pancake/build/Pancake.build/Release/pancake.build/Script-2E5026581C6192B6004AE29B.sh
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/pancake-project-headers.hmap
/bin/mkdir -p /.../Pancake/build/Pancake.build/Release/pancake.build/DerivedSources
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/DerivedSources/pancake_vers.c
/bin/mkdir -p /.../Pancake/build/Pancake.build/Release/pancake.build/Objects-normal/x86_64
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/Objects-normal/x86_64/pancake.LinkFileList
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/Objects-normal/x86_64/pancake-OutputFileMap.json
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/pancake-all-non-framework-target-headers.hmap
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/pancake-generated-files.hmap
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/pancake-own-target-headers.hmap
write-file /.../Pancake/build/Pancake.build/Release/pancake.build/pancake-all-target-headers.hmap

Create product structure
/bin/mkdir -p /.../Pancake/build/Release/pancake.app/Contents
/bin/mkdir -p /.../Pancake/build/Release/pancake.app/Contents/MacOS

参考

*1:If the target_file or target_dir is a symbolic link, do not follow it. This is most useful with the -f option, to replace a symlink which may point to a directory.