Showing posts with label iOS. Show all posts
Showing posts with label iOS. Show all posts

Tuesday, January 30, 2018

Userful xcodebuild command lines

I setup Jenkins jobs to build iOS project for QA and release. Here are some useful xcodebuild commands that I use. Tested with XCode 9.

Create a xcarchive file
xcodebuild -project ${APPNAME}.xcodeproj -scheme ${APPSCHEME} -configuration Release clean -archivePath "${WORKSPACE}/${APPNAME}.xcarchive" archive

Create an IPA from xcarchive file with exportOptions.
xcodebuild -exportArchive -archivePath "${APPNAME}.xcarchive" -exportPath "${WORKSPACE}" -exportOptionsPlist exportOptions.plist -allowProvisioningUpdates

If the above command doesn't create an IPA, try putting xcrun in front. To generate an IPA with the correct certificate and provision profile, you must set them correctly in exportOptions.plist. See example below.

Create an APP file for simulator
xcodebuild -project ${APPNAME}.xcodeproj -scheme ${APPSCHEME} -configuration Debug -sdk iphonesimulator clean build


Sample exportOptions.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>method</key>
 <string>enterprise</string> //app-store, enterprise, ad-hoc or development
 <key>signingCertificate</key>
 <string>iPhone Distribution</string> //Certificate name
 <key>teamID</key>
 <string>T7L12345678</string> //The development program team identifier.
 <key>uploadBitcode</key>
 <false>
 <key>uploadSymbols</key>
 <false>
 <key>provisioningProfiles</key>
 <dict>
  <key>com.sample</key>
  <string>fe26f4e4-11d0-4054-898c-144a8se030a1</string> //Provision profile UUID
 </dict>
</dict>
</plist>

Update build version in Info.plist
/usr/libexec/Plistbuddy -c "Set CFBundleVersion ${BUILD_NUMBER}" "${WORKSPACE}/${APPNAME}/Info.plist"

Wednesday, January 24, 2018

KML Collection iOS App

I often create apps I need that are not available in the app store. This is one of them. I usually plan my travel trip using Google My Maps to store all the interesting places I want to go. I needed an app that can import KML map files exported by Google and show all the places. I also want an easy way for me to open the place in my favorite navigation app. So, I created KML Collection using swift.

App Store link

Monday, January 1, 2018

Update: Items for Diablo 3

Happy New Year!
My first personal app Items for Diablo 3 was released in September 23rd, 2013 when I was actively playing the game Diablo 3. It received lots of great reviews from players that encouraged me to keep making updates to Items for Diablo 3. From a simple off-line items viewer to hero profiles checker, to hero skills simulator, to rift rankings. I want to say thank you to the fans of the app.

App Store link

Here are a few reviews from the app store.
Like it was made by Blizzard themselves
I have been searching for awhile for an app that would provide the utility of the official WoW Armory app for Diablo. I've tried several and never been satisfied - until now! This app is absolutely fantastic. It provides everything I had been wanting - easy ability to view my characters, full skill calculator/browser, and a cleanly presented database of legendary and set items. The search for the database is quick and robust - it will even give you a list of all class-appropriate items by simply entering the class in the search box! For the Diablo enthusiast, I highly recommend this app. It is everything the Armory is for WoW - 10/10! by darienspecter
Well written Diablo 3 app finally!! by *Vladimir*
Very useful and better than any tool I've tried! by Rg418
This app goes above and beyond all it's competitors. Just the fact that all the info in it is updated should be enough to put it head and shoulders above the other Diablo 3 companion apps but this app takes it to an even higher level. Excellent app and even though the ads weren't something I needed to pay to get rid of, I did just to pay tribute to the developer going above and beyond what he had to. It's a shame I can't do a better job articulating how good this app is because it deserves it after I've dealt with other subpar apps for months. by Mawillar
No doubt you Gentlemen have done a fantastic job in the development of probably one the most comprehensive D3 information sites I have found. Kudos for a job well done. by ElsagBailey

