EXC_BAD_ACCESS from JSONKit - objective-c

I keep running into EXC_BAD_ACCESS when calling [obj JSONString] method in the following code and I don't know why. I have tried turning on Zombie Objects but nothing different happens.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSDictionary *obj = #{
#"id": #1,
#"date": #"11/07/2012",
#"companyInfo": #"Company Details",
#"customerInfo": #"Customer Details",
#"taxRate": #0
};
NSLog(#"%#", obj);
NSLog(#"%#", [obj JSONString]);
// Other stuff here
}
I am running Lion. I have just upgraded to Xcode 4.4 and am using CocoaPods 0.9.2 to install JSONKit. I have tried both the 1.4 and 1.5pre versions of JSONKit to no avail.
I am using the latest OS X SDK (10.8) with a deployment target of 10.6 (it must deploy to 10.6). I have also tried the 10.7 SDK but the results are the same. The 10.6 SDK is no longer available so I cannot test that.
clang --version shows:
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
The application compiled and ran correctly when I was using Xcode 4.3.

It turned out that the problem was that CocoaPods does not remove the existing JSONKit files when running pod install. I'm using version 1.5pre and the code executes correctly.

Related

OTPublisherSettings *settings = [[OTPublisherSettings alloc] init]; getting Bad receiver type 'int32_t' (aka 'int')

While compiling
OTPublisherSettings *settings = [[OTPublisherSettings alloc] init];
getting compiler error.
Bad receiver type 'int32_t' (aka 'int')
Using the latest Xcode, happening on all unmodified sample apps, looked in lib headers dir under Pods, Found the OTPublisher.h and OTPublisherKit.h headers, cannot seem to find the OTPublisherSettings class. Am I missing something?
I just did a fresh install of sample apps with pod install without any errors. Did you see any issues when you were trying to install the SDK using cocoapods. What SDK version are you using ?

Receiving build failed error "Use of undeclared identifier 'ParseClientConfiguration'"

Screenshot of error
Long time lurker, first time posting. I am attempting migrate my parse.com db to back4app. The migration has gone flawlessly, but now I'm running into trouble changing where the app points to access the parse server. The code I am using came straight from back4app's guides here.
I am running Xcode 8.0, and the app is designed for a minimum of iOS 9. I am using cocoa pods to manage parse as well as several others, so I have the latest version of cocoa pods (1.1.1) and the latest version of parse (1.14.2).
It seems that several solutions for my error have suggested making sure Xcode and the parse pod were up-to-date. Which they are. Another person said they had issues, even though the parse pod said it was updated, the old pod was still being used. I removed parse form my podfile, ran pod update and install, then reinserted parse in the podfile to run 'pod install', but same results.
Anyone have any suggestions?
#import <Parse/Parse.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Set up Parse
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = #"....";
configuration.clientKey = #"....";
configuration.server = #"https://parseapi.back4app.com";
}]];
return YES;
}
I hope this helps others that have this or similar issues. I found that there was on old 'parse.framework' file in my workspace directory. Not sure if all these steps are necessary, but here is what I did...
Removed 'pod Parse' from podfile
Ran 'pod update' in terminal
Deleted remaining 'parse.framework' file
Re-added 'pod Parse' in podfile
Ran 'pod update' in terminal
Runs like a charm.
In addition to removing parse.framework from your Xcode project, open up your finder and remove parse.framework from your app directory as Xcode default build settings will include your directory to search for frameworks.

Undefined symbols for architecture x86_64 but error resources are inside built framework

