Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by a.macleod · Jan 27, 2014 at 04:02 PM · maccommand-linebatchmode

How can I "Switch Platform" from a script on Mac?

I have a cross-platform game that I want to build automatically for iOS and Android. My build machine is a Mac Mini, but I would like to be able to build on multiple machines using Jenkins. At this point, I have scripts set up that make the Android build nicely, but there is a lot of interactive preparation that I was hoping to avoid through automation.

The big hangup right now is this: whenever I have a "clean workspace", the editor seems to try and build "PC, Mac & Linux Standalone". This leads to compilation errors regarding conditionally-compiled blocks (`#if UNITY_IPHONE` and so on).

If I manually fire up Unity once in that folder and use the "Switch Platform" button from the Build Settings panel, all subsequent automated builds work just fine.

Is there any way to do the same thing as "Switch Platform" from the command line? I am using something like the AutoBuilder script from http://wiki.unity3d.com/index.php?title=AutoBuilder with "executeMethod" from the command line. The script has a line to switch target, but maybe it is not effective:

 EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
 BuildPipeline.BuildPlayer(scenes, path, BuildTarget.Android, BuildOptions.None);

The command line I am using is:

 Unity -batchmode -quit -executeMethod Builder.Android -projectPath ./proj -logfile unity_build_log.txt

Do I need to do anything more than that?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pjepsen · Feb 07, 2014 at 12:17 AM 0
Share

We have the same problem, this is a real short co$$anonymous$$g of unity and should be addressed ASAP by the dev $$anonymous$$m.

avatar image a.macleod · Mar 03, 2014 at 02:58 PM 0
Share

I have discovered that if I transplant the entire Library directory from a manually-switched project into the new workspace, the automated build functions correctly.

The first build after the transplant takes longer, apparently due to needing to re-load assets.

I have not been able to narrow down which file or files in Library indicate to Unity what platform to use.

avatar image a.macleod · Mar 04, 2014 at 03:52 PM 0
Share

A colleague suggested to me that there might be compile errors when the default "Standalone" platform is selected, which would prevent Unity from even getting to the SwitchActiveBuildTarget line.

If I have some spare time, I will test this theory, and see if some judicious use of #if UNITY_STANDALONE solves the issue.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by a.macleod · Mar 11, 2014 at 08:32 PM

I tested my colleague's theory and it seems to be correct.

In order to use a script in Assets/Editor the game must be able to compile everything for whatever platform is currently selected. This means that if you want to do an automated build from a clean checkout, the game must compile for Standalone.

In my case, since we do not actually care about building for Standalone, this means I can take some liberties with #if UNITY_STANDALONE to just disable sections of code that would otherwise have caused compilation errors. The compilation phase leading up to invocation of the argument passed to -executeMethod is entirely in Editor-space, so UNITY_EDITOR is also defined.

By combining this knowledge and the usage of smcs.rsp as described in the Global Custom Defaults section of https://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html I was able to get my automated build up and running without excess human intervention.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

-batchmode flag only available in PRO? 1 Answer

How to execute async method in batchmode correctly?,Questions about how to execute async method in batchmode 1 Answer

Does EditorApplication.update get called in -batchmode when calling -executeMethod? 1 Answer

Unity standalone crash when lanughing on batchmode 0 Answers

Linux editor attempting to connect to X even in batch mode with -nographics. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges