How to use xcode - 10 common examples

To help you get started, we’ve selected a few xcode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QuickBlox / quickblox-javascript-sdk / samples / chat-cordova / platforms / ios / cordova / lib / prepare.js View on Github external
function handleBuildSettings(platformConfig, locations) {
    var targetDevice = parseTargetDevicePreference(platformConfig.getPreference('target-device', 'ios'));
    var deploymentTarget = platformConfig.getPreference('deployment-target', 'ios');

    // no build settings provided, we don't need to parse and update .pbxproj file
    if (!targetDevice && !deploymentTarget) {
        return Q();
    }

    var proj = new xcode.project(locations.pbxproj);

    try {
        proj.parseSync();
    } catch (err) {
        return Q.reject(new CordovaError('An error occured during parsing of project.pbxproj. Start weeping. Output: ' + err));
    }

    if (targetDevice) {
        events.emit('verbose', 'Set TARGETED_DEVICE_FAMILY to ' + targetDevice + '.');
        proj.updateBuildProperty('TARGETED_DEVICE_FAMILY', targetDevice);
    }

    if (deploymentTarget) {
        events.emit('verbose', 'Set IPHONEOS_DEPLOYMENT_TARGET to "' + deploymentTarget + '".');
        proj.updateBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', deploymentTarget);
    }
github facebook / react-native-fbsdk / bin / ios_setup.js View on Github external
function updateFBSDKFrameworks(next) {
  const files = fs.readdirSync('./ios/');
  var myProjName = files.filter(f => { return f.substr(-10) === '.xcodeproj'; })[0];
  const myProjPath = path.join('./ios/', myProjName, '/project.pbxproj');
  myProjName = myProjName.replace('.xcodeproj', '');
  console.log('Updating target:' + myProjName + ' at ' + myProjPath + ' ...');

  const myProj = xcode.project(myProjPath);
  myProj.parse(function(err) {
    if (err) {
      next(err);
      return;
    }
    myProj.pbxCreateGroup('Frameworks', './ios/Frameworks');

    // NOTE: Assumes first target is the app.
    const target = myProj.getFirstTarget().uuid;
    myProj.addFramework('./ios/Frameworks/FBSDKCoreKit.framework', {'customFramework': true, target, 'link': true});
    myProj.addFramework('./ios/Frameworks/FBSDKShareKit.framework', {'customFramework': true, target, 'link': true});
    myProj.addFramework('./ios/Frameworks/FBSDKLoginKit.framework', {'customFramework': true, target, 'link': true});

    // WARNING: this will overwrite any existing search paths
    myProj.updateBuildProperty('FRAMEWORK_SEARCH_PATHS', '"$(PROJECT_DIR)/Frameworks/"');
    fs.writeFileSync(myProjPath, myProj.writeSync());
github appium / appium-ios-driver / lib / ios-log.js View on Github external
async startCapture () {
    if (this.udid) { // if we have a real device
      return await this.startCaptureRealDevice();
    }
    // otherwise, if we have a simulator...
    let xcodeVersion = await xcode.getVersion();
    let ver = parseInt(xcodeVersion.split('.')[0], 10);

    if (ver < 5) {
      logger.debug('Starting iOS6.* simulator log capture');
      this.proc = new SubProcess('tail', ['-f', '-n', '1', '/var/log/system.log']);
      await this.finishStartingLogCapture();
      return;
    }

    let logsPath;

    if (ver >= 6) {
      logger.debug('Starting iOS 8.*/9.* simulator log capture');
      if (_.isUndefined(this.simUdid)) {
        logger.errorAndThrow('iOS 8*/9.* log capture requires a sim udid');
      }
github apache / cordova-ios / bin / lib / create.js View on Github external
newLine = newLine.replace(/sourceTree.+?;/, 'sourceTree = \"\";'); /* eslint no-useless-escape : 0 */
            if (!newLine.match('name')) {
                newLine = newLine.replace('path = ', 'name = CordovaLib.xcodeproj; path = ');
            }
            shell.sed('-i', lines[i], newLine, path.join(projectPath, 'project.pbxproj'));
        }
    }

    if (!found) {
        throw new Error('Entry not found in project file for sub-project: ' + subprojectPath);
    }

    const wkWebViewOnly = projectConfig.getPreference('WKWebViewOnly') === 'true';
    if (wkWebViewOnly) {
        const pbxPath = path.join(cordovaLibXcodePath, 'project.pbxproj');
        const xcodeproj = xcode.project(pbxPath);
        xcodeproj.parseSync();
        xcodeproj.updateBuildProperty('WK_WEB_VIEW_ONLY', '1');
        fs.writeFileSync(pbxPath, xcodeproj.writeSync());
    }
}
github QuickBlox / quickblox-javascript-sdk / samples / cordova / video_chat / hooks / iosrtc-swift-support.js View on Github external
// Checking if the project files are in the right place
	if (!fs.existsSync(xcodeProjectPath)) {
		debugerror('an error occurred searching the project file at: "' + xcodeProjectPath + '"');

		return;
	}
	debug('".pbxproj" project file found: ' + xcodeProjectPath);

	if (!fs.existsSync(xcconfigPath)) {
		debugerror('an error occurred searching the project file at: "' + xcconfigPath + '"');

		return;
	}
	debug('".xcconfig" project file found: ' + xcconfigPath);

	xcodeProject = xcode.project(xcodeProjectPath);

	// Showing info about the tasks to do
	debug('fixing issues in the generated project files:');
	debug('- "iOS Deployment Target" and "Deployment Target" to: ' + BUILD_VERSION_XCODE);
	debug('- "Runpath Search Paths" to: ' + RUNPATH_SEARCH_PATHS_XCODE);
	debug('- "Objective-C Bridging Header" to: ' + swiftBridgingHeadXcode);
	debug('- "ENABLE_BITCODE" set to: ' + ENABLE_BITCODE_XCODE);
	debug('- "SWIFT_VERSION" set to: ' + SWIFT_VERSION_XCODE);


	// Massaging the files

	// "build.xcconfig"
	swiftOptions.push('LD_RUNPATH_SEARCH_PATHS = ' + RUNPATH_SEARCH_PATHS);
	swiftOptions.push('SWIFT_OBJC_BRIDGING_HEADER = ' + swiftBridgingHead);
	swiftOptions.push('IPHONEOS_DEPLOYMENT_TARGET = ' + BUILD_VERSION);
github JaneaSystems / nodejs-mobile-cordova / install / hooks / ios / before-plugin-uninstall.js View on Github external
var buildPhase = buildPhases[i];
      if (buildPhase.value == buildPhaseUuid) {
        buildPhases.splice(i, 1);
        break;
      }
    }
  };

  // Require the iOS platform Api to get the Xcode .pbxproj path.
  var iosPlatformPath = path.join(context.opts.projectRoot, 'platforms', 'ios');
  var iosAPI = require(path.join(iosPlatformPath, 'cordova', 'Api'));
  var iosAPIInstance = new iosAPI();
  var pbxprojPath = iosAPIInstance.locations.pbxproj;

  // Read the Xcode project and get the target.
  var xcodeProject = xcode.project(pbxprojPath);
  xcodeProject.parseSync();
  var firstTargetUUID = xcodeProject.getFirstTarget().uuid;

  // Removes the build phase to rebuild native modules.
  var rebuildNativeModulesBuildPhaseName = 'Build Node.js Mobile Native Modules';
  var rebuildNativeModulesBuildPhase = xcodeProject.buildPhaseObject('PBXShellScriptBuildPhase', rebuildNativeModulesBuildPhaseName, firstTargetUUID);
  if (rebuildNativeModulesBuildPhase) {
    xcodeProject.myRemovePbxScriptBuildPhase(rebuildNativeModulesBuildPhaseName, firstTargetUUID);
  }

  // Removes the build phase to sign native modules.
  var signNativeModulesBuildPhaseName = 'Sign Node.js Mobile Native Modules';
  var signNativeModulesBuildPhase = xcodeProject.buildPhaseObject('PBXShellScriptBuildPhase', signNativeModulesBuildPhaseName, firstTargetUUID);
  if (signNativeModulesBuildPhase) {
    xcodeProject.myRemovePbxScriptBuildPhase(signNativeModulesBuildPhaseName, firstTargetUUID);
  }
github shoutem / extensions / shoutem.firebase / app / scripts / ios / add_config_to_resources.js View on Github external
xcodeProjects.map((xcodeprojPath) => {
  const xcodeProject = xcode.project(xcodeprojPath).parseSync();

  xcodeProject.addResourceFile(configFilePath, { target: xcodeProject.getFirstTarget().uuid });
  fs.writeFileSync(xcodeprojPath, xcodeProject.writeSync());
  console.log(`iOS: Added ${configFilePath} to ${xcodeprojPath} resources`);
});
github apache / cordova-ios / bin / templates / scripts / cordova / lib / prepare.js View on Github external
if (swiftVersion) {
        events.emit('verbose', 'Set SwiftVersion to "' + swiftVersion + '".');
        project.xcode.updateBuildProperty('SWIFT_VERSION', swiftVersion);
    }
    if (wkWebViewOnly) {
        let wkwebviewValue = '1';
        if (wkWebViewOnly === 'true') {
            events.emit('verbose', 'Set WK_WEB_VIEW_ONLY.');
        } else {
            wkwebviewValue = '0';
            events.emit('verbose', 'Unset WK_WEB_VIEW_ONLY.');
        }
        project.xcode.updateBuildProperty('WK_WEB_VIEW_ONLY', wkwebviewValue);
        const cordovaLibXcodePath = path.join(locations.root, 'CordovaLib', 'CordovaLib.xcodeproj');
        const pbxPath = path.join(cordovaLibXcodePath, 'project.pbxproj');
        const xcodeproj = xcode.project(pbxPath);
        xcodeproj.parseSync();
        xcodeproj.updateBuildProperty('WK_WEB_VIEW_ONLY', wkwebviewValue);
        fs.writeFileSync(pbxPath, xcodeproj.writeSync());
    }

    updateBuildSettingsForLaunchStoryboard(project.xcode, platformConfig, infoPlist);

    project.write();

    return Q();
}
github apache / incubator-weex-cli / packages / @weex / plugins / plugin / src / plugin.ts View on Github external
installPList(projectRoot, projectPath, config) {
    const xcodeproj = xcode.project(projectPath)
    xcodeproj.parseSync()
    const xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection()
    let plistFileEntry
    let plistFile
    for (const p in xcBuildConfiguration) {
      const entry = xcBuildConfiguration[p]
      if (entry.buildSettings && entry.buildSettings.INFOPLIST_FILE) {
        plistFileEntry = entry
        break
      }
    }
    if (plistFileEntry) {
      plistFile = path.join(
        projectRoot,
        plistFileEntry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&'),
      )
github rnpm / rnpm-plugin-link / src / ios / unlinkAssets.js View on Github external
module.exports = function unlinkAssetsIOS(files, projectConfig) {
  const project = xcode.project(projectConfig.pbxprojPath).parseSync();
  const plist = getPlist(project, projectConfig.sourceDir);

  if (!plist) {
    return log.error(
      'ERRPLIST',
      `Could not locate Info.plist file. Check if your project has 'INFOPLIST_FILE' set properly`
    );
  }

  if (!project.pbxGroupByName('Resources')) {
    return log.error(
      'ERRGROUP',
      `Group 'Resources' does not exist in your XCode project. There is nothing to unlink.`
    );
  }

xcode

parser for xcodeproj/project.pbxproj files

Apache-2.0
Latest version published 4 years ago

Package Health Score

81 / 100
Full package analysis