I am writing a program by using objective-c. Now I am going to add a UDP server and client into my project, before I add the file into xcode project, the project can be run successfully. But after I add another mainudp.m and upd.h and upd.m, the program cannot run and here is the error message, how to cope with this issue? Thanks
Ld /Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Products/Debug/dd.app/Contents/MacOS/dd normal x86_64
cd /Users/bacd/Desktop/de
export MACOSX_DEPLOYMENT_TARGET=10.7
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Products/Debug -F/Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Products/Debug -F/Users/bacd/Desktop/de/Bluewear\ OSX -filelist /Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Intermediates/dd.build/Debug/dd.build/Objects-normal/x86_64/dd.LinkFileList -mmacosx-version-min=10.7 -fobjc-arc -fobjc-link-runtime -framework AVFoundation -framework QuartzCore -framework CoreAudio -framework Carbon -framework IOBluetooth -framework Cocoa -framework CoreServices -Xlinker -dependency_info -Xlinker /Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Intermediates/dd.build/Debug/dd.build/Objects-normal/x86_64/dd_dependency_info.dat -o /Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Products/Debug/dd.app/Contents/MacOS/dd
duplicate symbol _main in:
/Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Intermediates/dd.build/Debug/dd.build/Objects-normal/x86_64/main.o
/Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Intermediates/dd.build/Debug/dd.build/Objects-normal/x86_64/mainudp.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The new file (mainudp.m) must define a main() function, which is the entry-point into the program. You can only have one entry point and you already have one in your existing code.
You will either need to remove that new file or remove the main() function it contains and access any functionality it provides via your existing code.
Probably in your project you have dragged the whole 3rd party project, that's why there is two main() implementation one in your own project in main.m file and another in the third party project probably in mainudp.m file. That's why it is creating the issue. Try to drag drop only the useful classes not the whole project.
Related
we have a legacy iOS objective C app. We want to add "swift" functionality. Created a separate "Cocoa touch framework" project to reference it from the "objective C" project. I am getting this error when I try to call/init any of the methods in swift from objective c
Ld /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Products/Debug-iphonesimulator/super.app/super normal x86_64
cd /Users/teeboy/iWorkbench/super
export IPHONEOS_DEPLOYMENT_TARGET=10.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.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 x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -L/Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Products/Debug-iphonesimulator -F/Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Products/Debug-iphonesimulator -F/Users/teeboy/iWorkbench/super -filelist /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Intermediates/super.build/Debug-iphonesimulator/super.build/Objects-normal/x86_64/super.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -mios-simulator-version-min=10.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Intermediates/super.build/Debug-iphonesimulator/super.build/Objects-normal/x86_64/super_lto.o -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -all_load -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Intermediates/super.build/Debug-iphonesimulator/super.build/super.app.xcent -lz -lPatientSearch -framework MapKit -framework ZipArchive -framework QuartzCore -lMobuleMenuCell -framework OCMockitoIOS -framework Security -lModuleNavigation -lToDoList -framework CoreData -lPatientChart -framework CoreText -framework Crashlytics -framework CoreLocation -lVisitNotes -lDataAccess -lDashboard -framework MobileCoreServices -framework SystemConfiguration -lframework -lsuperCommon -framework UIKit -framework OCHamcrestIOS -framework Foundation -framework CoreGraphics -Xlinker -dependency_info -Xlinker /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Intermediates/super.build/Debug-iphonesimulator/super.build/Objects-normal/x86_64/super_dependency_info.dat -o /Users/teeboy/Library/Developer/Xcode/DerivedData/super-aybvkjtipygrszeyqsnbmtglaaqi/Build/Products/Debug-iphonesimulator/super.app/super
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$__TtC5utils3zip", referenced from:
objc-class-ref in libDashboard.a(ASLandingPageVC.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The name of swift library is "utils". The legacy objective c app uses some other project dependencies. sorry, newbie to xcode.
Without knowing exactly how you referenced the Swift framework in the Objective-C app, I can only guess that you referenced a framework binary that is built for a platform different from the one you are trying to build the app for.
For instance, this would happen if you built the framework for a device, then included, in the Framework Search Paths under the app's Build Settings, the path to the directory containing the resulting .framework directory and then tried to build the app for a simulator. It would work if you used the correct framework binary (built for the simulator in this case).
However, a more elegant way of doing this is to embed the Swift framework in your application. Assuming the framework and the app are in different projects, you might do the following:
Ensure that the framework project is not open in Xcode.
Open the app project in Xcode.
Drag the framework's .xcodeproj from Finder to the app project in Xcode to create a reference.
Under General -> Embedded Binaries add your Swift .framework.
When you build the app, Xcode will build the framework for the correct architecture and use and embed it in your app.
See https://developer.apple.com/library/content/technotes/tn2435/_index.html for more info about embedding frameworks. BTW, when the linker failed, did you also see a warning from ld about a file missing a required architecture?
I just finished programming my application. I tried to archive the App for submission, but it didn't work, the following error was displayed. This problem only happens when I want to archive the app, running on Test device or Simulator works perfect (no errors).
Ld /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp normal armv7
cd /Users/Admin/Desktop/MyApp3
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 armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos -L/Users/Admin/Desktop/MyApp3 -F/Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos -filelist /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/MyApp.LinkFileList -dead_strip -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -force_load /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/libCordova.a -ObjC -fobjc-link-runtime -miphoneos-version-min=6.1 -lxml2 -lxml2.2 -larchive.2 -framework CoreLocation -framework ImageIO -framework OpenAL -framework AssetsLibrary /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/libCordova.a -framework Foundation -weak_framework UIKit -framework CoreGraphics -framework AddressBook -framework AddressBookUI -framework AudioToolbox -weak_framework AVFoundation -framework CFNetwork -framework MediaPlayer -framework QuartzCore -framework SystemConfiguration -framework MobileCoreServices -weak_framework CoreMedia -framework CoreLocation -lCordova -o /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp
ld: file not found: /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/libCordova.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(null): File not found: /Users/Admin/Library/Developer/Xcode/DerivedData/Myapp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/Myapp/InstallationBuildProductsLocation/Applications/libCordova.a
(null): Linker command failed with exit code 1 (use -v to see invocation)
I already googled the ** out of this the past days. I tried everything I found. I set Build Active Architecture Only to "YES", deleted search paths (they were already empty), changed iOS Version, set Validate Build Product and other stuff.
I create my projects using terminal and ./create.
I even made a new clean project and posted my source code in there. The problem occures every time (even if I try to archive the new project without changing anything in source)
Using:
XCode 4.6.3
PhoneGap 2.9.0
I am desperate and hope for help. Thank you.
SOLUTION
I found a solution/work-around. (Couldn't post it because if 10Rep. limit, had to wait 8 hours)
In Target's Build Settings, find "Other Linker Flags"
Change $(TARGET_BUILD_DIR)/libCordova.a
To $(BUILT_PRODUCTS_DIR)/libCordova.a
Or just go to the Cordova site and download Cordova 3.0.0
(although the old known "splashscreen - white flash" is back)
With Cordova 3.0 this problem is fixed :)
Archiving works fine.
I am having the same issue... Works fine on simulator and test device, set Build Active Architecture to "YES" on both Cardova and MyApp projects, created using terminal ./create, rebuild the project from scratch.
Using: XCode 4.6.3 PhoneGap 2.9.0
Update:
Rebuilt my project with PhoneGap 3.0.0 and am now able to archive.
For me this was solved by setting "Build Active Architecture Only" to "Yes" for the "Release" setting in your Build Settings in xcode.
The fix described by FlyingLemon had already been done as I have the latest version of PhoneGap.
Phonegap version 3.4.0-0.19.13
Xcode version 5.1
I'm using a slightly outdated version of Xcode (4.2.1, with Apple clang version 3.0), which might be a problem, but.. this should work regardless:
I create a new Quicklook plugin project ("File > New > New Project", then "System Plugin > Quick Look Plug-in")
Then I rename GeneratePreviewForURL.c to GeneratePreviewForURL.m (as mentioned in the Apple docs)
If I try and use any Objective-C code in the file, I get errors. For example if I add the following to the GeneratePreviewForURL method:
#include <Foundation/Foundation.h> // at start of file
NSMutableDictionary *blah;
[blah setValue:#"valuething" forKey:#"keything"];
I get the following linker error:
Undefined symbols for architecture x86_64:
"_objc_msgSend", referenced from:
_GeneratePreviewForURL in GeneratePreviewForURL.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The slightly trimmed/reformmated linker command causing the problem is:
cd ~/QuicklookExample
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang
-arch x86_64 -bundle
-isysroot /Developer/SDKs/MacOSX10.7.sdk
-L/snip -F/snip -filelist /snip/QuicklookExample.LinkFileList
-mmacosx-version-min=10.7
-framework QuickLook
-framework ApplicationServices
-framework CoreServices
-framework CoreFoundation
-o /snip/QuicklookExample
You have to add at least Foundation framework to the linked libraries.
Note that what's missing here is libobjc which should be linked directly by the fact clang should understand your code is actually Objective-C.
I have no experience at all at objective-c, only now started.
A developer I work with had to go abroad for a few days, and by mistake left an error in the code, and now I cannot compile an Iphone application to finish it...
I got some information from him by mail, and he told me that he left a library that is called dialog and that I need to remove it to make it work...
The thing is that I have no experience in objective-c and Xcode... i'm the web developer :)
i tried to run the project, and got this error:
Build target mormar
Ld
/Users/yanivshimony/Library/Developer/Xcode/DerivedData/mormar-cxfykryhzfovlbgtsjfowgleiyxu/Build/Products/Debug-iphonesimulator/mormar.app/mormar
normal i386
cd /Users/yanivshimony/Desktop/mormar
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.0.sdk
-L/Users/yanivshimony/Library/Developer/Xcode/DerivedData/mormar-cxfykryhzfovlbgtsjfowgleiyxu/Build/Products/Debug-iphonesimulator
-F/Users/yanivshimony/Library/Developer/Xcode/DerivedData/mormar-cxfykryhzfovlbgtsjfowgleiyxu/Build/Products/Debug-iphonesimulator
-filelist /Users/yanivshimony/Library/Developer/Xcode/DerivedData/mormar-cxfykryhzfovlbgtsjfowgleiyxu/Build/Intermediates/mormar.build/Debug-iphonesimulator/mormar.build/Objects-normal/i386/mormar.LinkFileList
-mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300 -framework UIKit -framework Foundation -framework CoreGraphics -o
/Users/yanivshimony/Library/Developer/Xcode/DerivedData/mormar-cxfykryhzfovlbgtsjfowgleiyxu/Build/Products/Debug-iphonesimulator/mormar.app/mormar
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CATransition", referenced from:
objc-class-ref in LoadingView.o "_kCATransitionFade", referenced from:
+[LoadingView loadingViewInView:] in LoadingView.o
-[LoadingView removeView] in LoadingView.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with
exit code 1 (use -v to see invocation)
after googling this for a while, I still have no idea how to solve this...
I would greatly appreciate any help,
thanks!
You need to link against QuartzCore.
Click on your project name in the Xcode sidebar. Then click on your target, and in the Summary tab find the list of linked frameworks and libraries. Click the plus button below this list, and add QuartzCore.
You need QuartzCore framework. Add it to your project (through project setting's "Link binary" build phase). Add the #import <QuartzCore/QuartzCore.h> to project's prefix header (usually Prefix.pch or {ProjectName}-Prefix.pch). This should solve the problem without removal of this library.
This is driving me crazy, when i try to compile on the simulator, everything is ok, but on the device i got this error:
ld: library not found for -lz
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1
Please help me understand the source of the problem:
Ld /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos/Fontenay-sous-Bois.app/Fontenay-sous-Bois normal armv7
cd /Users/ZConsulting/Desktop/Fontenay-sous-Bois
setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products
/Debug-iphoneos -F/Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
/iPhoneOS5.0.sdk/Developer/Library/Frameworks -filelist /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Intermediates/Fontenay-sous-Bois.build/Debug-iphoneos/Fontenay-sous-Bois.build/Objects-normal/armv7/Fontenay-sous-Bois.LinkFileList -dead_strip -fobjc-arc -miphoneos-version-min=5.0 -framework SenTestingKit -lz -lz.1.1.3 -framework MobileCoreServices
-framework SystemConfiguration -framework CFNetwork -framework CoreLocation -framework MapKit -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos/Fontenay-sous-Bois.app/Fontenay-sous-Bois
EDIT:
I did import the libz.1.1.3.dylib framework:
The only libz that i got in the Linked frameworks is the libz.1.1.3.dylib
You did specify the library libz.dylib in the Linked frameworks and Libraries item rather than the direct reference to libz.1.1.3 - in general you should use the most generic version of a library for compilation rather than a more specific one
Secondly, make sure that the libz.dylib is present under the iOS SDK - if it's missing, then it may be a mis-installed SDK (reinstall should fix that).
i.e.
find /Developer/Platforms -name libz.dylib
should result in a non-empty output for a libz.dylib under iPhoneOS5.0.sdk
Also see the answer to iPhone - Linker Error in Xcode 4.2 Preview, which is a similar issue to this.
i got the same error with a different library:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
to resolve this, under search paths -> user header search paths -> release i put:
"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include"
keep in mind that I get this bug only when I archive, and my archive is a based off my release scheme..
update:
I got the same problem (on a different occasion/project) for the lpods Library (ie cocoapods).. the way i figured out to solve this is by realizing that the build worked fine on my development scheme but not my debug scheme. basically the development scheme had no for build active architectures only whereas debug had yes. I simply changed debug to no in all the targets under cocoapods