Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

XCode 8 and iOS 10 Support #102

Closed
joeced opened this issue Oct 6, 2016 · 34 comments
Closed

XCode 8 and iOS 10 Support #102

joeced opened this issue Oct 6, 2016 · 34 comments

Comments

@joeced
Copy link

joeced commented Oct 6, 2016

I recently updated to XCode 8 and the iOS 10 SDK. I have been using the ios-9-3.cmake toolchain with great success. I have tried to copy it to a new toolchain file, ios-10-0.cmake, updating set(IOS_SDK_VERSION 10.0). Unfortunately, this is not enough. I get the error message below when running cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=polly/ios-10-0.cmake:

Found iOS SDK Version = 10.0
-- [polly] Used toolchain: iOS 10.0 Universal (iphoneos + iphonesimulator) / clang / c++11 support
-- The C compiler identification is AppleClang 8.0.0.8000038
-- The CXX compiler identification is AppleClang 8.0.0.8000038
-- Check for working C compiler using: Xcode
-- Check for working C compiler using: Xcode -- broken
CMake Error at /usr/local/Cellar/cmake/3.5.2/share/cmake/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
is not able to compile a simple test program.

It fails with the following output:

Change Dir: /Users/<...>/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/xcodebuild" "-project"
"CMAKE_TRY_COMPILE.xcodeproj" "build" "-target" "cmTC_e2b54"
"-configuration" "Debug"

=== BUILD TARGET cmTC_e2b54 OF PROJECT CMAKE_TRY_COMPILE WITH CONFIGURATION
Debug ===

Check dependencies

Signing for "cmTC_e2b54" requires a development team. Select a development
team in the project editor.

Code signing is required for product type 'Application' in SDK 'iOS 10.0'

** BUILD FAILED **

The following build commands failed:

  Check dependencies

(1 failure)

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred!
See also "/Users/<...>/CMakeFiles/CMakeOutput.log".
See also "/Users/<...>/CMakeFiles/CMakeError.log".

As one can see XCode now requires a development team for code signing to work. I tried adding set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "iPhone Developer Team") but this results in:

Check dependencies

No profiles for 'com.example' were found: Xcode couldn't find a
provisioning profile matching 'com.example'.

Code signing is required for product type 'Application' in SDK 'iOS 10.0'

Does anyone have an idea to get around this issue?

@joeced
Copy link
Author

joeced commented Oct 6, 2016

I think I have found a solution, adding

set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM <10 Letter Dev. Team ID>)

Solves the code signing issue. If one can find the Developer Team ID automatically it would be very nice.

@ruslo
Copy link
Owner

ruslo commented Oct 10, 2016

@joeced Thanks for the info. I have not installed Xcode 8 yet. Will take a look later.

@ghost
Copy link

ghost commented Oct 10, 2016

Awesome, works like a charm :-) thanks guys !

@joeced
Copy link
Author

joeced commented Oct 10, 2016

@ruslo Great. If you have any ideas on either finding Developer Team ID automatically or "just" use a variable to define, I'll be happy to make a pull request.

@reasonMix
Copy link

@joeced there is a stupid method, i modify the ios-10-0.cmake,and add the following lines:
set(CMAKE_C_COMPILER_FORCED TRUE)
set(CMAKE_CXX_COMPILER_FORCED TRUE)
to ignore the compile the simple c program

@ruslo
Copy link
Owner

ruslo commented Oct 28, 2016

i modify the ios-10-0.cmake,and add the following lines

Just for your info this will break Hunter builds: https://github.com/ruslo/hunter/wiki/error.abi.detection.failure

@headupinclouds
Copy link
Contributor

For reference: http://stackoverflow.com/a/18727947

@headupinclouds
Copy link
Contributor

headupinclouds commented Oct 28, 2016

Per @joeced, adding the CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM variable to the toolchain fixes the issue. What convention shall we use for polly toolchains? Environment variable?

if (NOT DEFINED ENV{XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}) 
  polly_fatal_error("XCODE_ATTRIBUTE_DEVELOPMENT_TEAM variable must be set.")
endif()

