swift build と Xcode での Build の違い

swift build と Xcode での Build の違い

Tokyo Server-Side Swift Meetup #4

0a86666ca90016b2a28289dda921b0d7?s=128

Toshihiro Morimoto

June 27, 2016
Tweet

Transcript

  1. swift build ͱ Xcode Ͱͷ Build ͷҧ͍ 2016/06/27 Tokyo Server-Side

    Swift Meetup #4 @dealforest Toshihro Morimoto
  2. ࣗݾ঺հ

  3. None
  4. ࠓ೔͓࿩͢͠Δ͜ͱ 1. Slimane Λ Build Ͱ͖ΔΑ͏ʹͳΔ·Ͱ 2. swift build ͱ

    Xcode Ͱͷ Build ͷҧ͍
  5. 1. Slimane Λ Build Ͱ͖ΔΑ͏ʹͳΔ·Ͱ

  6. None
  7. Slimane ͸ express ϥΠΫͳ server side swift framework Ͱ͢

  8. ׆ൃʹ։ൃ͞Ε͍ͯ·͢

  9. ͱΓ͋͑ͣ Terminal ͔Βͱ Xcode ͔Β Build Ͱ͖ΔΑ͏ʹ͠·ͨ͠

  10. ͦͷաఔΛͲ͏ͧ

  11. ઌʹݴ͓ͬͯ͘ͱ slimane-cli ͔Β࡞ͬͨϓϩδΣΫτ ͩͱ Build Ͱ͖·ͤΜͰͨ͠

  12. ࠓ͸ͳ͓ͬͨΈ͍ͨͰ͢ 2016/06/27 18:00

  13. https://github.com/noppoMan/Slimane/wiki/Install-Guide

  14. ࣄલ४උ • DEVELOPMENT-SNAPSHOT-2016-05-31-a ΛΠϯετʔϧ (commit ʹΑͬͯมΘΓ·͢) $ brew install libuv

    openssl hiredis $ brew link libuv --force $ brew link openssl --force $ brew link -f hiredis
  15. αʔόʔΛىಈ $ git clone https://github.com/noppoMan/Slimane-Fullstack $ cd Slimane-Fullstack $ make

    debug $ ./.build/debug/Example Slimane server is listening at 0.0.0.0:3000
  16. ֬ೝ $ curl http://localhost:3000 Welcome to Slimane!

  17. Terminal ͔Β͸؆୯Ͱ͢Ͷ

  18. ࣍͸ Xcode ͰϏϧυͯ͠Έ·͠ΐ͏

  19. swift package generate-xcodeproj

  20. ͜ΕΛ࣮ߦ͢Δͱ Xcode ͷϓϩδΣΫτ͕࡞ΒΕ·͢

  21. Xcode Ͱ SlimaneFullstack Λ։͘ $ swift package generate-xcodeproj $ open

    SlimaneFullstack.xcodeproj
  22. ஫ҙࣄ߲ͱͯ͠͸ Xcode 7.3.1 Ͱ͋Δඞཁ͕͋Γ·͢

  23. ஫ҙࣄ߲ͱͯ͠͸ Xcode 7.3.1 Ͱ͋Δඞཁ͕͋Γ·͢

  24. ʂʂʂʂʂʂʂʂʂ

  25. ͳΜͱͦͷ··Ͱ͸ Build Ͱ͖·ͤΜ

  26. ൵͍͠Ͱ͢Ͷ

  27. ͱ͍͏Θ͚Ͱ ยͬ୺͔ΒΤϥʔΛ௵͍͖ͯ͠·͢

  28. Xcode Ͱ Build Ͱ͖ΔΑ͏ʹͳΔ·Ͱ 1. 'uv.h' file not found 2.

    ld: library not found for -luv for architecture x86_64 3. ld: library not found for -lCURIParser for architecture x86_64
  29. 1. 'uv.h' file not found ͜Ε͸ઌ΄Ͳ Homebrew ͰೖΕͨϥΠϒϥϦͷ ϔομʔ͕ݟ͔ͭΒͳ͍ͷ͕ݪҼͰ͢

  30. Header Search Paths ʹ /usr/local/include Λ௥Ճ

  31. 2. ld: library not found for -luv for architecture x86_64

    ͜Ε͸ઌ΄Ͳ Homebrew ͰೖΕͨϥΠϒϥϦͷ dynamic library ͕ݟ͔ͭΒͳ͍ͷ͕ݪҼͰ͢
  32. Library Search Paths ʹ /usr/local/lib Λ௥Ճ

  33. 3. ld: library not found for -lCURIParser for architecture x86_64

    ͜Ε͸ SPM Ͱґଘ͍ͯ͠ΔϥΠϒϥϦʹؚ·ΕΔ dylib ͕Ϗϧυ࣌ʹղܾͰ͖ͳ͍ͷ͕ݪҼͰ͢
  34. 3. ld: library not found for -lCURIParser for architecture x86_64

    ͪΌΜͱղܾ͕࣌ؒͳ͔ͬͨͷͰɹɹɹɹɹɹɹ ࢑ఆରԠͱͳΓ·͢ Ұ౓ swift build Λ࣮ߦ͓ͯ͘͠ඞཁ͕͋Γ·͢ (slimane Ͱ͍͏ make debug ͷ͜ͱͰ͢)
  35. Library Search Paths ʹ $(SRCROOT)/.build/debug Λ௥Ճ

  36. ͜ΕͰΊͰͨ͘ Build Ͱ͖ΔΑ͏ʹͳΓ·ͨ͠

  37. ΊΜͲ͍͘͞Ͱ͢Ͷ

  38. Ͳ͏ͯ͜͠ͷΑ͏ͳ͕ࠩ ͰΔͷ͔ݟ͍͖ͯ·͠ΐ͏

  39. 2. swift build ͱ Xcode Ͱͷ Build ͷҧ͍

  40. swift build • ࣮ߦόΠφϦΛࣗ෼Ͱ࣮ߦ (./.build/debug/Example) • $(SRC_ROOT)/.build ௚ԼʹதؒϑΝΠϧ͕Ͱ͖Δ • ґଘϥΠϒϥϦ͸

    swiftc ͰίϯύΠϧ͠ -emit-executable Ͱ link ͍ͯ͠Δ
  41. Xcode • Xcode Ͱ target Λબ୒͍ͯ Run Ͱ࣮ߦ • DerivedData

    ௚ԼʹதؒϑΝΠϧ͕Ͱ͖Δ • ґଘϥΠϒϥϦ͸ dynamic framework Ͱ link ͍ͯ͠Δ • xcodebuild Ͱ΍ͬͯ΋ಉ͡ (CONFIGURATION_BUILD_DIR΋ಈ͘) xcodebuild build -project "SlimaneFullstack.xcodeproj" ɹɹ-scheme "Example" -configuration Debug ɹ ɹɹ-sdk macosx10.11 CONFIGURATION_BUILD_DIR=build
  42. so ͱ dylib ͱ framework ͸޿ٛͰಉ͡ (ͨͿΜ…)

  43. /Applications/Xcode-7.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -dynamiclib -isysroot /Applications/Xcode-7.3.1.app/Contents/Developer/Platforms/MacOSX.platform/ Developer/SDKs/MacOSX10.11.sdk -L/Users/dealforest/Library/Developer/Xcode/DerivedData/ SlimaneFullstack-bahaftgmcprmzfgeqgmkpxlvnuog/Build/Products/Debug -F/Users/dealforest/Library/Developer/

    Xcode/DerivedData/SlimaneFullstack-bahaftgmcprmzfgeqgmkpxlvnuog/Build/Products/Debug -filelist /Users/ dealforest/Library/Developer/Xcode/DerivedData/SlimaneFullstack-bahaftgmcprmzfgeqgmkpxlvnuog/Build/ Intermediates/SlimaneFullstack.build/Debug/URI.build/Objects-normal/x86_64/URI.LinkFileList -install_name @rpath/URI.framework/Versions/A/URI -Xlinker -rpath -Xlinker /Library/Developer/Toolchains/swift- DEVELOPMENT-SNAPSHOT-2016-05-31-a.xctoolchain/usr/lib/swift/macosx -mmacosx-version-min=10.10 - fobjc-link-runtime -L/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-05-31- a.xctoolchain/usr/lib/swift/macosx -Xlinker -add_ast_path -Xlinker /Users/dealforest/Library/Developer/Xcode/ DerivedData/SlimaneFullstack-bahaftgmcprmzfgeqgmkpxlvnuog/Build/Intermediates/SlimaneFullstack.build/ Debug/URI.build/Objects-normal/x86_64/URI.swiftmodule -framework C7 -framework CURIParser -framework String -single_module -Xlinker -dependency_info -Xlinker /Users/ dealforest/Library/Developer/Xcode/DerivedData/SlimaneFullstack-bahaftgmcprmzfgeqgmkpxlvnuog/Build/ Intermediates/SlimaneFullstack.build/Debug/URI.build/Objects-normal/x86_64/URI_dependency_info.dat -o / Users/dealforest/Library/Developer/Xcode/DerivedData/SlimaneFullstack-bahaftgmcprmzfgeqgmkpxlvnuog/ Build/Products/Debug/URI.framework/Versions/A/URI
  44. ld: library not found for -lCURIParser for architecture x86_64

  45. Ͳ͏ͯ͠ -framework Ͱ link ͠Α͏ͱ ͍ͯ͠Δͷʹ -l Λ͢Δͷ͔

  46. dylib ͱ framework ͕བྷΉͱ Ͳ͏΋͏·͍͜ͱ͍͔ͳ͍Έ͍ͨ

  47. ෼͔Δਓ͕͍Ε͹ڭ͍͑ͯͩ͘͞

  48. Ұॹʹߟ͑·͠ΐ͏

  49. ·ͱΊ ෳࡶͳґଘΛղܾ͢Δ৔߹͸ swift build Λૉ ௚ʹ࢖ͬͯ Build ͨ͠΄͏͕޾ͤʹͳΕ·͢ Xcode Ͱ΍ͬͯ΋͍͍Ͱ͕͢஍ཕ͸ଟ͍Ͱ͢

  50. ·ͱΊ swift package generate-xcodeproj ͕ ݡ͘ͳΔͷΛ଴͔ͭ PR ૹΓ·͠ΐ͏

  51. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