Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automate the Creation of Xcode Projects (.xcodeproj)

How can I automate the creation of XCode projects within a terminal? If you are asking the purpose of this... I wish to create a service that can automatically create multiple different projects for different users.


ApplesScript

I believe this is possible with AppleScript, but this would be a big drain of ressources since it would open XCode. Also, this would most likely take a lot of time to create multiple projects.

*Edit: The use of AppleScript is definitely not what I am searching for in terms of performant solution.


CMake

I have looked into CMake, but I am a bit lost and confused with the documentation given for it...

*Edit: I have found the following for a CMakeLists.txt at https://gist.github.com/740257. Yet, the settings have to be modified.

# See original post at http://stackoverflow.com/questions/822404/how-to-set-up-cmake-to-build-an-app-for-the-iphone

cmake_minimum_required(VERSION 2.8)

cmake_policy(SET CMP0015 NEW)
cmake_policy(SET CMP0016 NEW)

project(test)
set(NAME test)

file(GLOB headers *.h)
file(GLOB sources *.cpp)

SET (SDKVER "4.1")
SET (DEVROOT "/Developer/Platforms/iPhoneOS.platform/Developer")
SET (SDKROOT "${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk")
SET (CMAKE_OSX_SYSROOT "${SDKROOT}")
SET (CMAKE_OSX_ARCHITECTURES "$(ARCHS_UNIVERSAL_IPHONE_OS)")

#Other 'CMAKE_OSX_ARCHITECTURES' iPhone/IOS option examples
#SET (CMAKE_OSX_ARCHITECTURES "armv6" "armv7")
#SET (CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT))


set(CMAKE_CXX_FLAGS "-x objective-c++")
set(CMAKE_EXE_LINKER_FLAGS
    "-framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework UIKit"
)
link_directories(\${HOME}/\${SDKROOT}/lib)

set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.mycompany.\${PRODUCT_NAME:identifier}")
set(APP_TYPE MACOSX_BUNDLE)

add_executable(${NAME}
    ${APP_TYPE}
    ${headers}
    ${sources}
)

target_link_libraries(${NAME}
    # other libraries to link
)

# code signing
set_target_properties(${NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: My Name")

I will build my own solution from that file. For instance, I know that the SDK version is wrong.


Terminal Tools

Are there some Developer Tools (that comes with XCode 4.2.1) for the Terminal that I could leverage for my situation?


like image 815
Alerty Avatar asked Feb 05 '12 17:02

Alerty


1 Answers

Try https://github.com/CocoaPods/Xcodeproj. It's a ruby gem that allows to create and modify xcode projects. You could use it in your scripts.

Example usage:

~/code/temp % irb                                                                                                                                            18:17
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'xcodeproj'
=> true
irb(main):003:0> project = Xcodeproj::Project.new
=> #<Xcodeproj::Project:0x400dfc080 @plist={"archiveVersion"=>"1", "classes"=>{}, "objectVersion"=>"46", "objects"=>{"ED69A76A86EE4CBD96F96E4D"=>{"isa"=>"PBXGroup", "sourceTree"=>"<group>", "children"=>[]}, "17739AA030054D088B3B573E"=>{"attributes"=>{"LastUpgradeCheck"=>"0420"}, "compatibilityVersion"=>"Xcode 3.2", "developmentRegion"=>"English", "hasScannedForEncodings"=>"0", "knownRegions"=>["en"], "mainGroup"=>"ED69A76A86EE4CBD96F96E4D", "projectDirPath"=>"", "projectRoot"=>"", "targets"=>[], "isa"=>"PBXProject"}}, "rootObject"=>"17739AA030054D088B3B573E"} @objects=<PBXObjectList: ["#<PBXGroup UUID: `ED69A76A86EE4CBD96F96E4D', name: `'>", "#<PBXProject UUID: `17739AA030054D088B3B573E', name: `'>"]>>
irb(main):004:0> project.save_as('MyProject')
=> true

See documentation here: http://rubydoc.info/gems/xcodeproj/frames

Hope this will help you!

like image 139
yas375 Avatar answered Nov 13 '22 04:11

yas375