Skip to content

Framework Development with Objective C and Swift

Provided below are the learnings I had as part of creating Frameworks with Objective-C and Swift Code.

Learning 1 (No bridging header required for interoperability for the Framework Targets)

There is no support for swift bridging headers in Xcode Framework Projects.

But how do you write Objective-C and Swift in same Project?

Just import your framework as a module in your swift class where you wanted to use the objective C created class.

Even if you try to add the bridging header manually, in a framework project, Xcode spits this below message.

“using bridging headers with framework targets is unsupported”

Digging Apple’s documentation gave the idea that, you do not need a Bridging header in Frameworks. You need bridging headers only for applications.

Learning 2

Learning 3

To access swift methods of  Framework you should make them public 

The github project provides an example.

Personalizing The Factory

Featured Image -- 1442

Originally posted on TechCrunch:

[tc_contributor_byline slug=”jose-ferreira”]

Winston Churchill famously said, “Democracy is the worst form of government, except all the others that have been tried.”

Until recently, the same could be said for the factory model of education. Imported from Prussia and implemented at the urging of education reformer Horace Mann, the factory model puts kids into age-based classrooms and uses seat time to determine when they’re ready to move on to the next level.

In many ways, it’s an awful system; rigid, arbitrary and impersonal. But it’s also responsible for almost every modern innovation we rely on today. The factory model reduced the per-student cost of education sufficiently so that wealthy countries could, for the first time ever, provide free and compulsory K-12 education to all children.

Wherever the model doesn’t exist, the populace desperately wants it. Modern medicine, housing, entertainment, transportation, communication, the Internet and everything else in the modern world…

View original 966 more words

Difference between Set (Swift ) and NSSet

One major difference I have observed between Set introduced as part of Swift and NSSet which is already available in Foundation framework is the way isSubSet method works in both.

NSSet does not bother the difference between a proper subset and a subset. But Set in Swift has method called

isStrictSubsetOf  in addition to isSubsetOf  which captures the scenario which Foundation fails to.

Swift Set

var set1 = Set(["r","a","m"])
var set2 = Set(["r","a","m"])

var bool = set1.isSubsetOf(set2) as Bool
var bool1 = set1.isStrictSubsetOf(set2) as Bool

 bool = set2.isStrictSubsetOf(set2) as Bool

 

Foundation NSSet 


NSSet *set1 = [NSSet setWithObjects:@"a", @"b", @"c", nil];

NSSet *set3 = [NSSet setWithObjects:@"a", @"b", @"c", nil];;

NSLog(@"isEqual :%d", [set1 isEqualToSet:set3]);

NSLog(@"isSubSet :%d", [set1 isSubsetOfSet:set1]);
<pre>

For differences between Proper Subset and Subset
https://www.mathsisfun.com/sets/sets-introduction.html

Warning :-Presenting view controllers on detached view controllers is discouraged

This log message I received when I was running my app  and it led to a strange UI glitch, where one of my  view in the application lost all of its subviews.

Context:

This error occurred once the modal view controller was dismissed.

Reason:

I had legacy code from the days of iOS 4.0. The view which was losing its subviews is a View controlled  by a UIViewController. So this view controller was not added as a ChildViewController of the Parent Controller.

Fix:

Added the viewcontroller responsible for this problem as a child of the parent controller and the problem was resolved

How to Extract the Images From Any App in the App Store

Originally posted on Objective C#:

Facebook

Recently I discovered how incredibly easy it to extract the original, full-resolution images (and other resource files like video, audio, .plist files) from any app in the App Store, without jailbreaking, and without special software. For iOS developers, this can give a fascinating look at the insides of an app. As always, be sure to do this for learning purposes only and respect all apps’ intellectual property.

View original 214 more words

The Fallacy Of Android-First

Featured Image -- 1387

Krishnan:

The cost of Fragmentation is so high when compared to iOS and this will lead to user frustration and brand name gets tarnished

