How do I create a release build in Xcode? - ios

Why is it that when I build an application, Xcode creates a debug build? I want to create a release build. How can I do this?

Product / Scheme / Edit Scheme..
And from the menu that comes up, select Release under "Build Configuration".

Xcode 11
I found this question because I had already finished debugging my app and I wanted to make a release build for the app store. I always forget which menu item to use, though. This answer is a reminder to me and others next time.
Choose the Generic iOS Device from the active scheme menu.
Then go to Product > Archive.
You may have to wait a little while for Xcode to finish archiving your project. After that you will be shown a dialog with your archived project. You can select Distribute app... and follow the prompts.
More Help
This answer is for those who are already all signed up with a developer account and just need to get the archive from Xcode to iTunes Connect. If you need more help signing up for a developer account and getting an app to the app store, read the following links.
How to Submit An App to Apple: From No Account to App Store – Part 1
How to Submit An App to Apple: From No Account to App Store – Part 2
App Distribution Guide (Apple Docs)
Submitting Your App to the Store (Apple Docs)

It is done over building an Archive version.
First connect a iOS device to your Mac. Then select that device as target in Xcode.
Now click on the tab "Product" and click on "Archive"

Leaving the original answer below, but this has not been the recommended method to create a "release" binary for distribution outside of Xcode in a long time — for that you want to Archive: see answers above.
If you are looking to debug/test a Release build in Xcode, this approach is still relevant.
To create a release build, you have to edit your current scheme (⌘<) and highlight "Run [name of application]. On the right, select "Build Configuration" and choose "Release". Build as usual.

If any one needs to go through how to make Adhoc build, here are quick steps
Product > Archive
then
Export > Save for Ad Hoc Deployment ....
See quick video https://jumpshare.com/v/rHLJII2npwyHCgGCabQA

Follow these steps:-
Go to product option
select Scheme option
Edit Scheme option
change Debug to Release
Make sure Through this you can run build in your physical device if you are disconnected to System..
but if you will run the same code o n simulator then you will face some error then that time you need to change the scheme option Release to Debug

Here is my 'more detailed' list of steps for creating a release build > (Working on a team and a project that has many schemes and environments)
checkout a new branch like releases/x.x.x that contains all changes. (x.x.x is the version) (Its more about your team conventions)
Check to make sure your app bundleIdentifier is correct (might differ for each environment)
Team/account/licence: log into correct account that has provisioning profiles. then under signing and capabilities make sure your Team is correctly selected and has all certificates needed
Upgrade the version in project settings to x.x.x
Make sure the scheme you selected is correct
Make sure the URLs of API calls are pointing to your release environment
Its better to select 'Any iOS device' instead of a simulator or actual device
Commit any changes locally if you have any (this step is very important)
Validate to make sure all is good
Create an archive
Distribute your app for AppStore Connect
I use an apple proxy named 'transporter' that is pretty easy for uploading iPA to Appstore
Happy releasing!

Related

Xcode 8 A valid provisioning profile for this executable was not found

