Thursday 9 October 2014

Making ad hoc build from command line without signing to developer account in Xcode 6 and iOS 8

It was the first problem I face during the use of xcode 6 first time, how can i share .ipa to my clients for demo purpose? I was unable to share an .ipa without signing Apple developer account. Xcode 6 was asking to sign with Developer account to export an .ipa file. Although I had the developer account details but it was the challenge how to make a adhoc build  without signing developer account.
After lots of Googling and consulting with other friends, I found  an alternate solution to achieve ad-hoc  build without signing developer account, solution is  command line/Terminal, you can create a adhoc build using command line tool and or a terminal on mac system.

Let me share the simplest way to create adhoc build using command line tool.

I note down 3 things to create quickest Xcode 6 build. So get ready for these 3 things before opening Terminal.

1- Project path: it will be required in terminal command as a parameter.

2- scheme name: it will be required in terminal command as a parameter.

3- Provisioning Profile name: it will be required in terminal command as a parameter.

Finding scheme name: Default scheme name is the project name but once verify. scheme name displays next to RUN icon in Xcode that is used to execute the app.

Finding Provisioning Profile name: This parameter value will be exact same as it display in Xcode; Provisioning Profile list under Code Signing Identity in build settings section of Xcode 6.

There are three steps two create build from command line tool

1- Clean project
2- Make Archive
3- Export to .ipa file

 Lets start with first. To clean project we will execute below command in Terminal  and or command line tool of mac system.
xcodebuild clean -project <projectname.xcodeproj> -configuration Release -alltargets

here  <projectname.xcodeproj> will be replace with the project path with .xcodeproj extension 

For example on my system's terminal
ajsharma$
xcodebuild clean -project /Users/ajsharma/Documents/iPad/testApp/testApp.xcodeproj -configuration Release -alltargets

Terminal will show you some process and updates and show you success message regarding project clean.
Lets go for next step to Make an archive using below command

xcodebuild archive -project <projectname.xcodeproj> -scheme <schemename> -archivePath <projectname.xcarchive>

here
<projectname.xcodeproj> will be replace with the project path with .xcodeproj extension 
<schemename> will be replace with the shceme name of the project as I discussed above.

<projectname.xcarchive> will be replace with the project path with .xcarchive extension


For example on my system's terminal
ajsharma$
xcodebuild archive -project  /Users/ajsharma/Documents/iPad/testApp/testApp.xcodeproj -scheme testApp -archivePath /Users/ajsharma/Documents/iPad/testApp/testApp.xcarchive

I used same path for as project Path for archivePath you may change it. So an archive file will be create at same path as project path.

@workspace:
Sorry I forgot to mention important command for those who have configured their projects under a WorkSpace or using pods in their projects.
For those people there would be slightly change in  command to make an archive. But I was not using workspace.

xcodebuild -workspace <projectname.xcworkspace> -scheme <schemename> archive -archivePath <projectname.xcarchive

 here;
<projectname.xcworkspace > will be replace with the project path with .xcworkspace extension.
<schemename> will be replace with the shceme name of the project as I discussed above.

<projectname.xcarchive> will be replace with the project path with .xcarchive extension

Lets go for  final step to Export to .ipa  using below command

xcodebuild -exportArchive -archivePath <projectname.xcarchive> -exportPath <projectname> -exportFormat ipa -exportProvisioningProfile “Provisioning Profile Name”

here
<projectname.xcarchive> will be replace with the project path with .xcarchive extension
<projectname>  will be replace with the project path with out .xcarchive or .xcodeproj extension
“Provisioning Profile Name”  will be replace with the Provisioning Profile Name  as I discussed above.

For example on my system's terminal
ajsharma$
xcodebuild -exportArchive -archivePath /Users/ajsharma/Documents/iPad/testApp/testApp.xcarchive -exportPath /Users/ajsharma/Documents/iPad/testApp/testApp -exportFormat ipa -exportProvisioningProfile TestProvision

If everything works fine the final result screen would be some thing like below text as per my project path.

Moving exported product to '/Users/ajsharma/Documents/iPad/testApp/testApp.ipa'
** EXPORT SUCCEEDED **


You can get the .ipa file from the above path as per your project path at your system and share with your client.

If you have any other best way to create adhoc build without using developer account, please share your comments.


11 comments:

  1. Really very good post. It really saved my lots of time. Close steps and example of commands solved my problem.

    Thanks. Keep posting such great contents

    ReplyDelete
  2. Thanks Aaryan to share good comments. It really insipre me to post good contents.

    ReplyDelete
  3. Thank you very much for such useful and clear information.

    ReplyDelete
  4. @Alina, Really Glad to see your feedback.Your good feedback gives me energy to post content in more clear and stepwise. Keep in touch.

    ReplyDelete
  5. Great post, it really help me a lot in making adhoc build using Xcode 6 n with out signing Apple developer Account. Clear steps and requirement saved time.
    Please keep posting such great posts in simple and clear steps.

    ReplyDelete
  6. hi,
    Thank you for this solution.

    I have a problem when i execute the second line:
    xcodebuild archive -project /Users/dori/desktop/xcode_projets/checklist/checklist.xcodeproj -scheme checklist -archivePath /Users/dori/desktop/checklist.xcarchive

    i have this error:
    Check dependencies
    Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID “(null)” were found.
    CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.1'

    ** ARCHIVE FAILED **


    The following build commands failed:
    Check dependencies
    (1 failure)

    Can you help me?
    Thank's

    ReplyDelete
  7. Hi Dori,
    Thanks for sharing your problem. As per the error "Code Sign error:" its very clear that you have not a valid certificate and or provisioning profile matching with that certificate.
    So first of all you need to fix this issue by installing a valid certificate and a provisioning profile matching to that certificate. You can create an adhoc build from command line without signing to apple developer account only when you have valid certificate and matching provisioning profile. Before go to command line to make adhoc build, select iOS device rather than simulator in xcode and then press (command+B) or Under Product menu in xcode choose Build if their is no error and build success then you can go for making adhoc build from command line. Thanks once again to visit this blog, keep in touch.

    ReplyDelete
  8. ok thank you Aj Sharma
    I began in Xcode, how to create a certificate and use it?

    ReplyDelete
    Replies
    1. Hi Dori,
      If you dont have a Apple developer Account then please first get it $99/Year.
      https://developer.apple.com/programs/start/standard/

      and then follow to create certificate and provisioning profile

      https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/CreatingYourTeamProvisioningProfile/CreatingYourTeamProvisioningProfile.html.

      Delete
  9. it is not possible to test an application without account developers?
    there is no way to create .ipa or .deb to test on my idevices?

    ReplyDelete
  10. No, There is no such way to test build.ipa on devices without having Apple Developer Account.

    ReplyDelete