App won't launch after Fastlane build and publish to App Center - ios

We're using Jenkins and Fastlane to automatically build and publish an app to App Center.
The publishing step is successful and it can be downloaded through App Center, but the app won't launch (it opens and immediately closes).
The builds we have submitted manually have a Provisioning Profile listed in the Release:
But the Fastlane builds have no value specified here, even though the logs say "All required keys, certificates and provisioning profiles are installed".
UPDATE: I've done some more digging and checked out the difference between a correct .xcarchive and an .xcarchive that leads to issues. The problematic one has no signing identity in its Info.plist ApplicationProperties SigningIdentity.

It seems that this lack of a SigningIdentity in the Info.plist file of the .xcarchive was the root of the problem.
I solved it by going to Keychain Access and setting When using this cerficate: to Use System Defaults on my distribution certificate.
With this in place, the SigningIdentity is set properly when creating an archive, and the generated .ipa successfully launches on my device.
So it turns out this had nothing to do with Fastlane, just the settings on my Build Server.
I didn't figure this out on my own, this post saved me: iOS 12 enterprise apps crash upon launch

Related

keychain-access-group entitlement not updating

The provisioning profiles for my apps that come down from Apple have the keychain-access-groups entitlement turned on. My local Xcode does not have this entitlement (capability) turned on. This is resulting in local entitlements that don't match those available in the provisioning profile's entitlements and my adhoc distributed builds are not installing in our devices.
To make matters worse, I am working with multiple bundle ids within the same target (using scheme and config modifications. Not ideal, I know), so when I go to muck with the capabilities tab, it's unclear which App ID I'm editing.
I have temporarily overridden the bundle id, so I know which app id is being edited via the capabilities tab. But, nothing I'm doing seems to edit the provisioning profiles available via the dev portal. Nothing gets invalidated. (I see the local entitlements file being edited immediately just fine)
I'm using Xcode 7 (7.3.1).
I've tried restarting Xcode. I also tried running on a local device (checking and unchecking the capability) hoping that would update the used provisioning profile. Still no change seen in the dev portal.
UPDATE
Later that same day, checking/unchecking the capability started showing network activity spinners within Xcode and the dev portal started updating immediately (provisioning profiles were invalidated). However, the next day, managing a different app, back to the same issue where I'm not seeing any updates in the dev portal.
How do I edit this entitlement consistently?

Xcode: Problems with getting my App to the AppStore

I am trying to upload my app to the AppStore with Application Loader
I tried to archive my project in order to generate the "ipa" file for Application Loader and the archive process got stuck at "Compiling swift sources" for almost 5hrs; I took to the response I read from - Xcode 6.0 taking forever to archive my project and I successfully generated the .ipa file with iTunes but while trying to upload with Application Loader, I get the error:
ERROR ITMS-90161: "Invalid Provisioning Profile. The provisioning
profile included in the bundle com.youngbobby.MyAppName
[Payload/MyAppName.app] is invalid. [Missing code-signing
certificate]. A Distribution Provisioning profile should be used when
submitting apps to the App Store. For more information, visit the iOS
Developer Portal."
I have generated my keychain certificate and my distribution provisioning profile and I still get that error during submission. Do you think the error is related to the method I used? Do I have to maintain the traditional "archive" method? If yes, what would be the fastest way to archive and generate my .ipa file? I have tried enabling Whole Module Optimisation as suggested here all to no avail.
Any help would be greatly appreciated.
EDIT
I did a quick check on why my archive process was stuck at "Compiling swift sources" using "cmd + 8" and I noticed that my local Data store swift file which is a long Dictionary of type [[String:Anyobject]] was the cause of the problem. I can't really explain why it is so but I want to maintain the traditional method of archive and send because it seems using iTunes to generate my ipa file does not agree with my provisioning profile.
When you are building the project, it is still building for debugging, hence it is using the development provisioning profile.
Before you do the build to create the .app, go to the Scheme (just to the right of the stop button, to the left of the device on which you are running).
Click that and choose "Edit Scheme..."
Under the Run section, there is a setting for Build Configuration.
Change that from Debug to Release (if you are using the standard build config and you have configured the Release config to use your distribution profile and signing identity).
Close that window, then change your device to the generic "iOS Device option (make sure you don't have any devices plugged into your Mac).
Once you've done that, run your build again and the ipa created should be built with your release configuration and signed correctly.
You are probably using a Development Provisioning profile.
Go to your dev center.
Create a new provisioning profile, select App Store and select your bundle ID. create that and download it.
Control drag that provisioning profile to Xcode, Change build settings in target and project to the one you downloaded now and as Distribution.
Compile and build your app. Archive it and start uploading it to App store.
That should do it.
P.S do select your team correctly before you configure your build settings.
EDIT
If you already have done these steps just revoke the old one and create a new Provisioning profile and check.
Finally got my problem solved.
It seems all I needed to do while my app was compiling swift sources was to WAIT
I reduced the amount of Data in my Datastore file and the Archive process took less than 10 seconds to archive.
Pity, Xcode does not show a Timer to calculate how long it would take to archive a project and looking at the progress bar does not really guarantee that the process is working as in my case was a relatively huge one. So, maintaining the huge data I had, I simply had a 6hr nap and by the time I was up, my project was successfully archived and all other processes worked seamlessly :)
If you find your project 'stuck at compiling swift sources' during Archive Process, all you need to do is Wait.