I know there are other questions asked like this here but I've followed all their solutions yet still end up with this error message.
I have a valid Apple Developer account with program active.
I have tried using managed and unmanaged provisioning with new/fresh bundle ID's (which get recreated provisioning profiles).
I have tried this: A valid provisioning profile for this executable was not found for debug mode
I have tried this: XCode :7 App installation failed :A valid provisioning profile for this executable was not found
I have deleted any old versions of the app from my phone.
I have confirmed my device ID on the developer portal is the same as in Xcode (was also useful for manual provisioning profile management to confirm)
I even tried another developer ID I have out of sheer desperation and yet the same error appears.
I even get this error when building for release scheme with my valid distribution certificate.
I've spent a ton of time trying to figure this out now I'm hoping someone else has felt my pain and actually solved this.
UPDATE: Adding screenshots for usefulness
UPDATE 2: I gave up trying to solve this problem, I created a new project and copied source files into the new project and I now have it working. Clearly something in the project configuration/settings files got corrupted somehow in the previous project which no obvious fix available. Will leave this question open, perhaps someone has a solution eventually. I have my old 'non-working' project so will continue to try those just for curiousities sake.
Before this error message, Build Succeeded is shown.
ATTENTION!
Who should read
If you were developing with a "Personal Team" and is switching to a paid team, then you'll get this error if you have not updated your other targets as well.
The cause
Since I'm using react-native, I happen to have a target for test (i.e. a target called appTests), and switching the team just in one target wasn't sufficient, and leads to this error. This error isn't informative enough to let you know there's an error in one of the targets, therefore leading to a long debugging time for myself.
Solution
1) On Xcode 9, go to every targets and update the team!
2) Unfortunately, the next steps aren't very reliable from my experience, you might have to do your best to clean the caches.
3) Stop every single running scheme/application by using the stop button
4) Go to Product -> Clean and cleans every schemes you use.
5) Quit and Restart Xcode
6) Run again and hopefully it works! If not, it's likely some cache are still present.
You can't install a build that was signed with the app store distribution provisioning profile and certificate (I'm assuming your release scheme is set to use your app store cert and profile). It will fail to install on the device if you try. You need to use either a development profile, or an enterprise distribution profile to install on test devices. The iOS Distribution certificate can only be used to build an app that will be installed via the App Store.
Thats a conflict of Xcode. The way I solved it is by deleting the derived data of Xcode.
Xcode > Preferences > Locations
You will see an arrow right from the path of the DerivedData which will open them in finder. Just erase everything in the folder.
Update: According to Chandler's comment check if there is a need to delete the test target.
I solved it by changing the build system to legacy in Xcode 10
File > Workspace Settings > Set Build system to "Legacy Build System"
It works when I also add the correct signing for myProjectTests. This was the last thing I did after trying all sort of solutions for 5 hours.
I followed many proposals but it didn't work until I unchecked Automatic signing for the TESTS
Clearing the DEVELOPMENT_TEAM and DevelopmentTeam entries in the xcodeproj/project.pbxproj file worked for me.
I'm on 8.2.1 and just had this same error. Deleting the original project folder and recreating it worked seamlessly. I verified that all of the signing and provisioning certificates were exactly the same as the last project. I'm not sure where the issue lies, but I believe your assumption of corrupted files is accurate.
In my case it was a conflict with the development team.
I've solved by opening my xcodeproj/project.pbxproj and emptying the following variables:
DevelopmentTeam
DEVELOPMENT_TEAM
We had a similar issue: we deleted the Unit Tests and it worked.
In my case, it was the problem when I setup my time manually two month earlier on my iPhone. But when I changed to set time automatically, it worked fine.
Setting -> General -> Date & Time -> set time automatically
GOTO: Targets->yourProjectNameTest and verify that team is the same as on yourProjectName
I had this problem too, and for me the solution was to sign in to https://developer.apple.com. There was a red bar, going like "our TOS have changed, you have to accept them again", I did, and then my provisioning profiles worked again immediately.
An easier fix is to uncheck the test target as part of the Analyze & Run steps in Edit Scheme > Build -> Build.
This is very specific to React Native projects, since this is how the projects are configured by default.
In my case it worked for me to follow the instructions in this article. Then disable Automatically manage signing inside xcode in the general tab.
Automatically manage signing disabled
And finally provide manually Provisioning Profile for Signing (Debug) and Signing (Release)
Note: The Provisioning Profile you must generate it from Apple Developer Program website, in the section Certificates, Identifiers & Profiles -> Provisioning Profiles
I hope you find it useful. regards
Step to be followed
must have a developer account - https://developer.apple.com
create a certificate for development
Add devices with UDID
add provisioning profile in development
sign in Xcode with your account
clean build
Build with any destination choose device I have done for iphone 6
the archive will be disabled first, the archive will be active by choosing
generic ios device from the right corner of Xcode for example ->
yourAppName>generic ios device
once archive is done build for development not ADHOC
done
I fixed it by setting in main Target / Build Settings / Section Signing
Code signing Identity: Debug and Release set to IOS Developer
Code Signing Style: Automatic
Provision Profile: all automatic.
I set this exactly same for Test Target.
Then i was able to run release version on my phone. Btw i dont know what is the difference between IOS Developer and iOS Distriobution though.
I had edited my app scheme Build Configuration from Debug to Release, and unchecked the Debug Executable.
I am not sure why, but if it makes a difference my signing details for Debug and Release were different. So after I reset those back to Debug and checked back the Debug Executable box, and all was fine again.
Edit: found out it was because I was trying to run release mode on my phone via App Store provisioning profile and App Store profile doesn't allow this. I switched to Ad Hoc and there is no more issues.
I guess you already tried this, but I just got the same error, and a quick restart of Xcode worked for me.
Just upgrade to Xcode 8.1. It solves the problem.

