leetal / ios-cmake

A CMake toolchain file for iOS/iPadOS, visionOS, macOS, watchOS & tvOS C/C++/Obj-C++ development
BSD 3-Clause "New" or "Revised" License
1.87k stars 447 forks source link

CMake for watchOS && wacthOS simulator generated the Wrong tvOS 8.0 min deployment target version binary #21

Closed dreampiggy closed 5 years ago

dreampiggy commented 5 years ago

The system envionment

➜  ~ xcodebuild -version
Xcode 10.1
Build version 10B61
➜  ~ cmake --version
cmake version 3.12.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

The usage

Trying to build libde265 project:

cmake .. -DCMAKE_TOOLCHAIN_FILE=../../ios-cmake/ios.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DIOS_PLATFORM=SIMULATOR_WATCHOS
make

Result

This can build. However, the generated static library's is strange. The architecture is correct, but however, the info stored inside Mach-O binary is strange and point out it's a watchOS 8.0 (?) binary. However, current (2018) latest watchOS SDK is 5.1.

See the output (take watchOS simulator for example) :

➜  SIMULATOR_WATCHOS lipo -info libde265.a
Non-fat file: libde265.a is architecture: i386
➜  SIMULATOR_WATCHOS otool -lv libde265.a | grep platform
  platform watchos
➜  SIMULATOR_WATCHOS otool -lv libde265.a | grep minos
     minos 8.0

And also, when uploading to CocoaPods trunk, the pod spec lint show the warnings here:

    - NOTE  | [SDWebImageHEIFCoder/libde265] xcodebuild:  ld: warning: URGENT: building for watchOS simulator, but linking in object file (/Users/travis/build/SDWebImage/SDWebImageHEIFCoder/Vendors/libde265/watchOS/libde265.a(cabac.cc.o)) built for tvOS. Note: This will be an error in the future.
    - NOTE  | [SDWebImageHEIFCoder/libde265] xcodebuild:  ld: warning: object file (/Users/travis/build/SDWebImage/SDWebImageHEIFCoder/Vendors/libde265/watchOS/libde265.a(cabac.cc.o)) was built for newer tvOS version (8.0) than being linked (2.0)
    - NOTE  | [SDWebImageHEIFCoder/libde265] xcodebuild:  ld: warning: URGENT: building for watchOS simulator, but linking in object file (/Users/travis/build/SDWebImage/SDWebImageHEIFCoder/Vendors/libde265/watchOS/libde265.a(de265.cc.o)) built for tvOS. Note: This will be an error in the future.
    - NOTE  | [watchOS] [SDWebImageHEIFCoder/libx265] xcodebuild:  ld: warning: URGENT: building for watchOS simulator, but linking in object file (/Users/travis/build/SDWebImage/SDWebImageHEIFCoder/Vendors/libx265/watchOS/libx265.a(analysis.cpp.o)) built for tvOS. Note: This will be an error in the future.
    - NOTE  | [watchOS] [SDWebImageHEIFCoder/libx265] xcodebuild:  ld: warning: object file (/Users/travis/build/SDWebImage/SDWebImageHEIFCoder/Vendors/libx265/watchOS/libx265.a(analysis.cpp.o)) was built for newer tvOS version (8.0) than being linked (2.0)
    - NOTE  | [watchOS] [SDWebImageHEIFCoder/libx265] xcodebuild:  ld: warning: URGENT: building for watchOS simulator, but linking in object file (/Users/travis/build/SDWebImage/SDWebImageHEIFCoder/Vendors/libx265/watchOS/libx265.a(search.cpp.o)) built for tvOS. Note: This will be an error in the future.
    - NOTE  | [watchOS] [SDWebImageHEIFCoder/libx265] xcodebuild:  ld: warning: object file (/Users/travis/build/SDWebImage/SDWebImageHEIFCoder/Vendors/libx265/watchOS/libx265.a(search.cpp.o)) was built for newer tvOS version (8.0) than being linked (2.0)

The FAT binary is in one open-source project and you can also download it from GitHub here.

Note that pod spec lint will check all 4 Apple platforms iOS/tvOS/watchOS/macOS, thoes warnings only happend on watchOS binary.

😕 I'm wondering is this a designed behavior ? (Quite strange from the first look), or Xcode bug ? Or this ios-cmake script issue ? Thanks for support !

leetal commented 5 years ago

Thanks for the detailed bug report. I'll have a look at this in the coming day. Most definitely not a bug with xcode. Most probably with the toolchain.

leetal commented 5 years ago

Looking closer into this issue there was definitely problems with the toolchain in certain (untested) situations. The default min version was always set to 8.0 (watchOS does not follow the other SDK versions obviously). I have patched this in the repo to now target watchOS SDK 2.0 as default.

dreampiggy commented 5 years ago

Seems this works for me. It's related to the min depolyment target version on watchOS platform. Thanks for your support !