Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FastLanes. Run sh action in Xcode project root folder

Tags:

ios

fastlane

Running fastlane build_and_rename on the following Fastfile,

  lane :build_and_rename do
    sigh
    gym(output_directory: "./Build/")
    sh "mv ./Build/MY-APP.ipa ./Build/nicely_name.ipa"
  end

results in the following error ln: ./Build/MY-APP.ipa: No such file or directory.

Testing shows that FastLane's sh action runs in the ./fastlane directory. Example, fastlane test_sh for the following Fastfile

  lane :test_sh do
    sh "touch where_am_i.txt"
  end

results in a where_am_i.txt created in the ./fastlane folder. Not in the folder where fastlane was run.

Obviously I could change all scripts to include ../ but wondering if there was a way to make fastlane run sh action in xCode's root project?

like image 590
ajmccall Avatar asked Nov 04 '15 14:11

ajmccall


2 Answers

It turns out to be rather simple, just add cd.. && to change to the root directory.

lane :test_sh do
    sh "cd .. && touch where_am_i.txt"
end

https://github.com/fastlane/fastlane/issues/990#issuecomment

like image 151
ajmccall Avatar answered Oct 22 '22 04:10

ajmccall


To change the directory you can use Ruby, Dir.chdir

Example

lane :test_sh do
  Dir.chdir("..") do
    # code here runs in the parent directory
    sh "touch where_am_i.txt"
  end    
end

See Fastlane docs

like image 2
Colin Bacon Avatar answered Oct 22 '22 03:10

Colin Bacon