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
2
Question by BenoitFreslon · Jun 08, 2015 at 08:22 AM · ios

How to specify -ObjC in Other Linker Flag in Xcode with Unity 5

Hello,

When I try to build my Unity project to Xcode project the -ObjC in Other Linker Flag is missing but I have to add this flag.

Is it possible to add automatically this flag with Unity?

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 kobyle · Sep 12, 2015 at 07:21 PM 0
Share

Any clue?

2 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by Andrey-Postelzhuk · Oct 28, 2015 at 03:18 PM

Hi. You can use third party XUPorter: https://github.com/onevcat/XUPorter

But, if you are using Unity5 it's better to use UnityEditor.iOS.Xcode.PBXProject.

Here is a documentation: http://docs.unity3d.com/ScriptReference/iOS.Xcode.PBXProject.html

Here is an example: link

This is short example:

     [PostProcessBuild(700)]
     public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
     {
         if (target != BuildTarget.iOS)
         {
             return;
         }
 
         string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
         PBXProject proj = new PBXProject();
         proj.ReadFromString(File.ReadAllText(projPath));
         string targetGUID = proj.TargetGuidByName("Unity-iPhone");
         proj.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-ObjC"); 
         File.WriteAllText(projPath, proj.WriteToString());
     }

Comment
Add comment · Show 1 · 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 plingativator · Mar 01, 2016 at 01:07 AM 0
Share

I just spent most of a day trying to figure out how to modify my xcode project as a post-process. This new class is great. I can add frameworks and flags so easily.

A note to anyone else: if you're not sure what a specific property string needs to be you can look in the pbx file (inside the xcodeproj) and it will have the properly formatted string there (since xcode won't display it like this).

avatar image
1

Answer by Fattie · Jan 10, 2019 at 08:07 PM

2019...

Here's exactly how you do it with modern syntax - enjoy!

 using System.IO;
 using UnityEngine;
 using UnityEditor;
 using UnityEditor.Callbacks;
 using UnityEditor.iOS.Xcode;
 
 
 public class BuildPostProcessor {
 
     [PostProcessBuildAttribute(1)]
     public static void OnPostProcessBuild(BuildTarget target, string path) {
 
         Debug.Log(">> Automation by Fattie .2019 <<");
 
         if (target == BuildTarget.iOS) {
 
             PBXProject project = new PBXProject();
             string sPath = PBXProject.GetPBXProjectPath(path);
             project.ReadFromFile(sPath);
 
             string tn = PBXProject.GetUnityTargetName();
             string g = project.TargetGuidByName(tn);
 
             ModifyAsDesired(project, g);
 
             File.WriteAllText(sPath, project.WriteToString());
         }
     }
 
     static void ModifyAsDesired(PBXProject project, string g) {
 
         // add hella frameworks
 
         project.AddFrameworkToProject(g, "VideoToolbox.framework", false);
         project.AddFrameworkToProject(g, "libz.tbd", false);
         project.AddFrameworkToProject(g, "libbz2.tbd", false);
 
         // go insane with build settings
 
         project.AddBuildProperty(g,
             "LIBRARY_SEARCH_PATHS",
             "../FFmpeg-iOS/lib");
 
         project.AddBuildProperty(g,
             "OTHER_LDFLAGS",
             "-lavcodec -lavformat -lavutil -lswresample");
     }
 }



Call it BuildPostProcessor.csd and put it in /Assets/Editor.


Enjoy !

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

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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Is Boo supported for Android/iOS since Unity 4? 1 Answer

www not working on android and iOS 0 Answers

How to use Unity for playback of a simulation within IOS 0 Answers

iOS native camera framework is always included 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