How to link to libz and libsqlite in xcode 7 beta? - ios

I got linkage error like:
+[WeChatApiUtil DecodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
"_deflate", referenced from:
+[MTAWXOHelper GZip:Out:] in libWeChatSDK.a(MTAWXOHelper.o)
"_deflateEnd", referenced from:
+[MTAWXOHelper GZip:Out:] in libWeChatSDK.a(MTAWXOHelper.o)
"_deflateInit2_", referenced from:
But I've already added those library to my target. But currently all those library have different extension .tbd.
Any idea? Thanks.

There is a known issue in XCode 7 while linking tbd files. Here is the link to the apple developer forum answer on how to link tbd files in XCode 7 - https://forums.developer.apple.com/message/8609#8609
[Snippet from the link is available below]
This is a known issue in the Xcode 7 beta.
To work around this issue for now, please:
Delete all references to .tbd files from either your linked libraries phase, or from the copied bundle resources phase (where they sometimes will be added).
Add the library you want to link manually to the "Other Linker Flags" build settings, by adding the argument: -l for each library you want to link (for example, add "-lsqlite3" (without quotes)).
For those who are curious, the .tbd files are new "text-based stub libraries", that provide a much more compact version of the stub libraries for use in the SDK, and help to significantly reduce its download size.

I have two project using zlib, one which finds it to link, one which doesn't. I set them both up by using the "+" in "Linked Frameworks and Libraries". I finally figured out how to fix the non-working one:
Remove all links to zlib that you added in previous attempts
Open Finder, head to /usr/lib, and drag the libz.dylib alias into your project's Frameworks folder
Compile. This worked on 2015/08/23 for me.

Related

xcode 7.1 for iOS 9 missing libc++.dylib required for Objective C Realm Static Framework

I am following this doc for integrating realm in my iOS app.
Realm static framework for iOS
My problem is in step 3. I am unable to find libc++.dylib. I find a few other .tbd ones but none of them are libc++.
I followed a few other SO posts on using the "add other" option and doing command+shift+G and find that library but it's not in that list either.
Does anyone know any workarounds?
I had the same problem. I found some kind of way around.
Go to Build Phases > Link Binary with Librairies > + > Add other
Once in the file selection window do "CMD"+Shift+G (Go to folder) and type /usr/lib/
From /usr/lib you can add : libc++.dylib and more...
Compile and have fun
This is a known issue in the Xcode 7 beta.
To work around this issue for now, please:
Delete all references to .tbd files from either your linked libraries phase, or from the copied bundle resources phase (where they sometimes will be added).
Add the library you want to link manually to the "Other Linker Flags" build settings, by adding the argument:
-l<library_name>
for each library you want to link (for example, add "-lsqlite3" (without quotes)).
For those who are curious, the .tbd files are new "text-based stub libraries", that provide a much more compact version of the stub libraries for use in the SDK, and help to significantly reduce its download size.
-- copy from link
finally, you can add -lc++ in this Other link Flags setting
I have same problem. I cannot find libc++.dylib through xcode but I found it using terminal.
You can copy or create a link to visible folder in xcode like /Users//Downloads.
Command below maybe help to fix the problem.
ln -s /usr/lib/libc++.dylib /Users/<your user>/Downloads/libc++.dylib
I had a similar issue with Realm the other week after the iOS 9 update. I know you already tried the method of going to build phases, add other, CMD + shift + G without success. However this was the method I used to locate libc++.dylib and I just checked it out again now and was able find it.
It is also worth mentioning that after you do manage to add libc++.dylib you may have build errors. In which case the fix I used was to go into your target's build settings and change Enable Bitcode to No.

Static lib linking error: Symbols not found for architecture

I need to link FFMPEG's libraries (libavformat, libavcodec, etc) to my project.
I have downloaded as an example iFrameExtractor project, and have successfully build it.
xcode-proj opens fine and the sample app works fine, so I just took libs from this project to my one.
But xcode fails to build it, saying me
Undefined symbols for architecture armv7:
"av_register_all()", referenced from:
I checked target settings, and I cannot see any difference between my project's settings and iFrameExtractor.
I just moved all ffmpeg folder to my project's folder.
Notes:
1) nm commands tells me that this symbol is inside the library.
2) library is fat-file, including i386, armv6, armv7 architectures.
Please, help me, what am I doing wrong?
I just went through this yesterday :-)
In xcode, you need to add the .a file to the list of linked libraries in the project. The easiest way to do that is by dragging the .a directly onto the project entry in the navigation area on the left:
Alternatively, you can select them from the dialogs in the summary area of the project editor:
Just make sure you select the actual .a files, not the whole folder. Then, simply import their headers (as you are likely already doing...), and you should be good to go :-)

