Example iOS project does not compile with Xcode 6.3
I am synced currently to head @ ff6458cdeb9a333816f8d759d329606e7ff1f157 with Xcode 6.3 installed. Trying to build the objective c example PrenotCalculatorClasses fails.
Here is an example run:
$ bazel build examples/objc:PrenotCalculatorClasses --verbose_explanations --verbose_failures
WARNING: --verbose_explanations has no effect when --explain=<file> is not enabled.
INFO: Found 1 target...
INFO: From ObjcCompile examples/objc/_objs/PrenotCalculatorClasses/examples/objc/PrenotCalculator/ValuesViewController.o:
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk'
In file included from examples/objc/PrenotCalculator/ValuesViewController.m:15:
examples/objc/PrenotCalculator/ValuesViewController.h:15:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^
1 error generated.
ERROR: /Users/trevorgray/code/src/github.com/google/bazel/examples/objc/BUILD:27:1: null failed: clang failed: error executing command
(cd /private/var/tmp/_bazel_trevorgray/1966798280922a74b4d2d3d424a8bfe5/bazel && \
exec env - \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wshorten-64-to-32 -Wbool-conversion -Wconstant-conversion -Wduplicate-method-match -Wempty-body -Wenum-conversion -Wint-conversion -Wunreachable-code -Wmismatched-return-types -Wundeclared-selector -Wuninitialized -Wunused-function -Wunused-variable -fexceptions -fasm-blocks '-fobjc-abi-version=2' -fobjc-legacy-dispatch -DOS_IOS '-mios-simulator-version-min=7.0' -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -O0 -iquote . -iquote bazel-out/local_darwin-fastbuild/genfiles -fobjc-arc -c examples/objc/PrenotCalculator/ValuesViewController.m -o bazel-out/local_darwin-fastbuild/bin/examples/objc/_objs/PrenotCalculatorClasses/examples/objc/PrenotCalculator/ValuesViewController.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: clang failed: error executing command
(cd /private/var/tmp/_bazel_trevorgray/1966798280922a74b4d2d3d424a8bfe5/bazel && \
exec env - \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wshorten-64-to-32 -Wbool-conversion -Wconstant-conversion -Wduplicate-method-match -Wempty-body -Wenum-conversion -Wint-conversion -Wunreachable-code -Wmismatched-return-types -Wundeclared-selector -Wuninitialized -Wunused-function -Wunused-variable -fexceptions -fasm-blocks '-fobjc-abi-version=2' -fobjc-legacy-dispatch -DOS_IOS '-mios-simulator-version-min=7.0' -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -O0 -iquote . -iquote bazel-out/local_darwin-fastbuild/genfiles -fobjc-arc -c examples/objc/PrenotCalculator/ValuesViewController.m -o bazel-out/local_darwin-fastbuild/bin/examples/objc/_objs/PrenotCalculatorClasses/examples/objc/PrenotCalculator/ValuesViewController.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //examples/objc:PrenotCalculatorClasses failed to build
INFO: Elapsed time: 1.459s, Critical Path: 0.18s
Installing the 8.1 simulator and adding a symbolic link for iPhoneSimulator8.1.sdk to it's correct directory (/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 8.1.simruntime/Contents/Resources) makes the "no such sysroot directory" go away.
However, even after that the "'UIKit/UIKit.h' file not found" error is still present:
bazel build examples/objc:PrenotCalculatorClasses --verbose_explanations --verbose_failures
WARNING: --verbose_explanations has no effect when --explain=<file> is not enabled.
INFO: Found 1 target...
INFO: From ObjcCompile examples/objc/_objs/PrenotCalculatorClasses/examples/objc/PrenotCalculator/AppDelegate.o:
In file included from examples/objc/PrenotCalculator/AppDelegate.m:15:
examples/objc/PrenotCalculator/AppDelegate.h:15:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^
1 error generated.
ERROR: /Users/trevorgray/code/src/github.com/google/bazel/examples/objc/BUILD:27:1: null failed: clang failed: error executing command
(cd /private/var/tmp/_bazel_trevorgray/1966798280922a74b4d2d3d424a8bfe5/bazel && \
exec env - \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wshorten-64-to-32 -Wbool-conversion -Wconstant-conversion -Wduplicate-method-match -Wempty-body -Wenum-conversion -Wint-conversion -Wunreachable-code -Wmismatched-return-types -Wundeclared-selector -Wuninitialized -Wunused-function -Wunused-variable -fexceptions -fasm-blocks '-fobjc-abi-version=2' -fobjc-legacy-dispatch -DOS_IOS '-mios-simulator-version-min=7.0' -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -O0 -iquote . -iquote bazel-out/local_darwin-fastbuild/genfiles -fobjc-arc -c examples/objc/PrenotCalculator/AppDelegate.m -o bazel-out/local_darwin-fastbuild/bin/examples/objc/_objs/PrenotCalculatorClasses/examples/objc/PrenotCalculator/AppDelegate.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: clang failed: error executing command
(cd /private/var/tmp/_bazel_trevorgray/1966798280922a74b4d2d3d424a8bfe5/bazel && \
exec env - \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wshorten-64-to-32 -Wbool-conversion -Wconstant-conversion -Wduplicate-method-match -Wempty-body -Wenum-conversion -Wint-conversion -Wunreachable-code -Wmismatched-return-types -Wundeclared-selector -Wuninitialized -Wunused-function -Wunused-variable -fexceptions -fasm-blocks '-fobjc-abi-version=2' -fobjc-legacy-dispatch -DOS_IOS '-mios-simulator-version-min=7.0' -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -O0 -iquote . -iquote bazel-out/local_darwin-fastbuild/genfiles -fobjc-arc -c examples/objc/PrenotCalculator/AppDelegate.m -o bazel-out/local_darwin-fastbuild/bin/examples/objc/_objs/PrenotCalculatorClasses/examples/objc/PrenotCalculator/AppDelegate.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //examples/objc:PrenotCalculatorClasses failed to build
INFO: Elapsed time: 1.331s, Critical Path: 0.06s
Does it work when you pass "--ios_sdk_version=8.3" to the bazel build command?
Thanks. That works.
I had the same problem trying to build the UrlGetClasses example form the tutorial
bazel build UrlGetClasses would fail with
In file included from ios-app/UrlGet/AppDelegate.m:15:
ios-app/UrlGet/AppDelegate.h:15:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
Adding the --ios_sdk_version flag didn't help, but this fixed it for me
bazel build UrlGetClasses --apple_platform_type=ios
The reason, I suppose, is that UIKit is automatically imported when building for iOS, as the objc_library docs state.
Ahhhh thanks Gio!