• 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
4
Question by Simurr · Sep 30, 2015 at 08:33 PM · buildxcodeapicloudmanipulation

Is it possible to use the Xcode Manipulation API to add files to the Embedded Binaries build step?

I need to add a framework to the Embed Binaries build step in Xcode. I've asked this before but I think maybe my question was badly phrased or incomplete.

If this is easy, ignore the detailed description below. Thank you!

Within Xcode this is as simple as dragging your framework into the Embedded Binaries area in the targets General page.

embedded frameworks

This creates a build phase called Embed Frameworks

build step for embedding frameworks added

The project.pbxproj file changes are...

PBXBuildFile section reference added

         C5E4C9731BBC78F4007C4CD8 /* MyEmbedded.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C8FC40EFB7EB18859284D579 /* MyEmbedded.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 

PBXCopyFilesBuildPhase section added

 C5E4C9741BBC78F4007C4CD8 /* Embed Frameworks */ = {
             isa = PBXCopyFilesBuildPhase;
             buildActionMask = 2147483647;
             dstPath = "";
             dstSubfolderSpec = 10;
             files = (
                 C5E4C9731BBC78F4007C4CD8 /* MyEmbedded.framework in Embed Frameworks */,
             );
             name = "Embed Frameworks";
             runOnlyForDeploymentPostprocessing = 0;
         };

PBXNativeTarget section changed to include Embed Frameworks phase

 1D6058900D05DD3D006BFB54 /* Unity-iPhone */ = {
             isa = PBXNativeTarget;
             buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Unity-iPhone" */;
             buildPhases = (
                 1D60588D0D05DD3D006BFB54 /* Resources */,
                 83D0C1FB0E6C8D5900EBCE5D /* ShellScript */,
                 83D0C1FD0E6C8D7700EBCE5D /* CopyFiles */,
                 1D60588E0D05DD3D006BFB54 /* Sources */,
                 1D60588F0D05DD3D006BFB54 /* Frameworks */,
                 033966F41B18B03000ECD701 /* ShellScript */,
                 C5E4C9741BBC78F4007C4CD8 /* Embed Frameworks */,
             );
             buildRules = (
             );
             dependencies = (
             );
             name = "Unity-iPhone";
             productName = "iPhone-target";
             productReference = 1D6058910D05DD3D006BFB54 /* awesumfree.app */;
             productType = "com.apple.product-type.application";
         };

Finally, and I'm not sure if this is required, XCBuildConfiguration section for all builds (Debug, Release etc.) sets this

 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

Hopefully this is detailed enough to get me an answer. I'd really love to be able to build this with Cloud Build but that will only work if I can set this stuff up in a PostProcessBuild function.

screen-shot-2015-09-30-at-31027-pm.png (279.1 kB)
screen-shot-2015-09-30-at-31059-pm.png (148.6 kB)
Comment
Add comment · Show 1
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 Simurr · Oct 06, 2015 at 04:29 PM 0
Share

Just adding a link to the forum thread. http://forum.unity3d.com/threads/is-it-possible-to-use-the-xcode-manipulation-api-to-add-files-to-the-embedded-binaries-build-step.358357/

8 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by bilal-carameltech · Feb 22, 2018 at 11:07 AM

In Unity 2017.2 following code works for me:

 public static void OnPostprocessBuild(BuildTarget target, string projectPath) {
         
     string pbxProjPath = PBXProject.GetPBXProjectPath(projectPath);
     PBXProject pbxProject = new PBXProject();
     pbxProject.ReadFromFile(pbxProjPath);
     
     string targetName = PBXProject.GetUnityTargetName();
     string targetGuidName = pbxProject.TargetGuidByName(targetName);
     pbxProject.WriteToFile(pbxProjPath);
 
     string basePath = Application.dataPath + "/";
     string frameworkPath = "Plugins/iOS/";
     string []arrFrameworks = {"frameworkA.framework", "frameworkB.framework"};
     foreach(string framework in arrFrameworks) {
         AddEmbeddedFramework(ref pbxProject, targetGuidName, basePath + frameworkPath + framework, frameworkPath + framework);
     }
 
     pbxProject.WriteToFile (pbxProjPath);
     foreach(string framework in arrFrameworks) {
         string contents = File.ReadAllText(pbxProjPath);
         string pattern = "(?<=Embed Frameworks)(?:.*)(\\/\\* " + framework + "\\ \\*\\/)(?=; };)";
         string oldText = "/* " + framework + " */";
         string updatedText = "/* " + framework + " */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }";
         contents = Regex.Replace(contents, pattern, m => m.Value.Replace(oldText, updatedText));
         File.WriteAllText(pbxProjPath, contents);
     }
 }
 
 public static void AddEmbeddedFramework(ref PBXProject project, string target, string frameworkPath, string frameworkName) {
     string fileGuid = project.AddFile(frameworkPath, "Frameworks/" + frameworkName, PBXSourceTree.Source);
     string embedPhase = project.AddCopyFilesBuildPhase (target, "Embed Frameworks", "", "10");
     project.AddFileToBuildSection (target, embedPhase, fileGuid);
     PBXProjectExtensions.AddFileToEmbedFrameworks(project, target, fileGuid);
     project.AddBuildProperty(target, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");
     project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(SRCROOT)/PATH_TO_FRAMEWORK/");
 }
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
avatar image
0

Answer by yurenjimi · Dec 10, 2018 at 08:22 AM

For Unity 5.x https://forum.unity.com/threads/xcode-embedded-binaries.430750/#post-3979972

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
avatar image
-1

Answer by unity_GYs5GCE8dSeS8A · Jun 15, 2019 at 07:02 AM

@mihakinova

I use your file for adding Embedded Binaries file. But recently I have a framework which used alias files. When xcodeproj got ready I see just one alias file on my framework folder. The framework which I tried to add is Pushwoosh. Do you have any idea how should I do it?

Thanks for your consideration

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
  • ‹
  • 1
  • 2

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

13 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

Related Questions

Is the Cloud Build API key machine specific? 0 Answers

Bluetooth Description in Xcode 0 Answers

Distribute terrain in zones 3 Answers

Cloud Built WebGL Stopped working 0 Answers

Can Cloud Build Replace the iOS Build Process? 1 Answer


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