Getting error "Undefined symbols for architecture i386" in xcode when headers are not missing

When I try to compile my iPhone app and run it in the simulator I get errors complaining about undefined symbols.
All of these symbols correspond to classes that are in included and not missing in my project.
Example:
"_OBJC_CLASS_$_SHKFacebook", referenced from:
objc-class-ref in FooAppDelegate.o
objc-class-ref in FooLandingPageViewController.o
objc-class-ref in FooAppDelegate.o
but SHKFacebook.h is not missing from the project.
Any ideas?
Thanks!
I have multiple Xcode targets in this project and when I added the files to the project I added them under the wrong target making them not visible to the target I was trying to build.
Is SHKFaceBook.h your file or a file from a library?
If its from a library click on your project target and select the Build Phases tab and then
select the Link Binary With Library section and make sure the library is added.
If SHKFaceBook.h is not from a library then the fact that the .h file is included is irrelevant if the corresponding .m file isn't present.
If the .m file is already in your XCode project then from the Build Phases tab select Compile Sources and make sure the necessary files are there.
FYI this is a link error, a link error is not the same as a compile error. Source files can compile with just the header, but they cannot be linked and built without the actual code. A header file is not code, it is more like a description of what is in the code.
It sounds to me like the library your linking against was only compiled for the arm platform, and not for the i386 - if you have the source try a clean / re-build?

How to link to coco2d static library (1.1 beta 2) using workspaces in Xcode 4.3.1