Xcode won't let me upload my app

I have an iOS app created with Cordova, and have just paid my $99 to apple to upload it to the App Store. I've created the app archive, but in the Organizer Upload to App Store… is grayed out, and I've got "Distribution requires enrollment in the Apple Developer Program."
Here is my account in preferences, which I have tried removing and re-adding
What am I missing?
I see you have two Team entries. I believe the issue might be because you have the "Personal Team" option selected under your Project settings page.
In Xcode, in the Filesystem sidebar, select the Project node, select your main Target, and choose the non-Personal Team entry. Ensure you have a device selected so you can provision it, then rebuild and rearchive, then it should work.
What happened to work for me was to "Enable Bitcode: Yes" under Build Options in my project target in Xcode. With that enabled I was able to upload to app store via the Application Loader.
I had to archive the project and export with bitcode attached.
I know this is way past the time for the original post, but hopefully it can help someone looking for a similar solution.

Entitlements / Capabilities per Xcode scheme

The Apple Pay entitlement / capability is only valid in the App Store. I am releasing this app in both the App Store and Enterprise.
If the App Store Release scheme is selected I'd like Xcode to enable the Apple Pay entitlement.
If the Enterprise Release scheme selected I'd like Xcode to disable the Apple Pay entitlement.
You can achieve the desired behaviour by using a different build configuration.
Copy the entitlements file and adjust it to your needs, e.g, remove the Apple Pay entitlement for enterprise distribution
Select the project on the project settings view
Add a new build configuration, e.g., AppStore
Switch to your app target and adjust the value for the new build configuration.
Create a new scheme, e.g., AppStore and select the new build configuration in the "Archive" Section of the scheme settings
In general, it is a good idea to have separate schemes and build configurations. That way you can support several different build configurations depending on your needs, e.g., Enterprise distribution, Hockey Testing, App Store etc. .
If you want to make your project setup more maintainable consider using xcconfig files to organize your build settings.
A possible approach:
Put your different schemes' entitlements files in a folder
Have your project or target's Build Settings > Code Signing Entitlements point to a location such as $(PROJECT_DIR)/AppName/AppName.entitlements
In Edit Scheme > Build > Pre-actions, add a "Run Script" action to copy the entitlements file for that scheme, to the location you specified in step 2. e.g. cp ${PROJECT_DIR}/entitlements/DevScheme.entitlements ${PROJECT_DIR}/AppName/AppName.entitlements
I had done this for some time. My solution was based on git branches. I had four branches: master, app-store, enterprise and feature.
Among these, app-store and enterprise were derived from master with their own variations, and feature was for new features in development.
Every time I finished building a feature and QA people finished verifying it, I would merge it to master , then merge master to app-store and enterprise.
I'm not that proficient with git, but I managed to work smoothly.
I've checked other answers, and realize my solution is a little silly :).

Instruments stopped working on iPhone apps

I had used Instruments tool (an Xcode developer tool) to analyze iOS applications before with no issues. But now when I try to run it on any iOS app (for instance CNN), it is giving me following error.
"Target failed to run: Permission to debug com.cnn.iphone was denied. The app must be signed with a development identity (e.g. iOS Developer)."
Is there any work around? Is it not supported anymore in new version of Xcode? Few months ago, I was able to use it on all applications including CNN.
Just edit a Profile section in target scheme. Switch Build Configuration to Debug.
Assuming that you are using the Release configuration to run in Instruments (as recommended), you need to review the code signing and make sure that Release is configured to use your Developer identity (instead of Distribution, for example).
First click your target
Choose Edit Scheme...
Select Profile and make sure Build Configuration is what
Here, my Build Configuration of Profile section is AdHoc. Don't change this selection to Debug, cause in Debug mode, it won't be optimized by compiler like AdHoc or Release.
Then come to Build Settings, change the Certificate and Provisioning Profile.
From this picture
To this picture
It's done!
The application (one wants to run Instruments libraries on) has to be in running state and then select from the 'Running Applications' category and not from the 'Installed Apps' category and that should work.

