How can I make a reference to another project in xcode 4.2?
I trying to put Protocol Buffers working in Objective-C but I can't do this:
Open your existing project and a reference to the ProtocolBuffers project found in .
Add a reference to /Classes/ProtocolBuffers.h in your project and add the following line to your pch file: #import "ProtocolBuffers.h"
Get Info on your build target
Add ProtocolBuffers as a Direct Dependency of your build target.
Add libProtocolBuffers.a as a Linked Library of your build target. You may have to do this by dragging and dropping the library from the referenced ProtocolBuffers project to your target's Link Binary With Libraries section.
I solved the problem. For making the reference just add to the main project the xcodeproj file of the another project. And then add as Direct Dependency and Linked Library.
Related
My project (Objective C, macOS, Xcode 11) does not use CocoaPods and I'd like to keep it that way.
I want to use libxlsxwriter to export data in Excel format. I cloned libxlsxwriter from GitHub and built it. Now I have libxlsxwriter.a and lbixlsxwriter.dylib.
What I tried so far: I followed the instructions on this site (thanks for the link) to include the dylib. In the "General" settings lbixlsxwriter.dylib is shown as "Embed & Sign", in "Build Phases" it is listed under "Link Binary With Libraries" and it has its own "Copy Files" section. Running from Xcode gives me
dyld: Library not loaded: /usr/lib/libxlsxwriter.dylib
Referenced from: /Users/XXX/Library/Developer/Xcode/DerivedData/XXXefxsacdsioejobcumpvsbklqguri/Build/Products/Debug/XXX.app/Contents/MacOS/XXX
Reason: image not found
What do I have to add to my project: The include folder with all the header files and both of these libs? How do I have to adjust the General settings and Build Phases?
If you have static library and only one loader, eg. main executable, (so you don't need to share it between your components), then you don't need dynamic library at all.
Just add your libxlsxwriter.a into Target > General > Frameworks and Libraries section, and it will be linked in into your executable and just work.
If you really need shared dynamic library then you need to use rpath + LD_RUNPATH_SEARCH_PATHS combination. (Let me know if you need more details on this).
We can use iOS Static Libraries without adding header files into the project.
But i want to use the Static Libraries without adding .a files into the project
Finally, I found the solution
Path of the static library should be added in ->target->build settings-> Other Linker Flags
eg.)
/Source/iPhoneApp/libs/Connection/build/Debug-iphonesimulator/libConnection.a /Source/iPhoneApp/libs/SocialNetwork/build/Debug-iphonesimulator/libSocialNetwork.a
If you built the library, you can use dependencies to add the library project to your app project without the hassle of configuring stuff.
To do so, just drag the .xcodeproj file from your library to the app project, go to the app target properties, and add a dependency on that library, just as you'd add a public framework such as MapKit.
My Problem
I getting "_OBJC_CLASS_$..., referenced from:" linker error when compiling some Xcode projects (it happens in both iOS and Mac projects) I have correctly linked frameworks and imports.
Setup
One application target
One test target
All frameworks linked correctly
On compile I get the following linker errors:
"_OBJC_CLASS_$_JGCountdownTimer", referenced from:
objc-class-ref in JGCountdownTimerTestCase.o
for many classes that are used in tests.
What I've Tried
Checked that imports are all present
Removed all non standard frameworks
If I compile a class for both the test target and the app target it fixes the issue. But then I get other warnings from the compiler.
I faced a similar problem. I got the linker error:
_OBJC_CLASS_$_MyClass
The problem was that I had declared an #interface for MyClass but had not declared its corresponding #implementation.
The fix was to simply add
#implementation MyClass
#end
Quick Answer
Copy and paste the following line into your build settings:
GCC_SYMBOLS_PRIVATE_EXTERN = NO
In the target build settings look for "Symbols Hidden by Default". For the Debug configuration you want "No".
I've had this problem on and off for many months and I've just discovered why.
Not sure if this could be the problem, but with the new compiler, any obj-c that aren't explicitly referred to/invoked will not be linked from libraries. This causes problems when you implement categories in libraries for example.
Try adding '-ObjC' to 'additional linker flags' in the build settings panel for your target. shrug
objc_class_$textfieldvalidator referenced from
Compile doesn't include those copied files in its compile list. To fix this error
select the file or folder, then go to the Build Phases panel and open the Compile Sources step, then click the + button and add them all file or folder.
Right click on a project folder, click "Add Files to ...", select the file(s), click the Options button and select the target, then click Add.
I need to weak link some framework with my target.
But I can't find how to do it...
If I try to run my project on 3.2 iPad simulator i get the following error:
dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd
Reason : Image not found
Thanks !
Go to your project -> Targets -> Build Phases -> Link Binary with Libraries.
Then change the library you want to weak-link from "Required" to "Optional".
This doesn't work now. Please follow the link below:
https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
Select the target you want to modify and reveal its build phases.
Expand the Link Binary With Libraries build phase to view the frameworks currently linked by the target.
If the framework you want to weakly link to is listed in the Link Binary With Libraries build phase, select it, and choose Edit > Delete to remove it.
Now you can tell the linker to use weak linking for that framework.
Select the target, open its Info window, and click Build.
To the Other Linker Flags build setting, add the following command-line option specification, where FRAMEWORK_NAME is the name of the framework you want to weakly link to:
-weak_framework FRAMEWORK_NAME
Build your product.
I'm currently busy on a project where I need to use an external accessory to read Mifare 1k tags.
The accessory was provided with an SDK, written in (Objective ?)C++ and I followed the instructions provided to set XCode to "Compile sources as: Objective-C++" and added "-Obj-C++" in "Other linkers flags.
The SDK compiles fine then, but trouble is I am already using several libraries in the project (such as ASIHTTPRequest, JSONKit, ...) and I get compilation problems because of those new settings in those libraries. If I switch back to the previous settings, I get compilation problems in the reader's SDK
The question is: is there a way to compile only the class from the SDK as C++ and the rest of the project as objective-c ?
Edit: the SDK files consists only of .h (and a linked library)
thanks for your help,
Mike
Select the file you want to compile as Objective C++ from the file navigator, and then select the File Type in the file inspector view. This is in Xcode 4, but there is a similar mechanism in Xcode 3.
Try renaming the files where you are including the library headers to myClass.h for interface and myClass.mm for implementation files. This forces the files to be compiled as objective-c++.
I have resolved this problem:
You should set "According to file type" to "Complile Sources As",
Set "-ObjC++" to the "Other Linker Flags"
The last,you should modify the files's suffix to .mm that reference
the library method
well, in Build phases tab, there is a section Compile sources. For file you want to use Objective-C++ compiler add flag: -xobjective-c++
tested in Xcode 12.5