install iOS ad-hoc app failed - objective-c

I've a problem by installing an ad-hoc build to my iOS test devices.
When I run the app via XCode, there is no problem, but from the moment I create a signed ad-hoc app (*.ipa), the app is not able to install via iTunes or the iPhone configuration tool.
What I've done:
- Creating a distribution certificate
- Creating an app ID (com.project_name.*)
- Creating a distribution provisioning profile including the distribution certificate, all devices UUID, etc.
- In the plist file I set "Bundle identifer" to "com.project_name.app_name"
By creating the ad-hoc file, I've chose the distribution certificate for code signing. This certificate is also set in the project file --> build settings --> Code-Signing
When I install the app in itunes, there comes an error dialog which just says, that it was not possible to install the app.

Make sure you are not using special characters in bundle identifier.
The bundle identifier string identifies your application to the
system. This string must be a uniform type identifier (UTI) that
contains only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)
characters. The string should also be in reverse-DNS format. For
example, if your company’s domain is Ajax.com and you create an
application named Hello, you could assign the string com.Ajax.Hello as
your application’s bundle identifier. The bundle identifier is used in
validating the application signature.
If your bundle identifier is correct,
Please validate your ipa file with following steps:
Step1: rename yourapp.ipa to yourapp.zip
step2: Extract content of yourapp.zip, you will see content in Payload
folder.
Step3: locate yourapp.app in payload folder.
Step4: rightclick on app and click "show package content"
Step5: in package content, locate "embedded.mobileprovision"
step6: Open "embedded.mobileprovision" in text editor. and check if
your device id exist there.
If your device id is there, Your build is correct. otherwise, rebuild by checking all code.
Note: Please make sure you have selected "Ad-hoc" while creating distribution file and not "App store".

The problem wasn't the app.
My solution: Export the app as Xcode-Project (same way Organizer --> Archive --> Distribute) to another mac. Think about the certificates. You will have to export the private keys from your first mac too (*.p12 files).
Open the XCode-Project from your second mac, sign it with the provision profile and install it via itunes.

Related

Which Build is generated when I archive my App in Xcode6?

I have an app which I want to distribute to the app store.
When I do >Product > Archive does the app automatically build in Release or Debug config? Do I have to set this manually or is it always Release?
You can define Release or Debug in the scheme by tapping on Edit Scheme and selecting the Build Configuration. Take a look at below screenshot:
EDIT: To get Production APNS token
Archive the build in release mode.
Ensure to sign it with an Ad Hoc Distribution Provisioning profile.
Ensure profile is correct by following below:
Verify that the entitlements in the provisioning-profile file are
correct. To do this, open the .mobileprovision file in a text editor.
The contents of the file are structured in XML. In the Entitlements
dictionary locate the aps-environment key. For a development
provisioning profile, the string value of this key should be
development; for a distribution provisioning profile, the string value
should be production.
You can define Release or Debug in the scheme by tapping on Edit Scheme and selecting the Build Configuration
Its better to cross check when you are uploading build to store.

How can I access specific iOS app's directory with Objective C?

I'm trying to write an app for jailbroken iOS devices that can load files from another app. But appstore apps are stored in folders with seemingly random characters that vary per device. How can I figure out the directory for X app on the device? On iOS 8, achieving this seems harder due to the way the app filesystem is structured.
iOS 7 and below
AppStore apps are installed in /var/mobile/Applications inside directory with random name. App's directories (documents, library etc) and *.app directory are both inside it. To determine which app it is you need to parse Info.plist file inside *.app directory where app name and bundle identifier are stored.
iOS 8
Apple completely changed the way AppStore apps are stored in filesystem. Everything we need now is in /var/mobile/Containers directory - at this point every directory I mention further down the text is contained inside that directory. All bundles (anything that contains application code) are stored in Bundle directory. There you will find apps, plugins and may be some other stuff.
For example, OpenVPN application contains two bundles with application code - OpenVPN.app with application executable and OpenVPNPlugin.vpnplugin which implements OpenVPN protocol as iOS VPN plugin. OpenVPN.app is in Applications directory and OpenVPNPlugin.vpnplugin is in VPNPlugin. For some reason OpenVPNPlugin.vpnplugin is also stored in Applications but it looks like it's a temporary measure for compatibility reasons.
All application data now stored in Data directory. Applications, plugins store their data inside that directory.
Apps directories (documents, library etc) now stored in Data/Application inside directory with random name. To determine which app directories it is you need to parse Data/Application/xx-xx-xx/.com.apple.mobile_container_manager.metadata.plist. Inside it you will find MCMMetadataIdentifier key that contains app's bundle identifier.
There are also Data/PluginKitPlugin and Data/VPNPlugin directories on my device. Again, parse Data/PluginKitPlugin/xx-xx-xx/.com.apple.mobile_container_manager.metadata.plist and Data/VPNPlugin/xx-xx-xx/.com.apple.mobile_container_manager.metadata.plist respectively. Inside it you will find MCMMetadataIdentifier key that contains plugin's bundle identifier. In case of PluginKitPlugin, to determine to which app it belongs you need to go to *.app. It seems PluginKitPlugin bundles are stored in *.app/PlugIns. Parse it's Info.plist to determine plugin's bundle identifier. As an example you can look at how Evernote is stored.
And finally there is Shared directory. It seems it contains app's documents that can be shared between different apps. Again, inside Shared you will find directory with random name. To determine which app shared that documents parse the .com.apple.mobile_container_manager.metadata.plist. MCMMetadataIdentifier will contain group. string concatenated with app's bundle identifier.
iOS 8 Update
Since iOS 8.4 Apple once again changed things. Now there are no .com.apple.mobile_container_manager.metadata.plist files. Instead you need to parse /var/mobile/Library/MobileInstallation/LastLaunchServicesMap.plist. It holds information about all installed applications (even system ones) since iOS 8 so you actually don't need .com.apple.mobile_container_manager.metadata.plist at all.
The plist has a very simple structure. First is dictionary with two main keys
System - dictionary of system applications (including Cydia ones)
User - dictionary of user applications (AppStore, enterprise, developer apps etc)
Those dictionaries use bundle identifier as key and dictionary with application info as value. For example:
Path - path to application bundle directory
Container - path to application directories (documents, library etc)
iOS 9 Update
It looks like both .com.apple.mobile_container_manager.metadata.plist and /var/mobile/Library/MobileInstallation/LastLaunchServicesMap.plist are too unreliable. The former is once again present in iOS 9 - don't know what happened in 8.4, maybe a bug. The latter is not always up-to-date. In fact, most of the time it contains old information. Especially for application sandbox path. Looks like it does change periodically as many times I found that the plist gives me the wrong path.
There is a much more reliable solution that doesn't require fiddling with plists or anything - LSApplicationWorkspace from MobileCoreServices framework. It has method - (id)allInstalledApplications that returns an array of LSApplicationProxy objects that will give you all the information you might find in LastLaunchServicesMap.plist. And, if I remember correctly, it works even without jailbreak.

