Can't run rake Specs because of incorrect paths

41 views
Skip to first unread message

m.ka...@gmail.com

unread,
Jan 12, 2015, 10:43:20 AM1/12/15
to cedar-...@googlegroups.com
Since I'm running a Cocoapods setup with RestKit 0.20.3, I can't launch xcodebuild with the .xcodeproj file and instead have to use the .xcworkspace per Cocoapods' docs. I modified the xcodebuild command under the build_specs task in my Rakefile.  It initially looked like this:

CedarTargetSpecs.system_or_exit "pushd #{CedarTargetSpecs::PROJECT_ROOT} && xcodebuild -target #{CedarTargetSpecs::UI_SPECS_TARGET_NAME} -configuration #{CedarTargetSpecs::CONFIGURATION} -sdk iphonesimulator clean build ARCHS=i386 && popd", CedarTargetSpecs.output_file("Specs")

I had to change it to this:

CedarTargetSpecs.system_or_exit "pushd #{CedarTargetSpecs::PROJECT_ROOT} && xcodebuild -workspace \"My-App-Project.xcworkspace\" -scheme #{CedarTargetSpecs::UI_SPECS_TARGET_NAME} -configuration #{CedarTargetSpecs::CONFIGURATION} -sdk iphonesimulator clean build ARCHS=i386 && popd", CedarTargetSpecs.output_file("Specs")

Note that I added the -workspace option with -scheme and removed -target.

Now, when I run rake Specs, I'll get the following error when it tries to launch ios-sim (running Specs from XCode runs fine):

-------

Touch /Users/SoftwareDev/Library/Developer/Xcode/DerivedData/My-App-Project-hhxpbduwsokzdacgrhmtptgmcepj/Build/Products/Release-iphonesimulator/Specs.app

    cd /Users/SoftwareDev/Documents/workspace/My-App-Project

    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/SoftwareDev/.rbenv/versions/1.9.3-p194/bin:/usr/local/Cellar/rbenv/0.4.0/libexec:/Users/SoftwareDev/.rbenv/versions/1.9.3-p194/gemsets/global/bin:/Users/SoftwareDev/.rbenv/versions/1.9.3-p194/gemsets/global/bin:/usr/local/Cellar/rbenv/0.4.0/libexec:/usr/local/heroku:/usr/local/heroku/bin:/usr/local/Cellar/postgresql/9.1.3/bin:/usr/local/bin:/Users/SoftwareDev/.rbenv/shims:/Users/SoftwareDev/.rbenv/bin:/android-sdk-mac_86/platform-tools:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"

    /usr/bin/touch -c /Users/SoftwareDev/Library/Developer/Xcode/DerivedData/My-App-Project-hhxpbduwsokzdacgrhmtptgmcepj/Build/Products/Release-iphonesimulator/Specs.app

** BUILD SUCCEEDED **

Executing ios-sim launch ./build/Release-iphonesimulator/Specs.app --devicetypeid 'com.apple.CoreSimulator.SimDeviceType.iPhone-6, 8.1' | tee /dev/stderr | grep -q ', 0 failures'

Application path /Users/SoftwareDev/Documents/workspace/My-App-Project/build/Release-iphonesimulator/Specs.app doesn't exist!

rake aborted!

******** Build failed ********

Tasks: TOP => Specs

(See full trace by running task with --trace)

------

This is clearly because it's looking at the wrong location and the built Specs.app is elsewhere.  You can see that from the Touch output vs. the execution of ios-sim.  I can hardcode the path in the Rakefile under def build_dir to look like this:

      File.join("/Users/SoftwareDev/Library/Developer/Xcode/DerivedData/My-App-Project-hhxpbduwsokzdacgrhmtptgmcepj/Build/Products/Release" + effective_platform_name)

and rake Specs runs to completion. I have a few questions here:

1.  Is the original directory in the Rakefile the recommended build directory?  If so, how would I change that in my project?
2.  How can I dynamically get the path of the built product directory so I can change the Rakefile if I need to?

I'm running cedar version 0.11.2, XCode 6.1.1.  Thanks.

Andrew Kitchen

unread,
Jan 13, 2015, 4:53:21 PM1/13/15
to cedar-...@googlegroups.com
Thanks for getting in touch.  The example Rakefile definitely has some tech debt, as it pre-dates the prevalent usage of Cocoapods by a few years I believe.

Anyway, I've added a story in Cedar's official backlog to address this: https://www.pivotaltracker.com/story/show/86058608

To answer your questions, you could try setting SYMROOT before your build, or reading it from the ENV after your build to find the path to your Specs.app.  Most of our Rakefile code sets it, such as:

```
xcodebuild -project #{PROJECT_NAME}.xcodeproj -configuration #{CONFIGURATION} SYMROOT=#{BUILD_DIR.inspect} clean build
```

--
You received this message because you are subscribed to the Google Groups "Cedar Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cedar-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

m.ka...@gmail.com

unread,
Jan 14, 2015, 9:35:11 AM1/14/15
to cedar-...@googlegroups.com
Thanks for the reply.  I'll try this.  For the time being, I had found another way of doing it as well.  I created my own function to find the target build directory from xcodebuild and use that directly in the ios-sim launch command:

```
    def target_build_dir
      in_project_dir do
        `xcodebuild -showBuildSettings -workspace \'My-App-Project.xcworkspace\' -scheme #{UI_SPECS_TARGET_NAME} -configuration Release -sdk iphonesimulator | grep TARGET_BUILD_DIR | awk '{print $3 }'`.strip
      end
    end

Then in task :Specs:

CedarTargetSpecs.system_or_exit "ios-sim launch #{File.join(CedarTargetSpecs.target_build_dir, "#{CedarTargetSpecs::UI_SPECS_TARGET_NAME}.app")} ...
```

I also noticed the env_vars don't make it into the ios-sim command.  I'm guessing this is our responsibility, but simple to fix.
Reply all
Reply to author
Forward
0 new messages