Phonegap/Cordova to ipa file without Phonegap build - xcode

I use Phonegap Build to create my Android and iOS app files. However I want to compile the files locally on my computer, and not use Phonegap Build. I have done this successfully for Android (see here: https://cordova.apache.org/docs/en/latest/guide/platforms/android/) but iOS is more complicated. I have little Apple-knowledge.
Does anybody know of any good tutorials on how to import a Phonegap plugin in to the xcode environment...ideally one for someone who's background is NOT an Apple developer.

I have managed to do this myself but I've answered my own post to help others who may be in a similar situation - Please note this is correct as of end of 2019, and I had already successfully uploaded an IPA file to the app store via Phonegap Build before. All I'm doing here is compiling my Phonegap/Cordova project IPA file directly on a Mac, rather than using Phonegap Build:
1) You will need a mac and a developer license (as expected). You will be using both a terminal window where possible and Xcode.
2) Certificates and provisioning are a messy nightmare right out of satans bumhole. But just make sure you set up an "App store distribution" profile on your developer.apple.com account. If you don't know how to handle certificates and provisions please read here https://medium.com/ios-os-x-development/ios-code-signing-provisioning-in-a-nutshell-d5b247760bef.
But remember you only need to download the certificate to your Mac, and add it to your "My Certificates" area. The provisions can be automatically downloaded/linked to via Xcode.
3) Install Xcode 11 on your Mac. Forget all the other versions.
4) Install Cordova CLI on your Mac using the terminal - open up the terminal window and type:
sudo npm install -g cordova
5) Create a FRESH cordova project - dont try to be smart by shoe-horning the one you've already used on your PC:
cordova create hello com.example.hello HelloWorld
...you might need to to add "sudo" to the front of that. Don't copy and paste any html files or plugins in to it yet!
6) If your Mac might give you read/write access problems. So locate the entire folder, ctrl+click on the project folder, choose "get info" ...in the bottom right of the popup window click the lock icon and enter your password. Now change all settings to "read and write", then click the cog icon and select "Apply to enclosed items".
7) Create the platform : sudo cordova platform add ios#5.1.0....note, DO NOT use ios5.1.1 if you are using firebase or push notifications, as it seems to break with 5.1.1.
8) Apple will (again) probably give only read access to your new platforms/ios folder, because it hates you and wants you to suffer. So repeat step 6 if necessary.
9) Open Xcode the following way... In your projectname/platforms/ios/ folder locate the .xcworkspace file. This is the file you use to open your project. DO NOT use the .xcodeproj file because this is for older Xcode versions (and it will just break your whole damn project). Also go to File->Workspace Settings and ensure Build System is set to "Legacy Build System".
10) Now piece together your config.xml file by extracting the bits you need from your previous config file to your fresh new one. Don't bother moving over any android-specific bits.
11 a) Apple bring you a fresh slice of hell with cocoapods - a dependency manager for Swift and Objective-C. You'll need to install this if your app uses certain things like push notifications (firebase for example). You can install this via the terminal window. FIRST....close down Xcode. NEXT go to projectname/ and type: sudo gem install cocoapods. FINALLY go to projectname/platforms/ios/ and type pod install.
11 b) There's a bug...a pretty major one. Your cocoapods will fail when building at this point. So you need to do some hacking here. Navigate to the directory projectname/platform/ios/Pods/TargetSupport Files/Pods-yourproject and look for
Pods-yourproject.debug.xconfig and Pods-yourproject.release.xconfig
You need to copy the content of these files into platform/ios
pods-debug-xconfig and pods-release.xconfig respectively----THANK YOU kyale-mwendwa for this tip....https://github.com/phonegap/phonegap-plugin-push/issues/1825#issuecomment-359155007
12) Now copy and paste your www folder over in to your fresh project. You are ready to build your project...
13) Re-open xcode using the .xcworkspace file. Now you need to ensure your provisioning is set up correctly for your release. Click the project name at the top of the left-hand column (right above where it says config.xml). Now in the main window click your app name under the "Targets" section. Now select "Signing and Capabilities". If you managed to set up certificates and provisions correctly you should be able to select your "team" (no I don't know either, just select whatever option you can here), and enter the correct bundle identified (com.whatever.whatever).
14) Ok, you are ready to create your IPA file. Still have hair?? Bonus points for you!
Just before this next bit, go to Xcode and towards the top of the screen you will see the project name followed by "> iPad (7th generation)" or something similar. Click this and make sure you choose "Generic iOS device".
Now back in the terminal enter sudo cordova build ios. You don't have to transport your plugin files over from your windows-built cordova folder. Cordova will detect the plugins you need from your config.xml and install them appropriately.
15) If you have no errors you can now create your IPA file and even submit it directly to the App store (this bit of Xcode is actually really good). In Xcode, from the menu at the top click "Product" and then "Archive". Follow the onscreen instructions. At this point your IPA file is created.
You can choose to automatically distribute your file to the Appstore, but I suggest clicking the "Validate App" option first, which will re-request the correct certificates/provisions and give you a summary of any issues. If no issues you can click "Distribute App" and it will upload the IPA file to your Appstore Connect (formerly iTunes Connect) area.

Related

How to open higher xcode version project(13+) into lower xcode version(12 or lower)?

I recently updated my XCode to latest(period) 13.3 and working on a project on that, Now when i moved that project to other mac which has MacOS Catalina and has XCode version 12.3.
When i try to open the project it keeps showing me this dialogue
But i found a solution to make it work on lower version XCode which can be useful to other people too, So i am including answer too.
Hope It Helps :)
Just have to follow steps given below
Right Click On Your_Project_Name.xcodeproj and select Show Package Contents from the option menu. { Even if you have .xcworkspace, ignore it for now }
Open project.pbxproj from opened folder.
Change object version to 46 like given below
Hit Command(⌘) + S to save it and close the window.
If you have pods installed on that project then you have to reinstall them again { I guess you already know how to do that or follow setps given below }
Open Terminal
Run Command cd PATH_TO_YOUR_PROJECT_FOLDER, Hit Enter
Run pod install {No need to open podfile as we never made a change to it} and we're done
Go back to project folder and open Your_Project_Name.xcodeproj or Your_Project_Name.xcworkspace
NOTE:
Since It is work around way, we can not run this on newer iOS version simulator on which we want to test code However, we can run the code on physical device which has newer iOS version { which is also tricky part! }
TO RUN THE CODE ON LATEST IOS PHYSICAL DEVICE, FOLLOW BELOW STEPS
Download zip of your desired iOS version to run from the link
Close the XCode App.
Right click on XCode App from Application and select Show Package Contents
Move the downloaded folder to Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport.
Open the project and run it on physical device
If you get error of Unable to install the Application, click on Details and try to resolve it.
If your error says The code signature version is no longer supported then check out this answer, it solved the error.
Hope It Helps !!!

Getting "Failed to create IXPlaceholder for app bundle ID" after installing xcode on an external drive

After struggling with space issues I finally bought an external drive for my Mac. I deleted my existing copy of XCode that was installed on the internal drive, downloaded the latest version from the apple developer site, and installed that to the external drive. I can open & build my project just fine, but when it comes to running it in the simulator, I get the following error:
"Failed to create IXPlaceholder for app bundle ID"
I did search on that, and found some answers that boiled down to "run xcode-setup --install", which I did, but it did not fix the issue.
The simulator does come up & run, it just doesn't load my project.
I'm pretty new to Mac/Xcode development, so hoping this is something basic I'm missing.
Delete your derived data first if not work try;
Go to your project and once you are on the build phases tab you should see a section that says Embed App Extensions, click on to extend.
Now that you will see a opened Embed App Extensions you should see a checkbox that says Copy only when installing. You need to check that checkbox.

Adding an unattached UDID to existing project in XCode

Sorry, I'm sure this question is quite basic, but from what I've read I'm doing it correctly and still not having any luck.
I have a project in XCode. It compiles correctly and I can install it ad-hoc on all the devices that were originally part of the provisioning profile I created when I first started the project.
I now have another UDID that I need to add so they can test. They live on the other side of the country, so I can't attach the device and add it through XCode.
So from my understanding, these are the steps I have taken:
Over at developer.apple.com, add the UDID to the device list.
Update the provisioning profile on the developer website to include the added UDID.
In XCode, open organizer, select provisioning profile and hit refresh.
Recompile.
Am I missing a step in there? It recompiles fine but apparently won't install on the added device.
EDIT: I found This Post, which sounds like what I want, but I can't find the checkbox for "Automatic Device Provisioning". Where is that located?
It seems that the "Automatic Device Provisioning" checkbox has been removed from later Xcode versions, check this question: The Automatic Device Provisioning options have gone since upgrading to Xcode 4.3.1?.
The steps you listed seem good. You could check if the new profile has been effectively inserted into the ipa file:
- rename the .ipa in .zip;
- navigate into Payload and then contents of the .app package;
- open the embedded.mobileprovision file with a text editor;
- search for the new UDID string inside the file.

How to make an IPA on XCode 4.3?

I have a Mac OS X Lion setup with XCode 4.3. I am not a registered Apple developer.
I told, via the plist files: /Applications/Xcode.App/Contents/Developer/Platforms/iPhoneOS.platform/Info.plist and
/Applications/Xcode.App/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist, XCode not to require codesigning.
I then compiled my project, just a basic iPhone app project, it ran well in simulator. I could build and archive it, then sign it using a self-created certificate and the archive appeared in the Organizer.
Nothing strange for the moment, but there comes the problem: I have no "Share" button in the organizer. I absolutely need to make an IPA file out of my project if I want it to work under an iPhone as it won't accept xcarchive files. I only get the "Validate" and "Distribute" buttons which both require to be a registered Apple developer. But, no "Share" button which enables building an IPA... for free.
I have gone through XCode settings but nothing seemed to help me there. Even the documentation says a Share button is available in XCode 4.3, so my question is: Why don't I get the possibility to make an IPA? IS there any workaround to get this Share button or make an IPA out of the xcarchive via any command line or whatever?
Here's how you can make an IPA in XCode 4.3:
To Disable Code Signing:
Go to /Applications.
Right click on XCode and select 'Show Package Contents'.
Copy Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/SDKSettings.plist to your desktop. (Make sure to actually copy and paste. No drag and drop)
Open it and under DefaultProperties set CODE_SIGNING_REQUIRED to NO.
Copy it back and replace the original file.
Restart XCode.
Open your project.
In Project Navigator select your project and open Build Settings section of your porject (and not any particular target)
Under Code Signing find Code Signing Identity and for both Debug and Release modes set Any iOS SKD to Don't Code Sign.
Now you should be able to build your project without any errors.
To make an IPA:
In 'Project Navigator' select Products
Right click on [NameOfYourProject].app and select 'Show in Finder'.
Create a folder and name it Payload
Move [NameOfYourProject].app to Payload.
Compress Payload and rename it to [NameOfYourProject].ipa
You should be able to get an IPA by clicking 'Distribute...' in Organizer->Archives, and choosing to 'Save for Enterprise or Ad-Hoc Deployment'.
Beginning iOs 5.1 Apple moved their files from /Developer/... to XCode->Show Package Content
In order to export codesign_allocate correctly run this line on your Mac terminal :
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate

How to get .app file of a xcode application

I have created an xcode project. Now I want to give .app file to my friend to use that application. From where do I get this file? How to install this .app file in his Applications folder using an installer package?
You can find the .app file here:
~/Library/Developer/Xcode/DerivedData/{app name}/Build/Products/Deployment/
Credit for the path location goes to this answer
SIDENOTE: I had a lot of fun trying to get this into my iPad after that. It worked however. Using Snow Leopard + Xcode 4.2 + iPad with IOS 5.1.1 :) - I used the iPhone configuration utility to get the app into the ipad (you have to add the app, then click on the device, then click "install" behind the app you just added in the "application library" of iphone configuration utility) and had to create a Distribution Provisioning Profile and get the WWDR certificate and finally change the build settings in Xcode after all the certificates were in place. See here
But after much fun I am now looking at my first app on my iPad :) - btw, for getting apps into the app store you need to create a app store Distribution Provisioning Profile, while for ad hoc installs like these you create an ad hoc one. There is a bit more to it, but I think these are the most important and tricky steps. Enjoy.
PS. Just remembered that you also have to set the build type (top left of Xcode) to "iOS device", otherwise it will never sign your application. So the path name above only has limited value: yes, it will have the .app file in it, but no you can't upload it (at least not using the iPhone configuration utility) since it is not code signed - you will get an "Could not copy validate signature" error. So change it to "iOS device" and build (remember to select the right certificates in the build section of Xcode as per the url info above). In that same build section, you can also set the "Installation Build Products Location" to a different path, so that you can determine where the .app (the one that is properly code signed) ends up.
Xcode 12.5
Can be found in the following directory ->
~/Library/Developer/Xcode/DerivedData/{app name}/Build/Products/{scheme}-iphonesimulator/{app name}.app
Build a release version, and the .app file is under build/Release folder of your project. Just copy it to Applications folder of your friend's machine. I don't think you need to build a installer.
xCode window tab
Organizer
Right click to the archive you want to get app
Show in finder
Right click to (ProductName….). xcarchive file
Show package contents
Products
Applications
Finally - THERE IS YOUR .APP PROJECT FILE !
The application will appear in your projects Build directory. In the source pane on the left of the Xcode window you should see a section called 'Products'. Listed under there will be your application name. If you right-click on this you can select 'Reveal in Finder' to be taken to the application in the Finder. You can send this to your friend directly and he can just copy it into his Applications folder. Most applications do not require an installer package on Mac OS X.
Under Xcode 4.5.2, you can find the .app file in this way:
Select Window > Organizer in the Xcode's menu(or just press 'Shift+Command+2')
Select your project on the left side of Organizer, and you will find the Derived Data path on the right side. Just click the mini arrow in the end of the path, this will open Finder at the path.
In the Finder, click "Build > Products > Release", you will find the .app.
I know as for Appium Mobile Automation you need .app file to run ios app on Simulator.So as like me many of you face this problem.
So I explain how to create that .app file and where it is located.
1.Open Xcode.
2.Click on your sample project.(If you don't have then click on create new xcode project)
3.In left panel inside screen you will see products folder then click and expand that, you will see the list.
Then right click on .app file and click on Show in Finder and thats your .app file. Now you can copy or use that path in capabilities for appium desktop or in framework.
Xcode 8.1
Product -> Archive
Then export on the right hand side to somewhere on your drive.
In Xcode 7 a quick way is to use Product > Archive. It's probably not a signed copy for submission but it's good enough to give to somebody else for testing.
In the navigator (left pane), expand the group "Products" and right-click on the .app file and choose "Show in Finder". There it is! :)

Resources