set(MACOSX_BUNDLE_GUI_IDENTIFIER com.example)
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "$ENV{XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}")

@joeced
Copy link
Author

joeced commented Oct 28, 2016

@headupinclouds I think that looks like a nice solution, and matches the pattern use in other toolchain files.

headupinclouds added a commit to elucideye/drishti that referenced this issue Oct 28, 2016
@ruslo
Copy link
Owner

ruslo commented Oct 29, 2016

If one can find the Developer Team ID automatically it would be very nice

Can't find anything :(

I think that looks like a nice solution, and matches the pattern use in other toolchain files

Yes, seems like an appropriate solution. Implemented in master:

Documentation:

@ruslo ruslo closed this as completed Oct 29, 2016
@headupinclouds
Copy link
Contributor

Thanks!

@joeced
Copy link
Author

joeced commented Oct 31, 2016

Great! Thanks.

@gelldur
Copy link

gelldur commented Nov 29, 2016

Error still occurs?

- [polly] Used toolchain: iOS 10.1 Universal (iphoneos + iphonesimulator) / clang / c++11 support
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- broken
CMake Error at /usr/local/Cellar/cmake/3.7.0/share/cmake/Modules/CMakeTestCCompiler.cmake:51 (message):
  The C compiler
  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: /Users/gelldur/Projects/app/CMakeFiles/CMakeTmp

  

  Run Build Command:"/usr/bin/xcodebuild" "-project"
  "CMAKE_TRY_COMPILE.xcodeproj" "build" "-target" "cmTC_f876e"
  "-configuration" "Debug"

  === BUILD TARGET cmTC_f876e OF PROJECT CMAKE_TRY_COMPILE WITH CONFIGURATION
  Debug ===

  

  Check dependencies

  No profiles for 'com.example' were found: Xcode couldn't find a
  provisioning profile matching 'com.example'.

  Code signing is required for product type 'Application' in SDK 'iOS 10.1'

  

  ** BUILD FAILED **

  

  

  The following build commands failed:

  	Check dependencies

  (1 failure)

  

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (PROJECT)

@ruslo
Copy link
Owner

ruslo commented Nov 30, 2016

@gelldur are you sure everything okay with your provisioning profiles? Can you try to start Xcode and build/run trivial example on your device? (without CMake and without Polly)

@gelldur
Copy link

gelldur commented Nov 30, 2016

@ruslo the same with example
Xcode sample project building normally. When i use ios-nocodesign-10-1.cmake everything ok

@ruslo
Copy link
Owner

ruslo commented Nov 30, 2016

@gelldur what is the version of Polly you're using? Probably you need to update: git pull?

@gelldur
Copy link

gelldur commented Nov 30, 2016

@ruslo yesterday i downloaded master

@ruslo
Copy link
Owner

ruslo commented Nov 30, 2016

@gelldur can you show the minimal example to reproduce the problem? Does error occur for this one:

cmake_minimum_required(VERSION 3.7)
project(foo)

?

@gelldur
Copy link

gelldur commented Nov 30, 2016

CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED (VERSION 3.7)

PROJECT (test)

ADD_EXECUTABLE(Test main.cpp)

I used: cmake -DCMAKE_TOOLCHAIN_FILE=~/Desktop/polly/ios-10-1.cmake -G Xcode .. without toolchain it works but this isn't what we want :(

-- Edit
Also when i'm building for simulator it doesn't work :/ simply during linking no such dir: /proj/ios/Debug-iphonesimulator/libmylib.a

@ruslo
Copy link
Owner

ruslo commented Dec 1, 2016

@gelldur test is not a good name for project/target. Just to be sure try another names.

@reasonMix
Copy link

reasonMix commented Dec 1, 2016

@gelldur use xcode to create a simple project for ios,and the bundle id is com.example, and check the auto option,then xcode will auto download the provisioning profiles, when compile success, close xcode ,then use the polly to build your's project

@ruslo
Copy link
Owner

ruslo commented Dec 1, 2016

then xcode will auto download the provisioning profiles

@reasonMix Already checked as far as I understand

