Wednesday, February 04, 2015

dvtassertions: assertion failure xcodebuild invoked in Makefile

What can you do to be able to run xcodebuild within a Makefile ?

First lesson I learned is that you can call xcodebuild in the folder where xcodeproj is located using the shell but how to invoke xcodebuild from a Makefile ?

Create top level Makefile and then call various project Makefile next to each xcodeproj.

In top level Makefile create a separate target for xcode

#  xcodebuild will fail mysteriously if we have the CC environmental variable set.  If we are building xocde target,
#  remove any local definition for CC so this won't happen.    
ifeq ($(MAKECMDGOALS),olympic)
unexport CC
olympic:

else    
    
xocde:
$(MAKE) -C subfolder/iOS/projectroot xcode
endif


Then in subfolder/iOS/projectroot create a Makefile and add the following

all: xcode

xcode:
                xcode-select -print-path  < USEFULL to LOG path to xcode
                xcodebuild -project myproject.xcodeproj -list    < USEFULL to LOG all target available in xcode project 
                xcodebuild

Open a shell in top level folder where top Level Makefile belongs

and run
make xcode

If you do not unexport CC then you will see following crash in xcodebuild.

APPLE Xcode team: Please FIX this is annoying!!!

2015-02-04 15:46:08.805 xcodebuild[19004:225695]  DVTAssertions: ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/BuildSystem/Runtime/PBXTargetBuildContext.mm:1690
Details:  commandPath should be a string, but it is nil
Object:  
Method:   -createCommandWithRuleInfo:commandPath:arguments:forNode:toolSpecification:withMacroExpansionScope:
Thread:   {number = 6, name = (null)}
Hints: None
Backtrace:
  0  0x000000010f83424a -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
  1  0x000000010f833c9f _DVTAssertionHandler (in DVTFoundation)
  2  0x000000010f833f8e _DVTAssertionFailureHandler (in DVTFoundation)
  3  0x00000001111afb4f -[PBXTargetBuildContext createCommandWithRuleInfo:commandPath:arguments:forNode:toolSpecification:withMacroExpansionScope:] (in DevToolsCore)
  4  0x00000001112b01be -[XCDependencyGraphCreationContext createCommandWithRuleInfo:commandPath:arguments:forNode:toolSpecification:withMacroExpansionScope:] (in DevToolsCore)
  5  0x00000001111e0a0b -[PBXCompilerSpecificationGcc2_95_2 compileSourceCodeFileAtPath:ofType:toOutputDirectory:withMacroExpansionScope:] (in DevToolsCore)
  6  0x00000001112ffaeb -[XCCompilerSpecificationClang compileSourceCodeFileAtPath:ofType:toOutputDirectory:withMacroExpansionScope:] (in DevToolsCore)
  7  0x00000001111dd80c -[PBXCompilerSpecificationGcc computeDependenciesForInputNodes:ofType:variant:architecture:outputDirectory:withMacroExpansionScope:] (in DevToolsCore)
  8  0x000000011122318b -[XCCompilerSpecification computeDependenciesForFilePath:ofType:outputDirectory:withMacroExpansionScope:] (in DevToolsCore)
  9  0x00000001112ee5b8 -[XCBuildRuleDGSnapshot(DependencyGraphCreation) computeDependenciesForFilePath:ofType:forBuildFileReference:withOutputDirectory:parameterMacros:withMacroExpansionScope:] (in DevToolsCore)
