Using DTCoreText with RubyMotion - ios

I'm currently working on my first major RubyMotion application. I have a lot of html text to display, and want to move away from using UIWebView -- as it's a bit of a hack and it's hard to size correctly without a lot of hoops. So, one of my options is DTCoreText, which seems like the most used and stable control of this lot.
I originally tried to use the CocoaPod version, but for some reason it's causing issues with MKNetworkKit from another pod. I messed with it for a bit, but saw that there are a lot of reported issues in MKNetworkKit about the build process, so I best left it alone.
Instead, I went for the vendor option. I git cloned the DTCoreText repo into my vendor directory and added it to my project. While it gets me closer by compiling the library and making my libDTCoreText.a file, I'm still stuck after actually running it.
My Rake files includes this (the rest is pretty generic):
app.vendor_project('vendor/DTCoreText',
:xcode,
:target => 'Static Library',
:products => ['libDTCoreText.a'])
app.libs << '/usr/lib/libxml2.2.dylib' #For DTCoreText
Like I said, the libDTCoreText.a file gets compiled and copied into the right place in my project.
My app has this in the code. It's as basic as possible -- I just wanted to see it work.
#source = DTAttributedTextView.alloc.initWithFrame(CGRectZero)
#source.attributedString = NSAttributedString.alloc.initWithHTMLData(post.source.dataUsingEncoding(NSString.defaultCStringEncoding), options:{}, documentAttributes:nil)
#source.frame = [[self.frame.size.width / 2 - size.width / 2, 600], [250, 250]]
The application compiles, fine but at runtime when we hit the code above, it crashes with:
Objective-C stub for message `initWithHTMLData:options:documentAttributes:'
type `##:##^#' not precompiled. Make sure you properly link with the framework
or library that defines this message.
*** simulator session ended with error: Error Domain=DTiPhoneSimulatorErrorDomain
Code=1 "The simulated application quit." UserInfo=0x10019d470
{NSLocalizedDescription=The simulated application quit., DTiPhoneSimulatorUnderlyingErrorCodeKey=-1}
Does anyone have any ideas where I can start looking? I don't know a ton about the XCode build process yet, so it's possible I'm missing something. But it just seems like it should work. It's saying to me that it can see the headers correctly (and can compile), but it doesn't know where the actual library is.

Well, I have relevant experience with DTCoreText but none with RubyMotion. DTCoreText uses categories, and as such has special load requirements. In my Xcode project, in "Other Linker Flags", I have this: -force_load $(BUILT_PRODUCTS_DIR)/libDTCoreText.a
That line insures that the library is properly loaded. If you don't do that, you get crashes when you try to use it.
I've been very happy using DTCoreText now for a year, and IMHO its a much better solution for attributed text than using UIWebViews.

Related

Transferring Xcode Project from one computer to another brings random errors?

I have a Xcode project I got from another developer. Initially when I opened it it has a bunch of errors (most of which were un-updated frameworks). I got it to work after a while and I fixed it. I want pass it back to the manager since I'm leaving uni in a few months. I copied it over to my friends Mac to see what would happen if I just took the project and all it's folders and made it a zipfile. It didn't work for some reason. It gave me an error:
error: using bridging headers with framework targets is unsupported
But why did that come up? I mean it's the same code on the slightly different versions of Xcode (13.1 versos 14.1) but I doubt there was a massive change between the two that would cause this. I want to be able to pass these app later in the future without having to care about this stuff. I made a GitHub (link below) would cloning that work? Also the laptop I chose was just a fresh reset. Would it be due to not having coco-pods installed?
I feel like I could go through and fix it all on that laptop and document that but then I'm afraid that every time I put it on a new one it would come up with random errors every single time making my documentation moot.
https://github.com/AbdullahMSaid/SonicExperiment-Works
With big help this was Fixed.
Things that fixed it.
Having the correct version of Xcode
Turning everything from absolute path to relative
Lots of other code fixes. But those are my project specific.
You don't need bridging headers in framework. Use should have something like "YourFramework.h" where you can import your .h files.

Class GAD_GTMStringEncoding is implemented in both <framework> and <app>. One of the two will be used. Which one is undefined

I have an iOS project in Xcode. It contains a load of linked libraries including GoogleInteractiveMediaAds.framework as well as an internal player library that I believe is also linked against this framework. Both are also embedded binaries.
The project compiles just fine but at runtime I get the following error:
Class GAD_GTMStringEncoding is implemented in both
/GoogleInteractiveMediaAds.framework/GoogleInteractiveMediaAds
and APP_PATH. One of the two will be used. Which one is undefined.
On simulator the app works as expected every time despite this warning - I get the pre-roll, mid-roll and post-roll ads that I'm expecting. Every time. On device it's a different story with the ads sometimes working and sometimes not. I'm aware that the above issue results in different behaviour on different targets and I suspect this conflict is to blame for the broken functionality on devices.
Solutions I've found here on SO suggest either changing the namespaces or removing the linkage from either my app or the library that I'm linking against. The problem is, if I remove the embedded binary in my project then it fails to compile:
dyld: Library not loaded:
#rpath/GoogleInteractiveMediaAds.framework/GoogleInteractiveMediaAds
Referenced from: APP_PATH
Reason: image not found
(lldb)
I've seen a few people suggest what would be removing the linkage from the app and using the player's internal instance (where I then have to hope that the player is compiled against the version that I need), but how on earth do you do that? And would that even work in this case?
Also, is there a way to find out for sure where this other instance of GoogleInteractiveMediaAds.framework is coming from? I'm only assuming that it's inside the internal player library but I don't know for sure as I don't have the source. The error message just provides me with the path to the compiled app which is of little help since there's like 30 linked libraries inside it.
Thanks in advance.
After initially insisting that the issue was somewhere in our code, the Google team responsible for this framework were eventually forced to admit (after we provided a sample app) that it was a problem with their code and not ours. It was resolved in an update.

