Simplifying new xcode / macOS projects using XCodeGen

659 views
Skip to first unread message

John Pope

unread,
Jan 3, 2019, 3:27:16 PM1/3/19
to Swift for TensorFlow
There's quite a few gotchas to ensure new projects are working / as well as older projects.

It seems there's a push to use either the jupyter notebook - or playgrounds - but for me having an xcode command line project is more appealing.
It can time consuming getting everything up and running if you want to quickly test stuff out.

So - with that background - I introduce XCodeGen -
brew install xcodegen
You detail a yml file with settings -/ compiler flags /  xcconfig.
Here we can capture - all these steps in a template.
 
debug.xcconfig
LD_RUNPATH_SEARCH_PATHS = "/Library/Developer/Toolchains/swift-latest/usr/lib/swift/macosx"
SWIFT_OPTIMIZATION_LEVEL = -O
OTHER_LDFLAGS =  -lpython




project.yml


name: SwiftTensorflow
options:
bundleIdPrefix: org.tensorflow.swift
configFiles:
Debug: debug.xcconfig
Release: debug.xcconfig
targets:
SwiftTorch:
type: tool
platform: macOS
deploymentTarget: "10.13"
sources:
- Sources
dependencies:
- framework: /Library/Developer/Toolchains/swift-latest/usr/lib/swift/macosx/libtensorflow_framework.so
- framework: /Library/Developer/Toolchains/swift-latest/usr/lib/swift/macosx/libtensorflow.so
- framework: libpython2.7.tbd
SUPPORTED_PLATFORMS: macosx


and then all you have to do is run 

xcodegen generate

it will read the project.yml and spit out a project.


I have a ticket open to turn the UseModernBuildSystem to false / otherwise you will get TensorFlow not found error

(that means you still have to go to File > Project Settings > Build System > Legacy Build System) 

https://github.com/yonaskolb/XcodeGen/issues/470







John Pope

unread,
Jan 4, 2019, 9:42:26 AM1/4/19
to Swift for TensorFlow
So it turns out you only need one file to bootstrap a new swift for tensorflow xcode project -
 just run XcodeGen to spit out new pre-configured xcode project.

Screen Shot 2019-01-04 at 9.39.40 AM.png



As long as the symlink for swift-latest is up to date ongoingly - then this approach would be superior to getting up and running - rather than hardcoding to specific builds. 
Reply all
Reply to author
Forward
0 new messages