I start develop iOS app using framework code I built myself from source code.
I added needed architectures to framework project and built framework, that add it to my application.
And when I tried to build application, Undefined symbols for architecture x86_64 errors was appeared, eg:
"_AES_ige_encrypt", referenced from:
_MTAesEncryptInplace in MTProtoKit iOS (MTEncryption.o)
_MTAesEncryptInplaceAndModifyIv in MTProtoKit iOS (MTEncryption.o)
...
"_AES_set_encrypt_key", referenced from:
_MTAesEncryptInplace in MTProtoKit iOS (MTEncryption.o)
_MTAesEncryptInplaceAndModifyIv in MTProtoKit iOS (MTEncryption.o)
...
And many others, not only at MTEncryption
I looked framework source, file MTEncryption.m:
void MTAesEncryptInplace(NSMutableData *data, NSData *key, NSData *iv)
{
AES_KEY aesKey;
AES_set_encrypt_key(key.bytes, 256, &aesKey); // <-- _AES_set_encrypt_key
unsigned char aesIv[AES_BLOCK_SIZE * 2];
memcpy(aesIv, iv.bytes, iv.length);
AES_ige_encrypt(data.bytes, (void *)data.bytes, data.length, &aesKey, aesIv, true); // <-- _AES_ige_encrypt
}
These methods are in .../openssl/aes.h that is already included to build phases.
But I noticed that aes.m file is missing (not just missing in build phases but file doesn't exist).Is it normal? Or exactly .m files missing is build failing reason? But if it's the reason, how framework was built successfully?
From scouting around the simulator files, i can't see a definitive iteration of aes or openssl which come "part and parcel".
On that note, you'd have to compile your own OpenSSL to support these missing libraries.
I did find a github repo for you that could be of help:
https://github.com/x2on/OpenSSL-for-iPhone
Hope this helps..

CFURLResourceIsReachable failed because it was passed this URL which has no scheme

I have a Cocoa program with deployment target 10.7, using the latest (10.8) SDK, I run it on 10.7.5 with XCode 4.6.2. In it I work with NSURLs with no problem whatsoever, everything works fine. One method I use is the NSURL method:
[newURL checkResourceIsReachableAndReturnError:&error]
with newURL a pointer to aNSURL. So far so good.
However, when I compile and run this, on a mac mini with Mountain Lion installed the following warning appears:
CFURLResourceIsReachable failed because it was passed this URL which has no scheme
and some other things now go wrong as well, such as
[dict setObject:url forKey:[url path]],
with dict a NSMutableDictionary and url a NSURL, the url simply is not added anymore to the dict. Strange isn't it? Did I miss a change in how NSURLs work from OS X 10.7 to 10.8?
Apologies if this already has been discussed here (I could not find it), thanks for looking at this question,
Marijn

How to access weak linked framework in iOS?

I want to use Twitter framework for iOS 5, but be able to run my app in older OS.
I added weak referenced framework (i.e. set "optional" flag) in Xcode 4.2 Target settings. Base SDK is iOS 5, iOS deployment Target is iOS 3.2.
Next, I try to use Twitter framework:
#import <Twitter/Twitter.h>
...
Class twClass = NSClassFromString(#"TWTweetComposeViewController");
if (!twClass) // Framework not available, older iOS
{
[self shareWithTwitterPriorIOS5];
return;
}
if ([TWTweetComposeViewController canSendTweet]) // Check if twitter is setup and reachable
{
TWTweetComposeViewController* twc = [[TWTweetComposeViewController alloc] init];
// [twc addURL:[NSURL URLWithString:#"http://mail.ru"]];
// [twc addImage:[UIImage imageNamed:#"Some image.png"]]
[twc setInitialText:textToShare];
[viewController presentViewController:twc animated:YES completion:^{
// Optional
}];
[twc release];
// Assume twc is ARC released or call [twc release];
}
else
{
// Twitter account not configured, inform the user
}
It run well on iOS 5 simulator. As soon as I try to use simulator or real device with older OS version, I get error "Twitter/Twitter.h" file not found (in compile time). If I remove "#import" directive, I get a couple of errors TWTweetComposeViewController class not found.
If I comment all twitter-related code, I get linker error: "ld: framework not found Twitter". Ld command caused error:
Ld /Users/mikhailkeskinov/Library/Developer/Xcode/DerivedData/Dictionary-eiyrziajmltuglfzgtnjxffkojwi/Build/Products/Debug-iphoneos/Dictionary.app/Dictionary normal armv6
cd /Developer/WorkShop/XDictionary/trunk
setenv IPHONEOS_DEPLOYMENT_TARGET 3.2
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 armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk -L/Users/mikhailkeskinov/Library/Developer/Xcode/DerivedData/Dictionary-eiyrziajmltuglfzgtnjxffkojwi/Build/Products/Debug-iphoneos "-L/Developer/WorkShop/XDictionary/trunk/Dictionary/Twitter+OAuth/Libraries & Headers" -F/Users/mikhailkeskinov/Library/Developer/Xcode/DerivedData/Dictionary-eiyrziajmltuglfzgtnjxffkojwi/Build/Products/Debug-iphoneos -filelist /Users/mikhailkeskinov/Library/Developer/Xcode/DerivedData/Dictionary-eiyrziajmltuglfzgtnjxffkojwi/Build/Intermediates/Dictionary.build/Debug-iphoneos/Dictionary.build/Objects-normal/armv6/Dictionary.LinkFileList -dead_strip -miphoneos-version-min=3.2 -lxml2 -framework AVFoundation -framework UIKit -framework Foundation -framework CoreGraphics -lOAuth -weak_framework Twitter -o /Users/mikhailkeskinov/Library/Developer/Xcode/DerivedData/Dictionary-eiyrziajmltuglfzgtnjxffkojwi/Build/Products/Debug-iphoneos/Dictionary.app/Dictionary
What is wrong in here?
After 5 hours, tons silly documentation reader, changing all target & project settings etc. I at least come to solution. Turns out it is pretty easy, when you know it. Probably, my answer will save somebody's day.
As you can see, real device destination ("mkeskinov's iPod") doubled. I never pay attention at this fact. It looks like it just doubled by some mistake, but it is not. If you select "Product\Edit Schemes" & open Destination list (on the top of window), you can clearly see the difference:
What I need to do to successfully compile app for real device - just select second option. It will compile for iOS 5 and then run on real device with OS 4. First option means that it will be compile for iOS 4, and if you have any references to Frameworks, which is not presented in iOS 4 (never mind, weak references or strong) - you get compile time error.
Your code is probably fine.
You absolutely want to build your app against the iOS5 SDK. The binary you produce will run on older iOS versions (provided your target SDK is an older version, as you have indicated).
Your code is correctly checking for iOS5 capabilities and doing the right thing, and you are correctly weak linking to the Twitter framework. It is these techniques that allows your app (built against the latest SDK) to run without crashing on older iOS versions.
Add this to your header file .h:
#import <Twitter/TWTweetComposeViewController.h>
Here is what I have used for my app:
if ([TWTweetComposeViewController class])
{
//can tweet
} else
{
//can't tweet
}
Instead of using import, you should reference the TWTweetComposeViewController class using the Class object you got from NSClassFromString(), e.g. [twClass canSendTweet] instead of [TWTweetComposeViewController canSendTweet].