|
|
|
|
I though I would start automating my builds and deployments. First I really need to plug the guys at Test Flight. This is really a great tool. So next was to auto increment the build number so I could start tracking builds. If ANYONE knows how to do this without some script, please let me know! My solution was to add a build phase with some script. This should really be just a check box, but there is always solution with some script.
Here is how I managed the problem.
First select your target and the Build Phases

Next Add a build phase run script - Its the + sign in the bottom right of the build phases window. press it and select "Add Run Script"

Now add the following script:
# Auto Increment Version Script
buildPlist=$INFOPLIST_FILE
echo $buildPlist
CFSVString=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$buildPlist")
CFBundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$buildPlist")
BUILD_NR=${CFBundleVersion##*.}
BUILD_NR=$(($BUILD_NR + 1))
#echo $BUILD_NR
CFBundleVersion=$CFSVString"."$BUILD_NR
#echo $CFBundleVersion
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$buildPlist"

Lastly we need to move the build phase so it is right below target Dependencies

Change the format of the CFBundleVersion as you need and you are done!
|
|
|
Needing to add a check for connectivity to an application, I came across the Reachability sample by Apple. Its a nice sample that you grab the reachability classes from, BUT....
it is not ARC friendly so you either need to fix it or do this:
Turn off ARC for individual files. I am not sure if this is the recommended way of doing things, but it works (on my box) Just had to throw that in ;)
Go to your project settings, under Build Phases > Compile Sources Select the files you want ARC disabled and add -fno-objc-arc compiler flags.
Next when you compile you will get this warning (not apples cleanest example out there)
declaration of 'struct sockaddr_in' will not be visible outside of this function
To get rid of this warning simple add this import to the Reachability.h file
#import <netinet/in.h>
Now go ahead and test your connectivity.
|
|
|
We encountered a very rare bug in our Tests today (Feb 29). And this is the lesson as to why you always use the DateTime class to add time instead of your own math. The offending line looked like this:
_args.LastMonthlyRunEndDate = new DateTime(DateTime.Now.Year + 1, DateTime.Now.Month, DateTime.Now.Day);
The problem with this code is that it fails once every 4 years. On Feb. 29.
A better way to write this code would be:
_args.LastMonthlyRunEndDate = new DateTime().AddYears(1);
Let the DateTime class handle all of that leap year stuff. This is now a unit test I will add to my repository where date additions need to account for leap years!
|
|
|
The UIWebView is a great view for showing formatted content within your application. However if your content contains URL's you may not want the navigation to happen within your application. The iOS device has a Safari web browser that is fully functional. Redirecting links to use Safari instead the UIWebView is simple.
- Ensure your ViewController class is the delegate for the UIWebView, either programatically or in the storyboard.
- Implement the UIWebViewDelegate protocol (in your .h file add the red delegate)
@interface TodaysSessionsViewController : UIViewController<UITableViewDelegate, UITableViewDataSource, NSURLConnectionDelegate, UIWebViewDelegate>
- Override (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType. Return YES if you want to allow the navigation, NO if you dont. In this case we want to stop the navigation. So we are going to return NO unless this is the first navigation. (IE our static content.
- The last part is to launch a shared application. We do this by specifying the URL from to the sharedApplication so the entire method looks like this
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:[request URL]];
return NO;
}
return YES;
}
Now we have a UIWebView that can display formatted content that includes URL's and launch those URL's in Safari!
|
|
|
|
|
|
This blog is a running archive of development issues and success's. Hopefully this can serve as a reference for myself and others. ( I am getting old and if I don't write it down, sometimes its hard to remember )
You can filter the blog based on submitter and category. Registered users can add their own blogs to the list, so if you would like to contribute, please register on the Registration page. |
|