IPA created via Xcode bot fails to run for APNS but runs if built manually via Xcode itself or built as an archive by Xcode

I have a CI build machine running Xcode server and using a bot to generate a build, however the .ipa built via the bot is not being entitled to register for the APNS token.
Specifically, didFailToRegisterForRemoteNotificationsWithError gets called and there is a runtime warning of ""No valid 'aps-environment' entitlement string found for application".
However if I build the app on a separte development PC, or I build it actually on the CI machine independently of the bot then everything is fine.
I've used push notifications extensively in several apps so know that the message "No valid 'aps-environment' entitlement string found for application" always appears if the app has not been signed with the correct profiles. However I have absolutely 100% confirmed that the app is being built with the same profiles when running as part of the bot build to when I build it manually.
I also know that Xcode downloads provisioning profiles to different locations when running under the bot to when running for a user, and I also know that the bot runs as system and not the logged in user when I build manually. I have taken all these differences into consideration but am still unable to get the bot build to work.
What's more I have used this exact same CI machine to previously build this app using Jenkins (which also ran as system) enabled for push and it worked!
These is what I have done/checked:
1)
Download the project manually to the desktop, open in Xcode and examine the signing identity and provisioning profiles being sued in the build settings. Build and run it manually using Xcode -> it works
Download the project indirectly via the bot as part of its integration run. Open the project downloaded by the Bot in Xcode (the Xcode server downloads it to: /Library/Server/Xcode/Data/BotRuns//Cache/NNNN). Do the same thing, check the signing identity and provisioning profiles. THEY ARE IDENTICAL to those used when I build on the desktop
OK so the problem is not due to a difference in the actual signing identity and provisioning profiles being used.
2) When you run Xcode manually it downloads the provisioning profiles to location X, but the Bot downloads the provisioning profiles to location Y. So I have examined the contents of X and Y to make sure there is nothing missing from Y (if there was the build would actually fail however, which it doesn't).
To make absolutely sure they are identical I have copied the entire contents of X into Y and run the bot again (they don't get overriden by the bot) - So now the bot and the desktop builds are using the exact same copies of the profiles yet still there is a difference when the .ipa executes.
Incidentally the location of X is ~/Library/MobileDevice/Provisioning Profiles and that of Y is / Library/Server/Xcode/Data/ProvisioningProfiles.
3) When I build manually it is as the logged in user, but when the bot build it is as the system. So within the keychain I have tried copying all the certificates and keys from the user's keychain into the system keychain. Yes still it makes no difference, the .ipa created by the build bot fails to run properly while the build created manually via Xcode does run.
This is driving me mad and has wasted days already, what else could I have missed or could try to resolve this?
Any suggestions or ideas?
I have found the exact cause, as to the reason behind the cause I don't know, thus I'm marking mine as the accepted answer as it is at least a workaround to anybody who encounters the same problem. I'm tempted to think the reason is due to a bug in the bot system which is mistakenly expecting there to be an entitlements file.
I've discovered that the reason the bot build fails is because the bot is not placing the aps-environment entitlement into the .app file even though that entitlement is within the embedded.mobileprovision. But XCode does insert it into the .app file if built manually or an archive is built.
Also I've found that I can force the bot to put the necessary entitlement and associated information into the .app file if I use an Entitlements.plist.
But this is using Xcode 5 - entitlement.plist files are a thing of the past, so it should not be necessary to use one just to force the bot to place the entitlement into the .app, hence why I suspect it might be a bot bug.
Are you tried to unzip your .ipa and check embedded.mobileprovision they should be the same. Also just for sure check that you not use developer profile to release build in bot/xcode.
Shooting in the dark:
Although you said that the provisioning profile works great when you are running the build manually, have you tried creating a new provision profile from scratch and use that on the CI build machine using the bot?

Archived IPA won't install onto my phone

I've done this a few times before with my own apps.
I've started working for a client and using there account I've created the necessary files on the dev portal. Downloaded and install them on my machine.
Followed the instructions to create an archived IPA for adhoc distribution.
Drag it into iTunes.
Then drag it to my device in iTunes. When i start dragging the app icon a red badge appears, but the app never starts to sync onto the phone.
I opened the ipa and looked at the mobile provisioning file and I see that my phones UDID is
included there.
Can anybody give me some insight into what the problem may be?
I had this happen when I could see myself in the provisioning profile under its code-signing identity but I was not on the distribution profile. And the issue relied on the build settings.
Go to your project -> Build Settings and check under Code Signing. Confirm that you are using the correct developer profile. Pay extra attention to mismatches between bundle identifiers.
Check the validity of the distribution profile in the same area.
Archive and make sure you are using the correct build configuration. When creating the ipa file confirm for the correct distribution profile again.
Hope that helps
There can be many reasons for that. one thing that cross my mind:
Check if their device iOS version is not higher then the SDK you are using or lower then your deployment target.
I can also recommend to use Testflight service (search Test Flight iOS in google), it is perfect for distributing builds to customers.

Problems with code signing for ad-hoc distrubution for iPad App

I've been trying for a weekend now to install my application via ad-hoc means for beta testing and demo purposes. I can install from Xcode just fine, but when I try and take the app file and place it into iTunes, then try and synch, I keep getting the error "The application was not installed on the iPad because it is not signed".
I have gone through all the steps. We went to the provisioning portal and added all the devices. We then downloaded a distribution provisioning profile and installed that onto the development computer. We created an Entitlements.plist file, though there was no get-task-allow attribute, so I had to add in my own. I cleaned the targets, restarted Xcode, built the application under the ad-hoc profile with the Entitlements.plist set for the Code Signing Entitlements.
I take the app file that's generated and drag it into the Applications area of iTunes, hit synch, and I get the error.
I know I am doing something wrong, missing a step, but it must be a convoluted, obscure step that Apple doesn't have in their documentation. So can anyone see the problem in what I'm doing? If you could, let me know. Thanks.
Ok. Yay. Figured this out after some more hair-pulling.
Apparently, the build you follow is important. I kept testing and building to the Simulator folder, and this is wrong.
To deploy to a device, you should clean all targets and then build specifically to the device. You don't have to run it or have something plugged in, but you must build to device. The APP that is produced is different for simulator as it is for device.
Did you set the "Code Signing Entitlements" build setting in your target to "Entitlements.plist"?

Resources