XCode 4, Invalid Signature (-19011)

I'm goin mad.
I'm using XCode 4 and finally i finished my app,and i was about to submit it to App Store,uploading to iTunes Connect. I tried to to Build for Archive but this warning showed up:
Application failed codesign verification. The signature was invalid, or it was not signed with an Apple submission certificate. (-19011)
I've googled all day long,i've tried to renew all my certificates in Provisioning Center,i've even tried to upload it with Application loader but anything happened. Same error there too. I've tried to validate it through the Archive tab in Organizer but anything, this warning won't go away.
I've read some answers here, and even if the answers were a bit old, anything worked for me, i've tried to reinstall XCode too,i've tried to select the right profile on Build in Targets..
Thanks to anyone who will help me
edit:
When i try to start a new project and select "Build for Archive" and then Archive, the warning appears but i can still share the archive as ipa. I tried to copy all the files from my old project into the new one, build for archive, archived. But when i select "Share" as .ipa it shows an error
The operation couldn't be completed. No such files or directory.
May this be 'cause i added 2 frameworks to my project to work? Should i select something from Target,or Project? Also,i want to say that all my profiles are ok, certificates etc. I've tried to bypass the error -19011 by turning on NO "Validate built product".
EDIT2:
The -19011 doesn't show up anymore, but when i try to validate or submit,i got this error:
The archive is invalid. var/folders/*randomnumbers* app.ipa does not exist.
What am i supposed to do in this case? I've already read some of the answers but none worked.
I solved, thanks to the help of an Apple Technic Engineer, this way:
In targets, on Build Settings - Product name, I had the name of the app with spaces and special characters (? character). After changing that and changing the Bundle Name too, I solved all the problems I got with that.
Hope this will help someone, one day.
You said you tried to "renew all my certificates in Provision Center". Are you certain you are:
Using a valid certificate. Have you imported the private key into your keychain?
Chosen the right provisioning profile + certificate combination for your "Release" or "Distribution" configuration?
It's possible that your Development configuration is correct, hence you could test on your device (if you have), but your Release configuration is wrong.
Go to "Build Settings" in XCode and verify that under "Release" or "Distribution", you chose your Distribution certificate (not development certificate) and the provisioning profile tied to it.
If that doesn't work, your problem is possibly related to
this SO question.
Try reinstalling?
Hope this helps.
Are you sure your distribution certificate is for the app store, and not for ad-hoc distribution?
From Product menu go to "Edit Schema", there find the Archive from the left sidebar and check which build configuration you are using for Archive. It should be distribution.
Another thing to check is which provision profile Distribution configuration is using, you can check this from projects Build Settings under Code Signing section.
After making sure my certificate and provisioning profile were correct for In-House deployment and making sure I didn't have any unwanted spaces or characters in the target names, what worked for me was to change my scheme from Debug to Release on the Run page. Product -> Scheme -> Edit Scheme -> Click Run -> Change Build Configuration to Release.

Can I re-use my app IPA, edit assets in it and update CodeResources with a script?

I've created an app that is reskinnable by just changing asset files. In theory, I could just unzip the IPA file, update my assets, then rezip it as a new version. Of course this doesn't work because of code signing and CodeResources hashes will not match my new assets. Is there anyway I can update CodeResources hashes without having to recompile my app?
Yes. Use the codesign utility. codesign will let you replace any existing signature with one for the identity you specify. (Here's a good blog post on the subject.)
You can see exactly what parameters Xcode is passing to codesign by looking in your build logs. Find the line beginning with "CodeSign AppName...", select it, and then click on the little button that appears to the right. It'll show you the raw codesign command Xcode executed to sign your app. You should be able to unzip the .ipa, replace your assets, zip, and run the command from Xcode to re-sign the app.

Entitlement are not valid?

My friend send me Build & provision profile ok, 1st I install provision profile than I upload Build on my i pod device , I face this error. Entitlement are not valid?? could you please tell me how can i solve this problem
The standard Project template does not include the entitlements file. On your project, add a new file (File, New). Select Code Signing as the category under iOS, and pick "Entitlements" template. You can name the file Entitlements.plist.
Then, on your Target, go to Build Settings, and set your Code Signing Entitlements setting to the name of this new file.
You should be able to build and distribute it just fine now.