Saturday, July 8, 2017

Skill Tree Lookup for ESO app: Taste of ReactNative

I heard about ReactNative when it first came out. After many years later, I finally decided to give it a try because it would be nice to release an app for both Android and iOS platform. I'm not an Android app engineer so this was my first app that is available on Google Play thanks to ReactNative. The app turned out nice and looks native, but the performance is not as good as native app build using Swift or Java especially on older devices.

I was excited about the Android release because there are more Android phones out there. Result is that I made about the same Ad revenue from each platform.

App Store link
Google Play link

Thursday, April 27, 2017

My HTPC remote mouse: VMouse

I have a HTPC set up in my living room that have TightVNC running so I can remote control it using my tablet or desktop. Sometimes, I just need to have an app that act like a mouse without the full remote desktop experience. I found many apps in the app store can do this but requires installation of its own server application on the HTPC. I don't like the idea of installing extra server that would take up more computer resource. Plus I trust TightVNC more. Since I already have TightVNC installed, I should be able to control the mouse via VNC protocol (RFB). This's why VMouse was born.

App Store link

Wednesday, March 8, 2017

Ridiculous Apple App Store rejection

My Items for Diablo 3 app has been in app store for years with 4.5 stars reviews from users got a rejection for a minor update. The reason was the following.

"We noticed that your app only includes links, images, or content aggregated from the Internet with limited or no native iOS functionality. We understand that this content may be curated from the web specifically for your users, but since it does not sufficiently differ from a mobile web browsing experience, it is not appropriate for the App Store."

Anyone that uses the app would know that the reviewer does not know what he is doing.

Wednesday, October 5, 2016

Xcode 8 automatic code signing problem with Jenkins

Xcode 8 automatic code signing is great. However if you try to use Jenkins to automate your app build with a specific provision profile, you would want to use manual code signing. What I wanted to do was use automatic code signing during development and use manual code signing with Ad-Hoc provision with Jenkins.

To switch from automatic to manual code signing, you need to change the following setting in the project file ([project name].xcodeproj/project.pbxproj).
Change "ProvisioningStyle = Automatic" to "ProvisioningStyle = Manual"
By default "ProvisioningStyle = Automatic" is not in the project.pbxproj. You just need to uncheck and check "Automatically manage signing" in app Target -> General in Xcode to add that setting.

Now in Jekins, you want to add this shell script before you run the Xcode build command to change "ProvisioningStyle = Automatic" to "ProvisioningStyle = Manual"

sed -i '' 's/ProvisioningStyle = Automatic;/ProvisioningStyle = Manual;/' [project name].xcodeproj/project.pbxproj

You can then use xcodebuild argument "PROVISIONING_PROFILE=xxxx-xxxx-xxxx" to use the provision profile you want.

Friday, March 25, 2016

Add tint to UIImage

I have been working on a SDK that allows user to customize colors for images. In many cases, I need to add an image to a button with different color at run time. So using just tintColor is not going to work. The following method will mask an image with the color you define.

- (UIImage *)maskWithColor:(UIColor *)color
{
    CGImageRef maskImage = self.CGImage;
    CGFloat width = self.size.width * self.scale;
    CGFloat height = self.size.height * self.scale;
    CGRect bounds = CGRectMake(0,0,width,height);
    
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef bitmapContext = CGBitmapContextCreate(NULL, width, height, 8, 0, colorSpace, kCGBitmapAlphaInfoMask & kCGImageAlphaPremultipliedLast);
    CGContextClipToMask(bitmapContext, bounds, maskImage);
    CGContextSetFillColorWithColor(bitmapContext, color.CGColor);
    CGContextFillRect(bitmapContext, bounds);
    
    CGImageRef cImage = CGBitmapContextCreateImage(bitmapContext);
    UIImage *coloredImage = [UIImage imageWithCGImage:cImage scale:self.scale orientation:self.imageOrientation];
    
    CGContextRelease(bitmapContext);
    CGColorSpaceRelease(colorSpace);
    CGImageRelease(cImage);
    
    return coloredImage;
}