10  0x00000001112ef3f5 -[XCBuildRuleDGSnapshot(DependencyGraphCreation) computeDependenciesForBuildFileReference:withOutputDirectory:parameterMacros:withMacroExpansionScope:] (in DevToolsCore)
11  0x00000001112e1cb3 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) _computeDependenciesForBuildFileReference:usingBuildRule:withMacroExpansionScope:processedPaths:] (in DevToolsCore)
12  0x00000001112e431d -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForBuildFileReference:usingBuildRule:withMacroExpansionScope:] (in DevToolsCore)
13  0x00000001112e4772 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForBuildFileReference:withMacroExpansionScope:] (in DevToolsCore)
14  0x00000001112d26f3 -[XCBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForAllBuildFileReferencesWithMacroExpansionScope:] (in DevToolsCore)
15  0x00000001112e7280 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForAllBuildFileReferencesWithMacroExpansionScope:] (in DevToolsCore)
16  0x00000001112e888f -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesWithMacroExpansionScope:] (in DevToolsCore)
17  0x0000000111226367 -[XCProductTypeSpecification computeDependenciesWithMacroExpansionScope:] (in DevToolsCore)
18  0x00000001112cb2fb -[XCNativeTargetDGSnapshot(DependencyGraphCreation) computeDependenciesWithMacroExpansionScope:] (in DevToolsCore)
19  0x00000001111a43ea -[PBXTargetBuildContext createDependencyGraphWithTargetDGSnapshot:] (in DevToolsCore)
20  0x00000001111c1dfa -[PBXTargetBuildContext(DependencyGraphEvents) dg_setTargetSnapshot:] (in DevToolsCore)
21  0x00000001111c0998 -[PBXTargetBuildContext(DependencyGraphEvents) processDependencyGraphEvents] (in DevToolsCore)
22  0x000000011121db20 -[XCBlockQueue _processNextBlockInThreadSlotNumber:] (in DevToolsCore)
23  0x000000011121ddf0 -[XCBlockQueue _processBlocksInThreadSlotNumber:] (in DevToolsCore)
24  0x00007fff8b76d90a __NSThread__main__ (in Foundation)
25  0x00007fff8bacc268 _pthread_body (in libsystem_pthread.dylib)
26  0x00007fff8bacc1e5 _pthread_body (in libsystem_pthread.dylib)
27  0x00007fff8baca41d thread_start (in libsystem_pthread.dylib)
2015-02-04 15:46:08.805 xcodebuild[19004:225693]  DVTAssertions: ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/BuildSystem/Runtime/PBXTargetBuildContext.mm:1690
Details:  commandPath should be a string, but it is nil
Object:  
Method:   -createCommandWithRuleInfo:commandPath:arguments:forNode:toolSpecification:withMacroExpansionScope:
Thread:   {number = 4, name = (null)}
Hints: None
Backtrace:
  0  0x000000010f83424a -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
  1  0x000000010f833c9f _DVTAssertionHandler (in DVTFoundation)
  2  0x000000010f833f8e _DVTAssertionFailureHandler (in DVTFoundation)
  3  0x00000001111afb4f -[PBXTargetBuildContext createCommandWithRuleInfo:commandPath:arguments:forNode:toolSpecification:withMacroExpansionScope:] (in DevToolsCore)
  4  0x00000001112b01be -[XCDependencyGraphCreationContext createCommandWithRuleInfo:commandPath:arguments:forNode:toolSpecification:withMacroExpansionScope:] (in DevToolsCore)
  5  0x00000001111e0a0b -[PBXCompilerSpecificationGcc2_95_2 compileSourceCodeFileAtPath:ofType:toOutputDirectory:withMacroExpansionScope:] (in DevToolsCore)
  6  0x00000001112ffaeb -[XCCompilerSpecificationClang compileSourceCodeFileAtPath:ofType:toOutputDirectory:withMacroExpansionScope:] (in DevToolsCore)
  7  0x00000001111dd80c -[PBXCompilerSpecificationGcc computeDependenciesForInputNodes:ofType:variant:architecture:outputDirectory:withMacroExpansionScope:] (in DevToolsCore)
  8  0x000000011122318b -[XCCompilerSpecification computeDependenciesForFilePath:ofType:outputDirectory:withMacroExpansionScope:] (in DevToolsCore)
  9  0x00000001112ee5b8 -[XCBuildRuleDGSnapshot(DependencyGraphCreation) computeDependenciesForFilePath:ofType:forBuildFileReference:withOutputDirectory:parameterMacros:withMacroExpansionScope:] (in DevToolsCore)
10  0x00000001112ef3f5 -[XCBuildRuleDGSnapshot(DependencyGraphCreation) computeDependenciesForBuildFileReference:withOutputDirectory:parameterMacros:withMacroExpansionScope:] (in DevToolsCore)
11  0x00000001112e1cb3 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) _computeDependenciesForBuildFileReference:usingBuildRule:withMacroExpansionScope:processedPaths:] (in DevToolsCore)
12  0x00000001112e431d -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForBuildFileReference:usingBuildRule:withMacroExpansionScope:] (in DevToolsCore)
13  0x00000001112e4772 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForBuildFileReference:withMacroExpansionScope:] (in DevToolsCore)
14  0x00000001112d26f3 -[XCBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForAllBuildFileReferencesWithMacroExpansionScope:] (in DevToolsCore)
15  0x00000001112e7280 -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesForAllBuildFileReferencesWithMacroExpansionScope:] (in DevToolsCore)
16  0x00000001112e888f -[XCSourcesBuildPhaseDGSnapshot(DependencyGraphCreation) computeDependenciesWithMacroExpansionScope:] (in DevToolsCore)
17  0x0000000111226367 -[XCProductTypeSpecification computeDependenciesWithMacroExpansionScope:] (in DevToolsCore)
18  0x00000001112cb2fb -[XCNativeTargetDGSnapshot(DependencyGraphCreation) computeDependenciesWithMacroExpansionScope:] (in DevToolsCore)
19  0x00000001111a43ea -[PBXTargetBuildContext createDependencyGraphWithTargetDGSnapshot:] (in DevToolsCore)
20  0x00000001111c1dfa -[PBXTargetBuildContext(DependencyGraphEvents) dg_setTargetSnapshot:] (in DevToolsCore)
21  0x00000001111c0998 -[PBXTargetBuildContext(DependencyGraphEvents) processDependencyGraphEvents] (in DevToolsCore)
22  0x000000011121db20 -[XCBlockQueue _processNextBlockInThreadSlotNumber:] (in DevToolsCore)
23  0x000000011121ddf0 -[XCBlockQueue _processBlocksInThreadSlotNumber:] (in DevToolsCore)
24  0x00007fff8b76d90a __NSThread__main__ (in Foundation)
25  0x00007fff8bacc268 _pthread_body (in libsystem_pthread.dylib)
26  0x00007fff8bacc1e5 _pthread_body (in libsystem_pthread.dylib)
27  0x00007fff8baca41d thread_start (in libsystem_pthread.dylib)
make[1]: *** [olympic] Abort trap: 6

make: *** [olympic] Error 2

2 comments:

Unknown said...

I got the same error. Did you solve this?

Thomas Younsi said...

you have to unexport CC
It worked in my case at least