AS3 Multiple Application Domain using local null.swf file

I have the following issue, I cannot find a solution on the web, please let me know if you can help me or point me to a proper info about this issue.
To understand the background, Im porting a game from flashDevelop to Flash Builder (please dont give me tips about this comment if doesn't help to my particular problem). Everything works fine right now, the game use a file null.swf as a container of local files (I don't undertand that part completely, but the game has a lot of embed swc files, and the game use the null.swf to access those files, through LoaderMax).
The problem is that everything works fine with a fast build, but it's not working with a standard build, I have the error on Loader class that says "Multiple application domains are not supported on this operating system".
Useful information:
Im using AIR 3.9, compilation flash swf-version=20 (I had 18 when I started with this issue)
null.swf is properly included on the IPA, the code recognize the file, and as I said before it works with a fast build.
For embed swc files, I had to include the files with a compiler argument: "-include-libraries ../../filename.swc ../../filename2.swc etc.."
Thanks for any help.
Regards
It's fixed, using a context:
context = new LoaderContext(false, ApplicationDomain.currentDomain, null);
If I use the third parameter, like ..., SecurityDomain.currentDomain); it doesn't work.

write an iOS 5.1 app that uses a web service

I am fairly new to iOS programming and I'm trying to make an iOS 5.1 app that communicates with a server to receive information from a database. I got the server returning the needed information from the database by following this tutorial:
http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app
But then I tried to follow a the other half of the tutorial by the same guy:
http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service
In this one we use JSON, ASIHTTPRequest and MBProgressHUD, but I get a lot of errors when I run this because ASIHTTPRequest is no longer supported in iOS 5.1.
Can anyone point me in the right direction here? I you can show me another tutorial that works for iOS 5.1 that would be great. I have looked but I can't find any.
Thanks
ASIHTTPRequest is most likely returning errors in your iOS 5.1 app because you're using ARC. ASIHTTPRequest wasn't written in ARC, which is why it's throwing tons of errors. But there's an easy workaround:
In Xcode 4's groups and files pane, select your project file at the top of the list.
Select your target towards the left hand panel.
You should now see a list of all the implementation (.m) files referenced and compiled throughout the course of the program.
Double click the implementation files for ASIHTTPRequest and add the following linker flag: -fno-objc-arc. This linker flag acts as a crossbridge between the old non-ARC files and your ARC-based project.
Although there may be residual warnings left, this trick should remove all other error messages associated with ASIHTTPRequest.
When I followed that same tutorial I got a lot of errors. and the build kept failing until I reliased it was because libz.1.2.3.dylib wasnt there. If you go to Build Phases, remove that from the list and add libz.1.2.5.dylib all mine worked first and I got the app working fully :)

Including a C++ header in an Objective-C project yields "Expected * before *" errors

I'm new to Objective C and (unfortunately) also to the project I am working on. I was given a small sample project that refers to work from my predecessors (in C++) and uses it for an iPhone app (Objective C). Rather than extending the sample (it was quick n dirty and I didn't wanna mess around in it) I created a new project from scratch for my stuff. To get it working I need to set up the same links to the previous libraries as the other one, but although in my settings I can't find any differences to the existing project it won't do the trick.
With the help of colleagues and Google I reached this:
1) The project includes two library files, libyid.a and libvrpn.a, via Xcode's "Add files" dialogue. It automatically added the libraries' paths to the Library Search Paths in the Build Settings and the files show in the projects folder structure in XCode.
As far as I can tell this bit seems not to cause problems.
Edit: if i remove these files from the project I get the same errors. I'm now thinking that XCode can resolve the headers, but can't find the implementation and that the libraries may have been there but not been properly set up?
2) One of my custom classes uses
#import "DisplayYid.h"
I added the path to the file's location to the "Header Search Paths" in the Build Settings and it seems to be found alright. (I also added the file via the "Add files" dialogue at some point, but it didn't change anything, so I left it this way)
Now the problem: in
#interface YidController : NSObject {
DisplayYid *myYid;
// (etc. etc.)
}
the identifier "DisplayYid" seems to remain unknown (Error: Expected specifier-qualifier-list before DisplayYid). In addition, all the class definitions in the headers that DisplayYid itself includes yield
error: expected '=', ',', ';', 'asm' or '__attribute__' before '__declspec'
My knowledge here is unfortunately very limited, but it seems to me that XCode can find the headers in question, but somehow would expect the content in a different format/language?
When I had DisplayYid.h included as a file in the project hierarchy I tried to set its file type in the file inspector to "C++ header" (as suggested by some hits I found on Google for my problem), but this doesn't change a thing.
I feel I am missing some tiny but crucial detail, but am not sure-footed enough in any of this to test around further. Hopefully somebody sees my missing link? And sorry if this is too lengthy, I simply tried to include the detailed steps in case this is were the problem lies.
Thanks in advance for your time ;)
EDIT: This question seems to be the same problem, especially the fact that he gets the error multiple times from files simply copied. But none of the suggested solutions seem to work for me.
It's been a while now, but I got hold of the guy who worked on this previously. It took him an hour, but he found the missing bit: In the project settings, two compiler flags needed to be set:
-DIOS (defining the flag iOS)
-x objective-c++
From there on everything went fine. Since this was a rather project-related question and solution, should I delete it all together?

Resources