Aditya Deshmane

… with proper design, the features come cheaply. This approach is arduous, but continues to succeed.

iOS: Free Provisioning

1. How it works ?

Apple Ref : How to use free provisioning

As stated in above link under Launch Your App on Devices Using Free Provisioning point 6. “Xcode creates a free provisioning profile for you”

Update: Above point 6 is removed from link, but there is no change in the way it works and steps in above link still work!

Profile created in this way is tied to your apple id, when you try to run app on new device that device’s UDID gets added in this profile.

2. How to use free provisioning?

Requirements: Apple ID, XCode 7


  1.  Go to XCode Preference
  2. Go to Accounts tab and hit plus “+” button on bottom left to add your Apple ID.
  3. After successfully adding Apple ID click on view details on bottom right 1
  4. Click the Create button next to “iOS Development” 2
  5. Connect your device and select your device as build destination.
  6.  In target’s general setting, set team id as your apple id, set team id as your apple id, set team id as your apple id. Hit fix Issue button below provisioning profile warning 3
  7. Run the app, this will install app.
  8. Click app icon to start app manually, you will get “Untrusted Developer” dialog. To trust your apple id, Go to iPhone setting > General > Device Management > Select your apple id and click trust.
  9. After step 8 you can run and debug app using free provisioning.

3. What are the Limitations?

I tried to install app with free provisioning and could run/debug app. But there are few catches. Profile created by XCode7 is bit different than our usual developer profiles

From profile raw file

  1. There is new key `LocalProvision` with value `true`

Many services like following are not available, See full list of services

Apple Pay, Game Center, iCloud, In-App Purchasing, Push Notifications, Wallet (Was Passbook)

2.  Expires in 3 months.



3. Under `<key>ProvisionedDevices</key>` there is list of devices on which I tried to install app, still unknown maximum number of devices possible, I tried to install on 3 devices which worked successfully.

4. This is not alternative to publishing app for free on app store, you still need to enroll to developer program to publish apps.

5. Testflight based internal / External testing is not possible.



iOS: Executing JavaScript in Objective C iOS Application

Apple introduced JavaScriptCore.framework with iOS 7 SDK, before that there was only one function -stringByEvaluatingJavaScriptFromString: available on UIWebView to execute JavaScript in iOS via Web Views.

Ways to execute JavaScript in iOS

  1. Writing JavaScript code in Objective C code.
  2. Using .js file for reuse purpose / for difficult to port code in Objective C
  3. Web views using JavaScript

#1. JavaScript code in Objective C

import JavaScriptCore framework

#import <JavaScriptCore/JavaScriptCore.h>

You are going to use two important Classes from this framework


JSContext represents a JavaScript execution environment.  JavaScript execution takes place within a context. You provide your JavaScript code in the form of NSString for execution.


A JSValue is a reference to a value within the JavaScript object space of a JSVirtualMachine. All instances of JSValue originate from a JSContext and hold a strong reference to this JSContext. JSValue holds JavaScript values, variable and functions you can convert these to Objective C type data by using function available on JSValue. E.g toString, toArray, toBool etc. 


Simple sum calculation

NSString * jsCode = @"2+3";
JSContext *context = [[JSContext alloc] init];
JSValue * value = [context evaluateScript:jsCode];
NSLog(@"SUM = %d", [value toInt32]);

#2. Using .js file in Objective C


Create file Demo.js with following content, and add it in project.

function HelloJS(name) 
   return "Hello, " + name + "!";

Now write following code to invoke HelloJS function from Demo.js in objective c code.

//Get JS file content in string format
NSString *path = [[NSBundle mainBundle] pathForResource:@"Demo" ofType:@"js"];
NSString *jsScript = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
//Initialize context with script
JSContext *context = [[JSContext alloc] init];
[context evaluateScript: jsScript];
//Set function name to invoke
JSValue *function = context[@"HelloJS"];
//Call fuction with parameter
JSValue* result = [function callWithArguments:@[@"World"]];
NSLog(@"Output : %@",[result toString]);

#3. Web views using JavaScript

  1. Load your file into web view.
  2. Set delegate of web view to self.
  3. When web view finishes loading call methods in your js


- (void) webViewDidFinishLoad:(UIWebView *)webView
    //Execute javascript method 
    [_webView stringByEvaluatingJavaScriptFromString:@"methodName();"];

Blog at

Up ↑