Why is xcodebuild not building dependencies when testing? - target

When I run xcodebuild, it crashes. It seems that it is not compiling the test target's dependency, which is the main app. The test target is called NiknikTests, while the app's target is called WTATest3.
Ld build/UninstalledProducts/NiknikTests.xctest/NiknikTests normal i386
cd "/Users/ethen/.jenkins/workspace/Build NikNik"
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/ethen/Desktop/sbt/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/ethen/.jenkins/workspace/Build\ NikNik/build/Release-iphonesimulator -L/Users/ethen/.jenkins/workspace/Build\ NikNik/NiknikTests/TestLibraries/include/lib -F/Users/ethen/.jenkins/workspace/Build\ NikNik/build/Release-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/ethen/.jenkins/workspace/Build\ NikNik/build/NikNik.build/Release-iphonesimulator/NiknikTests.build/Objects-normal/i386/NiknikTests.LinkFileList -bundle_loader /Users/ethen/.jenkins/workspace/Build\ NikNik/build/Release-iphonesimulator/Niknik.app/Niknik -Xlinker -objc_abi_version -Xlinker 2 -force_load /Users/ethen/.jenkins/workspace/Build\ NikNik/NiknikTests/TestLibraries/include/lib/libOCMock.a -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.1 -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/ethen/.jenkins/workspace/Build\ NikNik/build/NikNik.build/Release-iphonesimulator/NiknikTests.build/Objects-normal/i386/NiknikTests_dependency_info.dat -o /Users/ethen/.jenkins/workspace/Build\ NikNik/build/UninstalledProducts/NiknikTests.xctest/NiknikTests
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_NNBoundaryLineModel", referenced from:
objc-class-ref in NNBoundaryLineModelTests.o
(maybe you meant: _OBJC_CLASS_$_NNBoundaryLineModelTests)
"_OBJC_CLASS_$_NNConstant", referenced from:
objc-class-ref in NNConstantTests.o
(maybe you meant: _OBJC_CLASS_$_NNConstantTests)
"_OBJC_CLASS_$_NNPlayerModel", referenced from:
objc-class-ref in NNPlayerModelTests.o
(maybe you meant: _OBJC_CLASS_$_NNPlayerModelTests)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my xcodebuild command:
xcodebuild \
-target NiknikTests \
-arch i386 \
-configuration “Debug” \
-sdk iphonesimulator \
TARGETED_DEVICE_FAMILY="2" \
ONLY_ACTIVE_ARCH=NO \
clean install
When I run the tests from inside of Xcode, it works just fine.
EDIT: This is showing the target dependency of NiknikTests.
Why is it not building the target dependency?

I looks like it is not building the target dependency because of some issues with arch i386. In order to fix this I have two suggestions, 1) Delete the two arch statements from the xcodebuild command:
xcodebuild \
-target NiknikTests \
-configuration “Debug” \
-sdk iphonesimulator \
TARGETED_DEVICE_FAMILY="2" \
clean install
It should automatically choose the correct architecture for the program. However, if that does not work, 2) Try replacing "-arch i386 \" with "ARCHS=i386 \" IE
xcodebuild \
-target NiknikTests \
ARCHS=i386 \
-configuration “Debug” \
-sdk iphonesimulator \
TARGETED_DEVICE_FAMILY="2" \
ONLY_ACTIVE_ARCH=NO \
clean install

Did you try turning on build implicit dependencies under your build scheme ?
I had similar issues with Cocoapods and running unit tests

Related

Undefined symbols for architecture arm64 error after accidentally delete target

I accidentally delete target. I created again but i couldn't run my application again. When i set my AppDelegate i get an error.
Ld /Users/cihanozdiker/Library/Developer/Xcode/DerivedData/Moka-foueugicfassxcdbtgwkndrougpu/Build/Intermediates/Moka.build/Debug-iphoneos/Moka.build/Objects-normal/arm64/Moka normal arm64
cd /Users/cihanozdiker/Documents/MokaAfterMerchantFinished
export IPHONEOS_DEPLOYMENT_TARGET=9.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk -L/Users/cihanozdiker/Library/Developer/Xcode/DerivedData/Moka-foueugicfassxcdbtgwkndrougpu/Build/Products/Debug-iphoneos -L../include -L../include/barcode -L../include/common -L../include/cyclone_crypto -L../include/EstimoteSDK -L../include/openssl -L../include/EstimoteSDK/Headers -L/Users/cihanozdiker/Documents/MokaAfterMerchantFinished -L../lib -L../lib/AESCrypt-ObjC-master -L../lib/RNCryptor -F/Users/cihanozdiker/Library/Developer/Xcode/DerivedData/Moka-foueugicfassxcdbtgwkndrougpu/Build/Products/Debug-iphoneos -filelist /Users/cihanozdiker/Library/Developer/Xcode/DerivedData/Moka-foueugicfassxcdbtgwkndrougpu/Build/Intermediates/Moka.build/Debug-iphoneos/Moka.build/Objects-normal/arm64/Moka.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -miphoneos-version-min=9.1 -ObjC -ObjC -fobjc-arc -fobjc-link-runtime -lcrypto -lssl -lC4NetSdk -Xlinker -dependency_info -Xlinker /Users/cihanozdiker/Library/Developer/Xcode/DerivedData/Moka-foueugicfassxcdbtgwkndrougpu/Build/Intermediates/Moka.build/Debug-iphoneos/Moka.build/Objects-normal/arm64/Moka_dependency_info.dat -o /Users/cihanozdiker/Library/Developer/Xcode/DerivedData/Moka-foueugicfassxcdbtgwkndrougpu/Build/Intermediates/Moka.build/Debug-iphoneos/Moka.build/Objects-normal/arm64/Moka
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_MokaAppDelegate", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I couldn't fix it. I'm using XCode 7.2.
Make sure that the MokaAppDelegate implementation file (probably MokaAppDelegate.m) is marked as part of your new target.
Select the file in the Project Navigator, look at the File Inspector panel and make sure the right target(s) are selected in the Target Membership pane.