@gelldur I can reproduce similar error by providing incorrect team-id. Can you verify that team-id is correct? Here is the guide:

Also I haven't updated Xcode yet, just for your information I'm using Xcode 8.0 and iOS 10.0 SDK.

@joeced
Copy link
Author

joeced commented Dec 1, 2016

I use Xcode 8.0 and iOS 10.1 SDK, and it works fine for me.

@gelldur
Copy link

gelldur commented Dec 1, 2016

I have changed CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED (VERSION 3.7)
PROJECT (foo)
ADD_EXECUTABLE(Foo main.cpp)

I have checked my team id twice.


After creating Example project with com.example test script pass :) thx @reasonMix !
So now i am able to run cmake with toolchain.

Currently i have only problem with not found static libs. Simply build dirs are empty. I figure it out that using cocoapods workspace (after pod install) breaks it. So i simply go back to use oryginal xcodeproj now everything is building correctly but only in DEBUG when i deploy on iPhone or Simulator

But when i archive errors occur :( because missing libs in release dirs

@ruslo
Copy link
Owner

ruslo commented Dec 1, 2016

After creating Example project with com.example test script pass :)

Added by Polly here:

But when i archive errors occur :( because missing libs in release dirs

Please open separate issue if the problem is not about team-id. And if the problem is about Polly of course :)

@gelldur
Copy link

gelldur commented Dec 1, 2016

Ok now everything ok. Important note is that project MUST BE created next to top level CMakeLists to prevent such bugs... also i reset to default build paths for all submodules. Thx for help!

@ruslo
Copy link
Owner

ruslo commented Dec 2, 2016

Important note is that project MUST BE created next to top level CMakeLists to prevent such bugs

What do you mean? Your top level CMakeLists.txt doesn't contain project command?

Ok now everything ok

@gelldur Can you summarize what was the problem exactly and the solution? This may be helpful for other developers. This info can be saved to Errors section: http://polly.readthedocs.io/en/latest/toolchains/ios.html#errors

@gelldur
Copy link

gelldur commented Dec 3, 2016

Normally when you create project simply you do:

mkdir build
cd build
cmake ..

In my case when i do it in this way i have a lot of errors. Ok maybe not errors but sometimes subprojects do not build etc.

i just must execute cmake . and now installing pods etc works correctly.

My top level CMakeLists.txt contains project. On linux / android everything is working correctly

@ruslo
Copy link
Owner

ruslo commented Dec 3, 2016

cmake ..

@gelldur You mean cmake -DCMAKE_TOOLCHAIN_FILE=/.../ios.cmake -GXcode .. right?

cmake .

In source build?

On linux / android everything is working correctly

Probably issue is masked by some factor on such platforms but on iOS it triggers real errors.

@gelldur
Copy link

gelldur commented Dec 3, 2016

yeah cmake.. was only shortcut ;) for whole command.

I have such order:

CMakeLists <-- i must make project next to this file
native
|___ CMakeLists
|___ src
proj
|___ ios
|      |___ src
|      |___ CMakeLists
|___ android
|      |___ src
|      |___ CMakeLists
|___ linux
|      |___ src
|      |___ CMakeLists

@ruslo
Copy link
Owner

ruslo commented Dec 3, 2016

In my case when i do it in this way i have a lot of errors

It would be much easier if you provide an example and what kind of errors you get. Also this doesn't seems like a Polly related issue, just some cmake related troubles in CMakeLists.txt.

@headupinclouds
Copy link
Contributor

use xcode to create a simple project for ios,and the bundle id is com.example, and check the auto option,then xcode will auto download the provisioning profiles, when compile success, close xcode ,then use the polly to build your's project

This post ☝️ from @reasonMix helped me get through an error on a new OS X + Xcode 8 installation. It seems the process of creating a project "manually" has some side-effect that is required for CMake builds to work. ENV = { Xcode 8.2, OS X 10.12.2; Cmake = 3.7.2 }.

@ruslo
Copy link
Owner

ruslo commented Jan 21, 2017

@ruslo
Copy link
Owner

ruslo commented Sep 7, 2017

Step by step document with screenshots:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants