- How To Easily Create Macos Apps Without Xcode Password
- How To Make A Mac App Without Xcode
- How To Easily Create Macos Apps Without Xcode Version
- How To Easily Create Macos Apps Without Xcode Install
Home | Articles | Talks
————————————————————————————————————————————--
15 Oct 2018————————————————————————————————————————————--
A build system, despite its scary-sounding name, is just a regular program, which knows how to build other programs. As an iOS developer, you’re certainly familiar with how to build a project using Xcode. You go to the
Product
menu and select Build
, or you use the ⌘B
keyboard shortcut.You may have also heard about Xcode Command Line Tools. It’s a set of tools which allows you to build Xcode projects directly from the terminal using the
xcodebuild
command. A very convenient thing for automating your processes, for example on your CI.No matter how you’ve initiated it, the building itself is orchestrated by Xcode’s build system.
You need to make one change. To edit it, open the macOS 10.15 folder where you stored it (VMX folder in step 4). If you did not specify its location, look in Documents virtual machines. Right click on the VMX file and choose “Open with”. Choose “More Apps”. From the list of apps that will be seen, choose “Notepad” and press Enter. Begin A macOS Project. Open Xcode and create a new macOS project. At this point, you are probably still in the “iOS” style project. We have to update this so that we are building for the correct system. Hit the “macOS” icon at the top, and then make sure that “Cocoa App” is selected. Hit “Next.” Create a new macOS project.
Can we replicate the building process and build the app “manually”, without Xcode’s build system?
Is it possible to sign the resulting app? Or even deploy it to an actual iOS device?
⚠️ Disclaimer 1 ⚠️
What is this post about:
Writing a non-reusable script that builds one concrete iOS project the simplest way possible.
What is this post NOT about:
Writing a complex and universal build system.
Content
The App We’re About to Build
I let Xcode 10.0 generate a new project using the
Single View App
template, and named it “ExampleApp”. This is going to be the reference app we will try to build “manually”. The only adjustment to the project I made was adding a UILabel
with ?
to the main (and only) ViewController
.I also created the
build.bash
file in the root folder of the project. We’re going use this file for the actual build script.Don’t forget to make the file executable by running the following in the terminal:
Step 1: Prepare Working Folders
⚠️ Disclaimer 2 ⚠️
The complete “recipe” of how the app should be built is contained in its
xcodeproj
file. This article is not about how to parse and retrieve this information from it.We will ignore the project file for the sake of this article. To make our life easier, we will hard-code all the details like the project name, source files, or build settings, directly into the build script.
Let’s start with some housekeeping. We need to define and create a set of folders we will be using during the building process.
When you run the script, your terminal should like this:
Notice, that the script created two folders:
Step 2: Compile Swift Files
Did you know you can call the Swift compiler directly from the terminal using
swiftc
?With the correct flags, compiling all
.swift
source files is quite a straightforward operation.I’d like to talk a little bit about the
-emit-executable
flag. According to the documentation, when this flag is used, the compiler “emits a linked executable”. When you run swiftc
in the verbose mode (-v
), you can actually see, what’s happening under the hood. The compiler creates .o
object for every .swift
file, and then calls ld
to link them into the final executable file.Notice, that we set output (
-o
) to ExampleApp.app/ExampleApp
. That’s the resulting executable file from the compilation process.How To Easily Create Macos Apps Without Xcode Password
Run the script and you should see the following:
You can also check, that the resulting executable was created inside the
ExampleApp.app
bundle:Step 3: Compile Storyboards
Source code files are not the only files which need to be compiled. We also need to compile all
.storyboard
files. The compiler for storyboards (and all the other interface builder files) is called ibtool
. The resulting files from the process have the extension .storyboardc
.Fun fact
storyboardc
files are file bundles. When you inspect the content of the bundle, you will see, that a compiled storyboard is actually just a bunch of nib
files.ibtool
doesn’t accept more than one file at a time. We need to use a for loop to iterate over all storyboards.Let’s run the script and verify the content of
ExampleApp.app
:Step 4: Process and Copy Info.plist
A valid app bundle has to contain
Info.plist
. Unfortunately, we can’t simply copy the one from the project directory. This raw file contains several variables which we need to replace with the actual values.To deal easily with
plist
files, Apple provides us with a tool called PlistBuddy. Because we don’t want to modify the original plist
we first create a temporary copy in the _BuildTemp
folder, and modify it there. Finally, we copy the processed plist
to the app bundle.Let’s run the script:
We should also verify that the processed
plist
file is there, and its content is correct:Running ExampleApp in the Simulator
At this point, we should have a valid
.app
bundle. At least for running it in the iOS simulator. You can open the simulator directly from the terminal window:To interact with iOS simulators, Apple created a tool named
simctl
. Here’s how you can install the ExampleApp
app bundle to the currently running simulator. The second command starts the installed app.I must admit I was extremely surprised when I saw the app was working!
The truth is, I thought one more step would be needed. Swift doesn’t have a stable binary interface yet and Swift runtime is not included in iOS. Thus every app has to have its own copy of the Swift runtime libraries included in the bundle.
We haven’t copied the runtime libraries into the bundle but the app works!
How To Make A Mac App Without Xcode
When compiling Swift files using
swiftc
, you can specify a dylib
runtime search folder using -Xlinker -rpath
flags. By doing so, you’re letting the linker know where to search for dynamic libraries, like the Swift-runtime ones. It turns out if you don’t specify them as I did, the search path defaults to:This is exactly the place where the Swift runtime libraries are stored on your computer!
The iOS simulator is not sandboxed and has access to all your files. It means it can easily load the runtime libraries from any arbitrary place. I had no idea about this.
As long as you target the iOS simulator, you can create a valid, fully functional, Swift iOS app without including the Swift runtime libs in the bundle.
Building for Device
As you can see, building for Simulator is quite forgiving. We don’t need to include the runtime libraries in the bundle. We also don’t need to sign it and deal with provisioning.
Changing the build script so it can produce a valid app bundle, which can be executed on an iOS device, is another level of fun.
Firstly, we need to let the script know when to build for device.
Let’s use the
--device
flag to signal the script the desired target architecture. We update the code from step 1:Secondly, we need to update the code from step 2:
Changes we made:
- We check the value of
BUILDING_FOR_DEVICE
and setTARGET
andSDK_PATH
variables accordingly. - We introduced the
OTHER_FLAGS
variable. This variable is empty for simulator builds. For device builds, we pass to the compiler additional information about where to find dynamic libraries in the app bundle. For device builds, we will HAVE TO include Swift runtime in the app bundle.
Finally:
Because all the next steps will be needed only for device builds, if we build for simulator, we can exit the build script right after step 4.
Let’s add this to the end of the script:
Step 5: Copy Swift Runtime Libraries
I already mentioned, when building for device, we need to include the Swift runtime libraries in the app bundle. Fortunately, no magic is required here. We can just simply copy the libraries to the bundle.
Let’s run the script and verify the result. Don’t forget to use
--device
.Step 6: Code Signing
I spent over 20 hours trying to figure out all the steps needed to successfully build the app for device. A half of this time I spent on this one step.
Before we start, here’s a nice picture of kittens for you.
6.1 Provisioning Profile
All your installed provisioning profiles are stored in
~/Library/MobileDevice/Provisioning Profiles/
. The first challenge is to find the correct one to use for this app.I’d strongly recommend to figure everything out in Xcode, first. If I’m not mistaken, with the free Apple dev account, you can’t even create a new provisioning profile using the web portal. You have to use Xcode for that.
Once you have the code signing working there, make a note of which provisioning profile and signing identity were used. https://newswiss873.weebly.com/install-mac-sierra-app-virus.html.
For the app bundle to be valid, it has to contain a file named
embedded.mobileprovision
in its root. How to remove apps from bottom of mac. Let’s copy the correct provisioning profile to the app bundle, and rename it:6.2 Signing Entitlements
Another file needed to successfully sign the bundle is the
.xcent
file. This file is just another plist
, created by merging project’s Entitlements
file with additional signing information.There’s no
Entitlements
file in our project, so this part of merging is done ?.The additional signing information, I was referring to, is the Apple dev team ID. This ID has to be the one from the signing identity you are about to use in the next step.
Let’s create the
.xcent
file and set the required values:6.3 Signing
Now, when we have all the required pieces in place, we perform the actual signing. The tool which will help us with this is called
codesign
.You need to specify which identity should be used for signing. You can list all available identities in the terminal using: Agenda app mac review.
For the app bundle to be valid, we need to sign all dynamic libraries in the
Frameworks
folder, and then the bundle itself. We use the xcent
file only for the final signing. Let’s finish this!Celebrate!
The last part of the script we need to write is the final message:
You can now run the script, sit back, and enjoy your victory:
Installing to an iOS Device
Unfortunately, installing the app to a connected iOS device is not at all that straightforward as it was for the simulator. Luckily, there are 3rd party tools which make the task much more pleasant.
I’m using ios-deploy.
You can list all connected devices using
-c
and then copy the identifier of the device.Finally, you install the app bundle to the device using:
Next Steps
Here’s the GitHub repo with the final version of the script.
I learned a lot when writing this article. I don’t personally plan to work on this script anymore. However, if someone is interested in improving it, here are some ideas:
- I didn’t need to touch
*.xcassets
files because there was no content inside. However, these files also need to be compiled. - It would be nice to get incremental builds working for Swift.
- The script currently builds only Swift files. What about projects with Objective-C, C++, Objective-C++, C sources?
- I don’t think it would make sense to parse
xcodeproj
and get the build parameters from it. What about getting the build settings from an XcodeGen file? - What about target dependencies (like custom embedded frameworks) that also need to be built?
Special thanks to Harlan Haskins for helping me with the article by answering my questions.
Do you see a typo or have a comment? PRs and issues appreciated!
Recent Posts
Developers can start building apps today and first system ships by year’s end, beginning a two-year transition
Cupertino, California — In a historic day for the Mac, Apple today announced it will transition the Mac to its world-class custom silicon to deliver industry-leading performance and powerful new technologies. Developers can now get started updating their apps to take advantage of the advanced capabilities of Apple silicon in the Mac. This transition will also establish a common architecture across all Apple products, making it far easier for developers to write and optimise their apps for the entire ecosystem.
Apple today also introduced macOS Big Sur, the next major release of macOS, which delivers its biggest update in more than a decade and includes technologies that will ensure a smooth and seamless transition to Apple silicon. Developers can easily convert their existing apps to run on Apple silicon, taking advantage of its powerful technologies and performance. And for the first time, developers can make their iOS and iPadOS apps available on the Mac without any modifications.
To help developers get started with Apple silicon, Apple is also launching the Universal App Quick Start Program, which provides access to documentation, forums support, beta versions of macOS Big Sur and Xcode 12, and the limited use of a Developer Transition Kit (DTK), a Mac development system based on Apple’s A12Z Bionic System on a Chip (SoC).
Apple plans to ship the first Mac with Apple silicon by the end of the year and complete the transition in about two years. Apple will continue to support and release new versions of macOS for Intel-based Macs for years to come, and has exciting new Intel-based Macs in development. The transition to Apple silicon represents the biggest leap ever for the Mac.
“From the beginning, the Mac has always embraced big changes to stay at the forefront of personal computing. Today we’re announcing our transition to Apple silicon, making this a historic day for the Mac,” said Tim Cook, Apple’s CEO. “With its powerful features and industry-leading performance, Apple silicon will make the Mac stronger and more capable than ever. I’ve never been more excited about the future of the Mac.”
Family of Mac SoCs to Deliver Powerful New Features and Best-in-Class Performance
For over a decade, Apple’s world-class silicon design team has been building and refining Apple SoCs. The result is a scalable architecture custom designed for iPhone, iPad, and Apple Watch that leads the industry in unique features and performance per watt, and makes each of them best in class. Building upon this architecture, Apple is designing a family of SoCs for the Mac. This will give the Mac industry-leading performance per watt and higher performance GPUs — enabling app developers to write even more powerful pro apps and high-end games. And access to technologies such as the Neural Engine will make the Mac an amazing platform for developers to use machine learning. This will also create a common architecture across all Apple products, making it far easier for developers to write and optimise software for the entire Apple ecosystem.
macOS Big Sur Enables Transition to Apple Silicon
In macOS Big Sur, Apple is offering a range of technologies to make the transition to Apple silicon smooth and seamless. With everything built into Xcode 12, such as native compilers, editors, and debugging tools, most developers will be able to get their apps running in a matter of days. Using Universal 2 application binaries, developers will be able to easily create a single app that taps into the native power and performance of the new Macs with Apple silicon, while still supporting Intel-based Macs. With the translation technology of Rosetta 2, users will be able to run existing Mac apps that have not yet been updated, including those with plug-ins. Virtualization technology allows users to run Linux. Developers can also make their iOS and iPadOS apps available on the Mac without any modifications.
Quick Start Program Lets Developers Get Started Today
Apple Developer Program members can start moving their apps to Apple silicon today by applying for the Universal App Quick Start Program. The program provides access to documentation, forums support, beta versions of macOS Big Sur and Xcode 12, and includes the limited use of a DTK, which will enable developers to build and test their Universal 2 apps. The DTK, which must be returned to Apple at the end of the program, consists of a Mac mini with Apple’s A12Z Bionic SoC inside and desktop specs, including 16GB of memory, a 512GB SSD, and a variety of Mac I/O ports. Developers can apply to the program at developer.apple.com, and the total cost of the program is £479.
Images of Developer Software
Apple revolutionised personal technology with the introduction of the Macintosh in 1984. Today, Apple leads the world in innovation with iPhone, iPad, Mac, Apple Watch and Apple TV. Apple’s five software platforms — iOS, iPadOS, macOS, watchOS and tvOS — provide seamless experiences across all Apple devices and empower people with breakthrough services including the App Store, Apple Music, Apple Pay and iCloud. Apple’s more than 100,000 employees are dedicated to making the best products on earth, and to leaving the world better than we found it.
Press Contacts
Juriaan Bosman
Apple
020 8278 1440
How To Easily Create Macos Apps Without Xcode Version
Apple Media Helpline
How To Easily Create Macos Apps Without Xcode Install
020 3284 6333