I have done the following so far:
Created workspace
Added my project
Added the Cocos2d iOS project (by dragging dropping into project navigator). It is a sibling of my project (not child).
In my project, in build phase, linked to libcocos2d.a
In build settings of my project - Set Always search paths to YES
Created source tree variable pointing to folder containing cocos2d iOS xcodeproj file.
In user header paths of my project, added source tree variable from step 6. Set as recursive.
8.In project navigator, clicked on libcocos2d.a library (it appears red). Set location "Relative to build products" You set this in the right most window in Xcode 4.3.1.
Closed workspace, and opened pbxproj file in TextWrangler. Searched for path containing libcocos2d.a Remove path, so the entry only reads "libcocos2d.a" . This is because after compiling the library is in the same build directory of the app anyway.
Codesense and autocomplete work. But this will not compile. Around 70 linker errors pop up when I try to build, all saying something like:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_CCDirector", referenced from:
objc-class-ref in AppDelegate.o
objc-class-ref in ViewController.o
"_kEAGLColorFormatRGB565", referenced from:
-[RIAppDelegate applicationDidFinishLaunching:] in AppDelegate.o
"_OBJC_CLASS_$_CCTexture2D", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_EAGLView", referenced from:
objc-class-ref in AppDelegate.o
If I try to build for the simulator, then instead of armv7, it says the symbols are missing for i386. The cocos2d project by itself compiles & builds fine. It is my project which has the above errors.
The cocos2d library is present in the build directory of my app after I try to build.
EDIT: Forgot to mention. I also edited the scheme for my project to not build in parallel. I also added the cocos2d target, and made it the top of the list (so it should build first).
EDIT: To clarify - after making the changes to the pbxproj file as detailed above, the libcocos2d.a file is no longer red. It looks normal. Also my app is also built, even though there are the link errors and the build fails. (It doesn't actually build, but the product is not "red". An app file is created in the same location as where the cocos2d library is produced.
I've been trying for a while to use Cocos2d as a static library, instead of a template. The reason being that it makes it easier to develop my project in a modular fashion. In addition, it makes it easier to switch between cocos2d versions and so on. After searching the cocos2d-x forums I found this link: http://cfc.kizzx2.com/index.php/cocos2d-x-with-xcode-4-from-scratch-without-template/
I found out the frameworks that I needed to add, and that solved all linking problems.
I still haven't submitted an application to the store, so if someone with more experience could look it over to check if there are any pitfalls / errors it would be great. English is a second language for me, so please don't mind. This was done using cocos2d1.1beta2 and Xcode 4.3.1
Create an Xcode workspace
Navigate to the folder containing the cocos2d xcodeproj file (iOS / Mac). This is where you unzipped cocos2d after downloading it.
Drag and drop the xcodeproj file into the navigator window of Xcode.(left most window).
Click on the tiny triangle near the cocos2d project file so all its contents disappear.
Add a new project to your workspace by right clicking in the navigator and "New Project". Make sure that the project is added as a sibling to the cocos2d project, and not as a child. I chose single window application (iOS)
In this new project, go to the build settings, and change "Always Search User Paths" to "Yes"
Add the location of your cocos2d folder to "User Header Search Paths". If you like you can instead add the cocos2d folder to your list of source trees in Xcode, and instead just fill in the name of the variable here. Eg: ${COCOS2D_SRC} . This is handy if later on you want to change the folder structure of build environment.
Click on the target and select the build phases tab. You want to link the following binaries with your library. Make sure they are there.
libcocos2d.a
libz.dylib
libxml2.dylib
OpenGLES.framework
QuartzCore.framework
UIKit.framework
Foundation.framework
CoreGraphics.framework
If libcocos2d.a is "red", then don't worry about it. It still compiles / links properly.
Under build settings, change "Build active architectures only" to YES.
Otherwise you may get an error ignoring file /Users/Pteriedaktyl/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/libcocos2d.a, file was built for archive which is not the architecture being linked (armv6)
In your info.plist file, make sure to remove the entry inside "required device capabilities" that says armv7. Otherwise, your code will only run on newer devices.
Now you're set! You should be able to access the cocos2d api from the sibling project. If you ever want to change your version of cocos2d, you just need to change the cocos2d project that is in the workspace, update the source tree path (if necessary), and link to the new libCocos2d.a
Testing:
Just to try it out, I modified the app delegate and view controller code to match the code from one of my old hello world projects.
Please try this out, and add to the thread if you have any problems.
In the Utilities pane for the libCocos2d.a, underneath the Identity and Type where you set the library to relative to Build Products, scroll to the bottom and make sure that the Target Membership is selected for your targets. If it's not, it won't include it in the actual build made by the target. At least, that was the only way I was able to reproduce this issue.

Problems adding Google Analytics to iOS App

When I run through implementing Google Analytics in my app, using this walk through:
http://code.google.com/mobile/articles/analytics_end_to_end.html
After adding the libGoogleAnalytics.a CFNetwork and libsqlite3.0.dylib frameworks, and added the GANTracker.h into my AppDelegate.m
I get this error:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_GANTracker", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
and the app won't even compile. My app is aimed at iOS 5.0
I'm pretty stuck. Any advice or work throughs would be very highly appreciated.
I actually figured out the answer after posting the comment.
Click on your project in the "Project Navigator", then click on your project under "Targets". You then need to click on "Build Phases". You need to make sure libsqlite3.0dylib and CFNetwork.framework are added to the "Link Binary WIth Libraries". I had this, but what I didnt have was you also need to add libGoogleAnalytics.a to that same area. That fixed the problem for me.
In my case, I add the AdSupport.framework for the missing "_OBJC_CLASS_$_ASIdentifierManager"
Just adding to the answer of #Etch.
Xcode 4.5 dropped armv6 and only supports armv7. Therefore, your lib might be an old version and you need to download version 1.5.1 onward. Download here
Issues: http://code.google.com/p/analytics-issues/issues/detail?id=232
I was working on a Cordova based XCode project. And got stuck with these stupid errors before figuring out what the linking errors meant. So here is what you do..
First, make sure you follow the steps mentioned https://github.com/phonegap/phonegap-plugins/tree/master/iOS/GoogleAnalytics. Next make sure you have the following files under the project linked via Build Phases (You get that when you click on the project name.. figure it out)
GANTracker.h
libsqlite3.0.dylib
libGoogleAnalytics.a
CFNetwork.framework
Also make sure your Plugins folder has 2 files, GoogleAnalyticsPlugin.h and GoogleAnalyticsPlugin.m.
If that doesn't help resolve your bugs. Then God help you. Start praying. Or alternatively try a bug spray. See if that works.
I had the same issue. The solution was move the library to same level of .h files.
But I don't know why this work.
In your Link Binary With Libraries under Build Phases under your target:
Make sure you remove libGoogleAnalytics_debug.a if you added it. And ensure you have AdSupport.framework and of course libGoogleAnalyticsServices.a.

Resources