24 May, 2017

iPhone/XCode - not all cases are equal!

This bit me! 

Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the stuff to a phone via TestFlight, my images that was rendering fine in the simulator did not show up at all? What up?

When you are dealing with image resources (UIImage) in Xcode; remember that the spelling is important. I'm referring to case sensitivity here.
So - in short:
The iPhone Simulator: case insensitive
The iPhone: case sensitive

Just saying if you are puzzled about why your images are not showing up when deployed to a Phone.

02 February, 2017

InRiver: Not loading your extensions?

(You really need to in the loop to appreciate the issue this post addresses).

Man, I've been fighting this problem for hours before I found the reason. Having added everything correctly to the zip file and deploying everything to the correct location, why is the webserver not picking up my extensions and presenting them in the top menu?

Look at the below - nothings shows up but the standard apps. Why?



This was really a great puzzle to me until I discovered a bizarre thing: The PackageConfiguration.xml file needs to be named with lowercase letters (i.e. PackageConfiguration.xml packageConfiguration.xml) to be picked up by the system.



This will result in the following UI:



Come on - how crazy is this? I for one am not very impressed! How did I discover this? Well - crack open the InRiver.Web.dll (thank you DotPeek!)

31 January, 2017

IOS: How to enable ForceTouch support (2/2)

This is part 2 of a double post (see http://blog.clauskonrad.net/2017/01/ios-how-to-enable-force-touch-support-12.html for part 1)

Continuing from the previous post; once you have the UI defined - we need to be able to handle that the app is launched by pressing one of thUIApplicationShortcutItems instead of conventional icon click. The key to detecting this in the app is the appDelegate class (the startup class). As you might remember from part 1, we gave the shortcutItems a unique type (a unique string). These strings are used to identify to the app what shortcut item has been pressed.

As seen from the below image - the first thing when the app is launched is to check the launchOptions  argument. If it is possible to cast that as a UIApplicationShortcutItem - we have been launched from such UISchortcutItem.


The next thing is to determine which item (item1 or item 2) has been used to launch the app.


In my sample app - the startup viewcontroller as seen below is a TabbarController that normally would start the left hand child viewcontroller (Network Info) as this has index = 0 (default). Therefore I can just set the selectedIndex on the tabbarController as seen in the code above. This will allow me to either select the Network Info or Cell Info tab. All from the UIShortcutItem.






29 January, 2017

IOS: How to enable ForceTouch support (1/2)

The ability to accelerate a users interaction with your app by the virtue of ForceTouch - has proven surprisingly useful to me and I’ve decided to investigate how that is achieved.

As this is a fairly large topic - it has been broken down into 2 separate posts. The first one (this post) addresses the UI declaration. The second post will address the code behind the UI-items.

First of - how do you define the support? You need to define a new entry in the custom section of your info.plist file (that ultimately will render in your project settings). To my surprise - this was actually not an entry that comes up in the drop down list when adding a new row. But, luckily you are allowed to add it by hand (just type the name).

Changes to info.plist (the project file)

  • Select the info.plist file in the project navigation window.
  • Right click on the blank area and select Add Row
  • You cannot select a properly named item - so name the new entry (just write the name): UIApplicationShortcutItems
  • Set the datatype = Array
  • This array will hold a number of Dictionary objects that each define a ShortCutItem (the force touch items presented when pressing the application icon)



To add the dictionary items to the array - you can do so using the Xcode editor or using a conventional text editor (he plist file is just an xml-file). Finally - as you can see from the below images the entries in the plist file will give you the UI.

All 3 elements in each dictionary should be there - the one connecting the dots between UI and code is the UIApplicationShortcutItemType value. This must be unique. Conventionally, this is achieved by combining the bundleID with a string (in the below example ".First" or ".Second").

info.plist open in Xcode:
  

info.plist file opened in Visual Studio Code (just a text editor):


The end result when force-pressing the app icon is seen here:

The next question obviously is - okay, how do I interact with the code when these items are pressed? That's the subject of post 2...

26 January, 2017

C#: functions vs. expression trees

I recently was given the opportunity to revisit Func<T> and Expression<T>. These things can become extremely complex and almost impossible to understand or read. So if you are as confused as I was when starting this here is how the Expression<T> vs. Func<T> relates.

Just bear in mind that you rarely want to deal with Expressions. Given the circumstances I was unfortunately forced to as I was hooking into an existing query expression.

To start off - the following statement is very important and very true:

So - an Expression is actually not a method that can execute in its own right.

  • An Expression is merely meta-data about a function that can be compiled and then executed.
  • A Function is executable code that you can call and use directly.


Looking at the example below - you will find a Func<int> (line 12) and an Expression<Func<int>> (line 13). Both return an integer of the value 10. The function can be executed directly by calling .invoke() (line 21) whereas the Expression first need to see a compilation (line 22) and then an invocation.

In other words - the expression is actually as the name suggests just an “expression” (a statement) about a future method (function) that it can be compiled into. Then, and only then can it (the compiled function) be used.


Need I say again - you do not need to deal with Expressions…?

25 January, 2017

Using Obj-C from Swift 3.x

If you forget where to reference that bridge-header file from your Swift project settings - here is where to put it. The bridge file (*bridging-header.h) goes anywhere in your project structure (project view!) and the reference is put under Swift Compiler as seen below.


PS: XCode will actually do this automatically during creation, but if you as I did missed that step - you are left to your own devices.

24 January, 2017

Cocoapods pod install takes forever?

If you ever run into the experience that setting up your master repo using Cocoapods takes forever - fret not. It is not only you ;-)

So instead of running pod install and being presented with the below “static” image:


You can run the verbose version pod install —verbose and gain this somewhat more informative view:


Still - it does take forever; you are just more informed about what’s going on on the machine.

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...