Steps to upload an iPhone application to the AppStore

I want to know the basic steps for uploading my iPhone application to AppStore.
How do I make a provisioning profile using a certificate and what other settings do I need to do to upload an application?
I have just made an application on my iMac using Xcode and the iPhone SDK V2.2.1. What do I need to do for uploading it on the Apple iTunes store?
I am member of that and I have also a distribution certificate.
This arstechnica article describes the basic steps:
Start by visiting the program portal
and make sure that your developer
certificate is up to date. It expires
every six months and, if you haven't
requested that a new one be issued,
you cannot submit software to App
Store. For most people experiencing
the "pink upload of doom," though,
their certificates are already valid.
What next?
Open your Xcode project and check that
you've set the active SDK to one of
the device choices, like Device - 2.2.
Accidentally leaving the build
settings to Simulator can be a big
reason for the pink rejection. And
that happens more often than many
developers would care to admit.
Next, make sure that you've chosen a
build configuration that uses your
distribution (not your developer)
certificate. Check this by
double-clicking on your target in the
Groups & Files column on the left of
the project window. The Target Info
window will open. Click the Build tab
and review your Code Signing Identity.
It should be iPhone Distribution:
followed by your name or company name.
You may also want to confirm your
application identifier in the
Properties tab. Most likely, you'll
have set the identifier properly when
debugging with your developer
certificate, but it never hurts to
check.
The top-left of your project window
also confirms your settings and
configuration. It should read
something like "Device - 2.2 |
Distribution". This shows you the
active SDK and configuration.
If your settings are correct but you
still aren't getting that upload
finished properly, clean your builds.
Choose Build > Clean (Command-Shift-K)
and click Clean. Alternatively, you
can manually trash the build folder in
your Project from Finder. Once you've
cleaned, build again fresh.
If this does not produce an app that
when zipped properly loads to iTunes
Connect, quit and relaunch Xcode. I'm
not kidding. This one simple trick
solves more signing problems and "pink
rejections of doom" than any other
solution already mentioned.
Apple provides detailed, illustrated instructions covering every step of the process. Log in to the iPhone developer site and click the "program portal" link. In the program portal you'll find a link to the program portal user's guide, which is a really good reference and guide on this topic.
Check that your singing identity IN YOUR TARGET properties is correct. This one over-rides what you have in your project properties.
Also: I dunno if this is true - but I wasn't getting emails detailing my binary rejections when I did the "ready for binary upload" from a PC - but I DID get an email when I did this on the MAC
Xcode 9
If this is your first time to submit an app, I recommend going ahead and reading through the full Apple iTunes Connect documentation or reading one of the following tutorials:
How to Submit an iOS App to the App Store
How to Submit An App to Apple: From No Account to App Store
However, those materials are cumbersome when you just want a quick reminder of the steps. My answer to that is below:
Step 1: Create a new app in iTunes Connect
Sign in to iTunes Connect and go to My Apps. Then click the "+" button and choose New App.
Then fill out the basic information for a new app. The app bundle id needs to be the same as the one you are using in your Xcode project. There is probably a better was to name the SKU, but I've never needed it and I just use the bundle id.
Click Create and then go on to Step 2.
Step 2: Archive your app in Xcode
Choose the Generic iOS Device from the active scheme menu.
Then go to Product > Archive.
You may have to wait a little while for Xcode to finish archiving your project. After that you will be shown a dialog with your archived project. You can select Upload to the App Store... and follow the prompts.
I sometimes have to repeat this step a few times because I forgot to include something. Besides the upload wait, it isn't a big deal. Just keep doing it until you don't get any more errors.
Step 3: Finish filling out the iTunes Connect info
Back in iTunes Connect you will need to complete all the required information and resources.
Just go through all the menu options and make sure that you have everything entered that needs to be.
Step 4: Submit
In iTunes Connect, under your app's Prepare for Submission section, click Submit for Review. That's it. Give it about a week to be accepted (or rejected), but it might be faster.

Resources