ARM64 build error during building libetpan project

While building libetpan for iOS-ARM64,
I've been added logging functionality on prepare script on libetpan for mac project. Xcode fails with strange error, only during build ARM64 target.
Here's the xcode log below:
configuring
running prepare-cyrus-sasl.sh
prepare sources
patching file lib/client.c
building tools
generated makemd5i386 properly
building for iPhoneOS - armv7
CPPFLAGS=-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
CFLAGS=-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -Os -miphoneos-version-min=7.0
./configure --host=arm --prefix=/Users/user/Developer/Workspace/myapp/libetpan/build-mac/dependencies/build/libsasl/workdir/20140417150520/tmp/build/cyrus-sasl-2.1.25/iPhoneOS7.1armv7 --enable-shared=no --enable-static=yes --with-pam=/Users/user/Developer/Workspace/MyApp/libetpan/build-mac/dependencies/build/libsasl/workdir/20140417150520/tmp/build/openpam-20071221/universal --enable-otp=no --enable-digest=no --with-des=no --enable-login
building for iPhoneOS - armv7s
CPPFLAGS=-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
CFLAGS=-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -Os -miphoneos-version-min=7.0
./configure --host=arm --prefix=/Users/user/Developer/Workspace/myapp/libetpan/build-mac/dependencies/build/libsasl/workdir/20140417150520/tmp/build/cyrus-sasl-2.1.25/iPhoneOS7.1armv7s --enable-shared=no --enable-static=yes --with-pam=/Users/user/Developer/Workspace/myapp/libetpan/build-mac/dependencies/build/libsasl/workdir/20140417150520/tmp/build/openpam-20071221/universal --enable-otp=no --enable-digest=no --with-des=no --enable-login
building for iPhoneOS - arm64
CPPFLAGS=-arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
CFLAGS=-arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -Os -miphoneos-version-min=7.0
./configure --host=arm --prefix=/Users/user/Developer/Workspace/myapp/libetpan/build-mac/dependencies/build/libsasl/workdir/20140417150520/tmp/build/cyrus-sasl-2.1.25/iPhoneOS7.1arm64 --enable-shared=no --enable-static=yes --with-pam=/Users/user/Developer/Workspace/myapp/libetpan/build-mac/dependencies/build/libsasl/workdir/20140417150520/tmp/build/openpam-20071221/universal --enable-otp=no --enable-digest=no --with-des=no --enable-login
CONFIGURE FAILED.
The build script generated its own build log file. It ends with "Malformed object" message like below:
ar cru .libs/libsasldb.a db_ndbm.o allockey.o
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: object: .libs/libsasldb.a(allockey.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make[2]: *** [libsasldb.a] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Any ideas? Thanks in advance.
I ran into the same problem after updating iPhone SDK from 7.0 to 7.1.
I fixed it by changing ranlib and ar paths, they were pointing to some old version of those applications (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar).
I changed the path to:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar

Linker Error with Tests in Xcode

I was following along the instructions for building tests using xcode/appcode from TDD site. I got through the initial part ok and started to experiment in my own project, but I keep getting a linking error and can't figure out where from?
The output I get is this
Ld /Users/prasanth/Library/Developer/Xcode/DerivedData/acidplus-ctbnayjfiyhfxkccqyopjsnfagos/Build/Products/Debug-iphonesimulator/acidplusTests.octest/acidplusTests normal i386
cd /Volumes/Defiant/Freeradical/freeradical_newacidbase/acidplus
setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/Users/prasanth/Library/Developer/Xcode/DerivedData/acidplus-ctbnayjfiyhfxkccqyopjsnfagos/Build/Products/Debug-iphonesimulator -LLibs/OCMock/iOS -LLibs/OCMock/iOS/OCMock -F/Users/prasanth/Library/Developer/Xcode/DerivedData/acidplus-ctbnayjfiyhfxkccqyopjsnfagos/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/prasanth/Library/Developer/Xcode/DerivedData/acidplus-ctbnayjfiyhfxkccqyopjsnfagos/Build/Intermediates/acidplus.build/Debug-iphonesimulator/acidplusTests.build/Objects-normal/i386/acidplusTests.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -force_load Libs/OCMock/iOS/libOCMock.a -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 -framework CoreGraphics -framework SenTestingKit -framework UIKit -framework Foundation -lOCMock -o /Users/prasanth/Library/Developer/Xcode/DerivedData/acidplus-ctbnayjfiyhfxkccqyopjsnfagos/Build/Products/Debug-iphonesimulator/acidplusTests.octest/acidplusTests
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_BPG_testModelObject", referenced from:
objc-class-ref in testModelTest.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried looking at missing Sources or Linked libraries, but couldn't find anything. Anyone know what else could be wrong?
thanks!
Have you tried the following:
Go to XCode, Under Project -> do a clean and Build your solution again.

Error When Running on iPhone, Works fine on simulator

I get this error when I try to run on a device. When I run it on a simulator it works fine.
This is the error I get:
Ld "/Users/xxx/Library/Developer/Xcode/DerivedData/Munch_Box-ebibgicdmigfwdbgfdcshfqvxxrc/Build/Products/Debug-iphoneos/Munch Box.app/Munch Box" normal armv7s
cd "/Users/xxx/Projects/xCode Projects/Munch Box"
setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/Users/xxx/Library/Developer/Xcode/DerivedData/Munch_Box-ebibgicdmigfwdbgfdcshfqvxxrc/Build/Products/Debug-iphoneos -F/Users/xxx/Library/Developer/Xcode/DerivedData/Munch_Box-ebibgicdmigfwdbgfdcshfqvxxrc/Build/Products/Debug-iphoneos -filelist "/Users/xxx/Library/Developer/Xcode/DerivedData/Munch_Box-ebibgicdmigfwdbgfdcshfqvxxrc/Build/Intermediates/Munch Box.build/Debug-iphoneos/Munch Box.build/Objects-normal/armv7s/Munch Box.LinkFileList" -dead_strip -fobjc-arc -fobjc-link-runtime -stdlib=libc++ -miphoneos-version-min=6.1 -framework CoreLocation -framework MapKit /Users/xxx/Library/Developer/Xcode/DerivedData/Munch_Box-ebibgicdmigfwdbgfdcshfqvxxrc/Build/Products/Debug-iphoneos/libqrencoder.a -framework UIKit -framework Foundation -framework CoreGraphics -o "/Users/xxx/Library/Developer/Xcode/DerivedData/Munch_Box-ebibgicdmigfwdbgfdcshfqvxxrc/Build/Products/Debug-iphoneos/Munch Box.app/Munch Box"
ld: warning: ignoring file /Users/xxx/Library/Developer/Xcode/DerivedData/Munch_Box-ebibgicdmigfwdbgfdcshfqvxxrc/Build/Products/Debug-iphoneos/libqrencoder.a, file was built for archive which is not the architecture being linked (armv7s): /Users/xxx/Library/Developer/Xcode/DerivedData/Munch_Box-ebibgicdmigfwdbgfdcshfqvxxrc/Build/Products/Debug-iphoneos/libqrencoder.a
Undefined symbols for architecture armv7s:
"_OBJC_CLASS_$_QREncoder", referenced from:
objc-class-ref in TodaysCodeViewController.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Turn off the armv7s in the build settings architectures area. See my answer at Failing Archive App RestKit 0.10
Try to delete Derived Data, clean and restart xCode.
You can delete derived data in organizer (cmd+shift+2 or window->organizer) on the projects tab select yours project and press delete on derived data, then clean.
It may helps, but not sure

Undefined symbols for architecture i386 linker command failed with exit code 1 (use -v to see invocation)

I have looked through other questions that had similar issues, but I still can't figure out what is wrong. This is my first app and the other answers didn't make much sense. I keep getting the same error:
Ld /Users/brandonpayne/Library/Developer/Xcode/DerivedData/FordyceSchools-gcczvpeftaotknfzpktdnjoqzncf/Build/Products/Debug-iphonesimulator/FordyceSchools.app/FordyceSchools normal i386
cd /Users/brandonpayne/Desktop/FordyceSchools
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/brandonpayne/Library/Developer/Xcode/DerivedData/FordyceSchools-gcczvpeftaotknfzpktdnjoqzncf/Build/Products/Debug-iphonesimulator -F/Users/brandonpayne/Library/Developer/Xcode/DerivedData/FordyceSchools-gcczvpeftaotknfzpktdnjoqzncf/Build/Products/Debug-iphonesimulator -filelist /Users/brandonpayne/Library/Developer/Xcode/DerivedData/FordyceSchools-gcczvpeftaotknfzpktdnjoqzncf/Build/Intermediates/FordyceSchools.build/Debug-iphonesimulator/FordyceSchools.build/Objects-normal/i386/FordyceSchools.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/brandonpayne/Library/Developer/Xcode/DerivedData/FordyceSchools-gcczvpeftaotknfzpktdnjoqzncf/Build/Products/Debug-iphonesimulator/FordyceSchools.app/FordyceSchools
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ViewController", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I can't find in my code where the error is. Please help.

Resources