Originally posted on TechCrunch:

Editor’s note:Dave Feldman is the co-founder of Emu. Previously he was Entrepreneur in Residence for CrunchFund, led the 2011 redesign of TechCrunch, and managed the design team for Yahoo! Messenger. Emu for iPhone is available now.

In late 2012, we decided to launch Emu on Android first. It went against the conventional wisdom at the time, but we saw a real advantage. Sixteen months later, we’re back on iOS: Emu for iPhone launched on April 2. Here’s why Android didn’t work out for us and why you should think carefully before going Android-first.

To build a messaging app on iPhone, you have to create your own communication channel — essentially an IM service. But on Android, you can simply replace the built-in Messages app, while still using the underlying SMS/MMS medium. You save yourself the effort of building a communication service. And, your users needn’t invite their friends:…

View original 2,004 more words

Sharing the iOS SDK, Xcode installers with other people

Each time a new version of iOS SDK , Xcode is available for update, we have to download a .dmg  file with size of 2.0+ GB and lot of time to get the update. So when many people want to share the dmg, instead of downloading the dmg from the appstore, it is better to download it once and share it with others.

The link where you get all these installers is:

https://developer.apple.com/downloads/index.action?q=xcode#

 

Thanks:

http://apple.stackexchange.com/questions/104520/from-where-to-download-xcode-5

Core data Fetch Request returning wrong number of records

I  am using Core data’s NSFetchRequest to extract all distinct values of a column from a Table. Sometimes I would need to extract all the items without any NSPredicate  and sometimes with the predicate.

So I started getting two weird problems when I  used the below code:

NSEntityDescription *entity = [NSEntityDescription  entityForName:@"EntityName" inManagedObjectContext:coreDataContext];

NSFetchRequest *request = [[NSFetchRequest alloc]init];

[request setEntity:entity];

[request setPredicate:predicate];

[request setResultType:NSDictionaryResultType];

[request setReturnsDistinctResults:YES];

[request setPropertiesToFetch:[NSArray arrayWithObject:propertyName] ];

// Execute the fetch.

NSError *error;

NSArray *objects = [coreDataContext executeFetchRequest:request error:&error];

The expected Result:

An array of the NSDictionary-ies with key being the name of the property which we are searching for and the value being the unique value of the property.

Problems I faced:

1. There was an extra record appearing in the result array with an empty key and a value. All other records will had the unique values . (This occurred when I use a single property condition check in NSPredicate)

2. The result always had only 1 record irrespective of the number of unique values.

I used the sqlite queries to check if what I am doing is correct.


SELECT DISTINCT ZPROPERTYNAME FROM ZENTITY  WHERE ZCONPROP1 ==  2 AND ZCONPROP2='aValue'

I verified that whatever I was doing was correct.

Then I tried altering the values of NSPredicate string. Thats where the root cause was.

valid NSPredicate:

NSPredicate *predicate  =  [NSPredicate predicateWithFormat:@”prop1==%d AND prop2==%@”,value1,value2];

Invalid NSPredicate:

NSPredicate *predicate  =  [NSPredicate predicateWithFormat:@”prop1 == %d AND prop2 ==  %@”,value1,value2];

Not much difference between the two predicates right? Yes, except the spaces between property name and == operator and the value.

the device does not support this instrument

While testing for leaks in iOS device, I received this error.

the device does not support this instrument.

The problem I had was, I have not chosen the Provisioning Profile at all in the Xcode for this device. After selecting an appropriate profile, the problem did not occur.

Convert a xml file to plist

You can do it in two steps:

1. Convert xml to json. (use an online tool to do it. I used http://www.utilities-online.info/xmltojson/)

2. Go in to the target folder location( where your have the  json file to be converted)  in terminal.Use plutil to convert json to plist.

plutil -convert xml1 blahblah.json -o blahblah.plist

Follow

Get every new post delivered to your Inbox.