Tuesday, December 23, 2014

Weather for your business?

A beautiful iPhone app before the year end. It is a business analytics app.
In App Store: https://itunes.apple.com/us/app/weathr-lite/id980422041?ls=1&mt=8

Wednesday, October 1, 2014

Directory with extra fun

Employee look up app with fun ideas.


Monday, November 18, 2013

How to get iDevice hardware model

size_t size = 100;
char *hw_machine = malloc(size);
int name[] = {CTL_HW,HW_MACHINE};
sysctl(name, 2, hw_machine, &size, NULL, 0);
NSString *hardware = [NSString stringWithUTF8String:hw_machine]; //e.g. iPhone4,1
free(hw_machine);

Wednesday, November 6, 2013

How to resign an IPA with new bundle Id, certificate and entitlements

  1. Create an Entitlements.plist using Xcode
    1. Include the following keys values in the plist file. 
      1. application-identifier (String) -> 3Q83MXXZGH.com.company.appname
      2. get-task-allow (Boolean) -> NO
  2. Put the Entitlements.plist in the same folder of the app.ipa file
  3. Unpackage the app
    1. unzip app.ipa
  4. Delete current code signature
    1. rm -rf Payload/MyApp.app/_CodeSignature/
  5. Open Payload/MyApp.app/Info.plist in Xcode and update the bundle ID(CFBundleIdentifier)
  6. Copy the new .mobileprovision file to Payload/MyApp.app/embedded.mobileprovision
  7. Run the codesign command
    1. codesign -f -s "iPhone Distribution: Company Certificate" --resource-rules Payload/MyApp.app/ResourceRules.plist --entitlements Entitlements.plist Payload/MyApp.app
  8. Repackage the app
    1. zip -qr app-resigned.ipa Payload/
Sample Entitlements.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>application-identifier</key>
 <string>3Q83MXXZGH.com.company.appname</string>
 <key>get-task-allow</key>
 <false/>
</dict>
</plist>

Tuesday, September 10, 2013

Experiencing Sencha Touch: VW Dealer app

Sencha Touch, a high-performance HTML5 mobile application framework. We used Sencha to build an iPad application that allows Volkswagen field managers and dealers to show customers everything about VW cars.
Application features:
  • Work offline.
  • Update application data without reinstalling the app.
  • Support multiple events.
  • Capture customer information locally and upload to server later on.
  • Vehicle gallery and videos slide show.
  • Vehicle trim specs, color specs, technical specs, pricing.
  • Vehicle comparison. 
Since this app needs to work with iPad 1st generation, memory management became very important. We spent good amount of time to tweak the app to have small memory footprint. 

The app is being used at places with no wifi. When the application is installed, it downloads all data from a server and stored on the iPad using HTML5 local file system feature. App uses high quality gallery images, so using manifest method would exceed the browser storage limit.

The app itself has a version control built-in so every update is an incremental update instead of re-download all data again.

Customer data are stored on the app using Sencha store data model.

2013 Sep updates: Redesign user interface!











Monday, June 3, 2013

iPhone app: real time video sharing

An native iPhone app prototype that steams camera video between two iPhones. Not very complex, but it took a good amount of research and learning. Major classes are NSOperation, AVFoundation and GameKit.
  • Multi-threading is necessary to prevent UI lockup, so NSOperation is used. 
  • AVFoundation - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer (CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection is the key element to capture video frames from camera. 
  • GameKit peer-to-peer communication via Bluetooth is used to send and receive data between two devices. 
Result was that I was able to reach about 4 frames per second. Did not get to try Game Center peer-to-peer via local WiFi. I believe that will increase the frame rate.