2

This type of question came up many years ago regarding Objective C development but I'm interested specifically in Swift.

Objectives:

Use VIM to write Swift source code (using the Swift syntax plug-in) and compile a native cocoa App (bundle) that is similar to creating a simple cocoa app from Xcode.

Motivation:

8GB downloads of the Xcode app over a fairly slow and sometimes unreliable internet connection, combined with the 'Xcode can not be open while being updated' messages means I have a few days to dedicate to an Xcode-free experience.

Secondary Motivation:

Sometimes Xcode seems to be performing hidden 'magic' under the hood and I always intended to do a deep dive on 'what is Xcode really doing' vs 'Just how much of the app is frameworks vs Xcode/Compiler magic'.

There are a number of sub-topics within this, for example: when I download an older sample projects from various sources and Xcode says - This project needs to be migrated to a newer version of Swift, using an older version of Xcode you no longer have to migrate it. Yet, these projects are primarily source code and resources and when I build an empty project and copy in the source and resources, they usually work fine (once a few syntax errors are fixed) which leaves me curious as to what these deal-breaking incompatibilities truly are.

I decided one way to investigate this is to:

  1. Use VIM to edit all required files
  2. Replace xib/nib files with programatically generated UI (I'm comfortable with this part)
  3. Use the Swift compiler to compile a cocoa app bundle and thus figure out:
  4. Which of the files created for an Xcode project relate to internal Xcode only activities vs which (and what) become compiler directives (and how).

Progress:

I created a default cocoa mac app that displays an empty window. This creates the following project files:

basicProject/basicProject/AppDelegate.swift
basicProject/basicProject/basicProject.entitlements
basicProject/basicProject/Info.plist
basicProject/basicProject/ViewController.swift
basicProject/basicProject/Assets.xcassets/Contents.json
basicProject/basicProject/Assets.xcassets/AppIcon.appiconset/Contents.json
basicProject/basicProject/Base.lproj/Main.storyboard
basicProject/basicProject.xcodeproj/project.pbxproj
basicProject/basicProject.xcodeproj/xcuserdata/username.xcuserdatad/xcschemes/xcschememanagement.plist
basicProject/basicProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata
basicProject/basicProject.xcodeproj/project.xcworkspace/xcuserdata/username.xcuserdatad/UserInterfaceState.xcuserstate
basicProject/basicProject.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

In the build directory, at the top level, I have:

someXcodeWorkDirectory/scm.plist
someXcodeWorkDirectory/OpenQuickly-ReferencedFrameworks.index-v1
someXcodeWorkDirectory/Logs
someXcodeWorkDirectory/TextIndex
someXcodeWorkDirectory/Index
someXcodeWorkDirectory/Build
someXcodeWorkDirectory/info.plist

I didn't list them all because there are circa 1,800 files for this single empty window project.

A few examples are:

./Index/DataStore/v5/records/61/NSHTTPCookieStorage.h-SNU4K7QOIQ61
./Index/DataStore/v5/records/61/mach_voucher_types.h-ZENRRUWBXU61
./Index/DataStore/v5/records/XH/SCSITaskLib.h-2051VDYD45GXH
./Index/DataStore/v5/records/XH/SCSICmds_REPORT_LUNS_Definitions.h-2H7QJ9X9DMJXH
./Index/DataStore/v5/records/21/NSResponder.h-3G5XCM1YTXX21
./Index/DataStore/v5/records/4D/NSBezierPath.h-2W852T4P4GT4D
./Index/DataStore/v5/records/4D/IOHIDLibObsolete.h-38UUUALWPN94D
./Build/Intermediates.noindex/basicProject.build/Debug/basicProject.build/all-product-headers.yaml
./Build/Intermediates.noindex/basicProject.build/Debug/basicProject.build/basicProject-all-target-headers.hmap
./Build/Intermediates.noindex/basicProject.build/Debug/basicProject.build/basicProject.hmap

What I'm looking for:

  • A general explanation of the role of these 1,800 files, such as are they Xcode generated or compiler/toolchain generated (eg: does the compiler generate these 1800 files, and, broadly speaking, why, SCSICmds?)
  • Any Links to appropriate references
  • Any Links to any similar endeavours
  • Any guidance/wisdom/intuition on how to approach/complete the task.
0

1 Answer 1

1

A good resource is Building from the Command Line: Technical Note 2339. Everything that Xcode does is done on the command line, you can see this via the 'Report Navigator'. You should first follow Apple's documentation to build apps using Xcode, because there is a lot to learn and Apple explains it all from the assumption that you will use Xcode. Then you can examine Xcode's commands in the Report Navigator. For example CodeSigning is complicated if you don't use Xcode's Automatic Signing. That's why they made the feature. If you manually generate the target bundle, it will be tricky, you will need to become a bit expert on CodeSigning to get it right.

I relate to your desire for thoroughness, but I advise you to take a second look at your objectives. For example, if you want to programmatically generate UI then just do that via code you write in your Xcode project, just don't use the UI builder. If you are doing this because you want to stay in your preferred development environment, and not learn XCode then I don't think it will work. I think the main use case for command line development of Xcode apps is devops and build test work where you need to run things within a pre-existing enterprise build/test harness.

Perhaps the easiest thing, is to use Xcode like everyone else, and just edit Swift/Objective-C/C/C++ files in the editor you prefer, then use XCode for the rest? The most up-to-date and popular Vim package for Swift development seems to be https://github.com/keith/swift.vim. And there is also a plugin to make Xcode use Vim keybindings, https://github.com/XVimProject/XVim2, albeit a stunted substitute for true Vim development.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.